4b7dcbc93b3cc8fca930750e8ecfdac7b221b8dc
[WebKit-https.git] / Source / WebKit / UIProcess / API / APIPageConfiguration.cpp
1 /*
2  * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27 #include "APIPageConfiguration.h"
28
29 #include "APIProcessPoolConfiguration.h"
30 #include "WebPageGroup.h"
31 #include "WebPageProxy.h"
32 #include "WebPreferences.h"
33 #include "WebProcessPool.h"
34 #include "WebUserContentControllerProxy.h"
35
36 #if ENABLE(APPLICATION_MANIFEST)
37 #include "APIApplicationManifest.h"
38 #endif
39
40 using namespace WebCore;
41 using namespace WebKit;
42
43 namespace API {
44
45 Ref<PageConfiguration> PageConfiguration::create()
46 {
47     return adoptRef(*new PageConfiguration);
48 }
49
50 PageConfiguration::PageConfiguration()
51 {
52 }
53
54 PageConfiguration::~PageConfiguration()
55 {
56 }
57
58 Ref<PageConfiguration> PageConfiguration::copy() const
59 {
60     auto copy = create();
61
62     copy->m_processPool = this->m_processPool;
63     copy->m_userContentController = this->m_userContentController;
64     copy->m_pageGroup = this->m_pageGroup;
65     copy->m_preferences = this->m_preferences;
66     copy->m_preferenceValues = this->m_preferenceValues;
67     copy->m_relatedPage = this->m_relatedPage;
68     copy->m_visitedLinkStore = this->m_visitedLinkStore;
69     copy->m_websiteDataStore = this->m_websiteDataStore;
70     copy->m_sessionID = this->m_sessionID;
71     copy->m_treatsSHA1SignedCertificatesAsInsecure = this->m_treatsSHA1SignedCertificatesAsInsecure;
72 #if PLATFORM(IOS)
73     copy->m_alwaysRunsAtForegroundPriority = this->m_alwaysRunsAtForegroundPriority;
74 #endif
75     copy->m_initialCapitalizationEnabled = this->m_initialCapitalizationEnabled;
76     copy->m_cpuLimit = this->m_cpuLimit;
77     copy->m_controlledByAutomation = this->m_controlledByAutomation;
78     copy->m_overrideContentSecurityPolicy = this->m_overrideContentSecurityPolicy;
79 #if ENABLE(APPLICATION_MANIFEST)
80     copy->m_applicationManifest = this->m_applicationManifest;
81 #endif
82
83     return copy;
84 }
85
86
87 WebProcessPool* PageConfiguration::processPool()
88 {
89     return m_processPool.get();
90 }
91
92 void PageConfiguration::setProcessPool(WebProcessPool* processPool)
93 {
94     m_processPool = processPool;
95 }
96
97 WebUserContentControllerProxy* PageConfiguration::userContentController()
98 {
99     return m_userContentController.get();
100 }
101
102 void PageConfiguration::setUserContentController(WebUserContentControllerProxy* userContentController)
103 {
104     m_userContentController = userContentController;
105 }
106
107 WebPageGroup* PageConfiguration::pageGroup()
108 {
109     return m_pageGroup.get();
110 }
111
112 void PageConfiguration::setPageGroup(WebPageGroup* pageGroup)
113 {
114     m_pageGroup = pageGroup;
115 }
116
117 WebPreferences* PageConfiguration::preferences()
118 {
119     return m_preferences.get();
120 }
121
122 void PageConfiguration::setPreferences(WebPreferences* preferences)
123 {
124     m_preferences = preferences;
125 }
126
127 WebPageProxy* PageConfiguration::relatedPage()
128 {
129     return m_relatedPage.get();
130 }
131
132 void PageConfiguration::setRelatedPage(WebPageProxy* relatedPage)
133 {
134     m_relatedPage = relatedPage;
135 }
136
137
138 VisitedLinkStore* PageConfiguration::visitedLinkStore()
139 {
140     return m_visitedLinkStore.get();
141 }
142
143 void PageConfiguration::setVisitedLinkStore(VisitedLinkStore* visitedLinkStore)
144 {
145     m_visitedLinkStore = visitedLinkStore;
146 }
147
148 API::WebsiteDataStore* PageConfiguration::websiteDataStore()
149 {
150     return m_websiteDataStore.get();
151 }
152
153 void PageConfiguration::setWebsiteDataStore(API::WebsiteDataStore* websiteDataStore)
154 {
155     m_websiteDataStore = websiteDataStore;
156
157     if (m_websiteDataStore)
158         m_sessionID = m_websiteDataStore->websiteDataStore().sessionID();
159     else
160         m_sessionID = PAL::SessionID();
161 }
162
163 PAL::SessionID PageConfiguration::sessionID()
164 {
165     ASSERT(!m_websiteDataStore || m_websiteDataStore->websiteDataStore().sessionID() == m_sessionID || m_sessionID == PAL::SessionID::legacyPrivateSessionID());
166
167     return m_sessionID;
168 }
169
170 void PageConfiguration::setSessionID(PAL::SessionID sessionID)
171 {
172     m_sessionID = sessionID;
173 }
174
175 #if ENABLE(APPLICATION_MANIFEST)
176 const ApplicationManifest* PageConfiguration::applicationManifest() const
177 {
178     return m_applicationManifest.get();
179 }
180
181 void PageConfiguration::setApplicationManifest(ApplicationManifest* applicationManifest)
182 {
183     m_applicationManifest = applicationManifest;
184 }
185 #endif
186
187 } // namespace API