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 "APIWebsitePolicies.h" |
31 | #include "WebPageGroup.h" |
32 | #include "WebPageProxy.h" |
33 | #include "WebPreferences.h" |
34 | #include "WebProcessPool.h" |
35 | #include "WebURLSchemeHandler.h" |
36 | #include "WebUserContentControllerProxy.h" |
37 | |
38 | #if ENABLE(APPLICATION_MANIFEST) |
39 | #include "APIApplicationManifest.h" |
40 | #endif |
41 | |
42 | namespace API { |
43 | using namespace WebCore; |
44 | using namespace WebKit; |
45 | |
46 | Ref<PageConfiguration> PageConfiguration::create() |
47 | { |
48 | return adoptRef(*new PageConfiguration); |
49 | } |
50 | |
51 | PageConfiguration::PageConfiguration() |
52 | { |
53 | } |
54 | |
55 | PageConfiguration::~PageConfiguration() |
56 | { |
57 | } |
58 | |
59 | Ref<PageConfiguration> PageConfiguration::copy() const |
60 | { |
61 | auto copy = create(); |
62 | |
63 | copy->m_processPool = this->m_processPool; |
64 | copy->m_userContentController = this->m_userContentController; |
65 | copy->m_pageGroup = this->m_pageGroup; |
66 | copy->m_preferences = this->m_preferences; |
67 | copy->m_preferenceValues = this->m_preferenceValues; |
68 | copy->m_relatedPage = this->m_relatedPage; |
69 | copy->m_visitedLinkStore = this->m_visitedLinkStore; |
70 | copy->m_websiteDataStore = this->m_websiteDataStore; |
71 | copy->m_sessionID = this->m_sessionID; |
72 | copy->m_treatsSHA1SignedCertificatesAsInsecure = this->m_treatsSHA1SignedCertificatesAsInsecure; |
73 | #if PLATFORM(IOS_FAMILY) |
74 | copy->m_alwaysRunsAtForegroundPriority = this->m_alwaysRunsAtForegroundPriority; |
75 | copy->m_canShowWhileLocked = this->m_canShowWhileLocked; |
76 | #endif |
77 | copy->m_initialCapitalizationEnabled = this->m_initialCapitalizationEnabled; |
78 | copy->m_waitsForPaintAfterViewDidMoveToWindow = this->m_waitsForPaintAfterViewDidMoveToWindow; |
79 | copy->m_drawsBackground = this->m_drawsBackground; |
80 | copy->m_controlledByAutomation = this->m_controlledByAutomation; |
81 | copy->m_cpuLimit = this->m_cpuLimit; |
82 | copy->m_overrideContentSecurityPolicy = this->m_overrideContentSecurityPolicy; |
83 | #if ENABLE(APPLICATION_MANIFEST) |
84 | copy->m_applicationManifest = this->m_applicationManifest; |
85 | #endif |
86 | for (auto& pair : this->m_urlSchemeHandlers) |
87 | copy->m_urlSchemeHandlers.set(pair.key, pair.value.copyRef()); |
88 | |
89 | return copy; |
90 | } |
91 | |
92 | |
93 | WebProcessPool* PageConfiguration::processPool() |
94 | { |
95 | return m_processPool.get(); |
96 | } |
97 | |
98 | void PageConfiguration::setProcessPool(WebProcessPool* processPool) |
99 | { |
100 | m_processPool = processPool; |
101 | } |
102 | |
103 | WebUserContentControllerProxy* PageConfiguration::userContentController() |
104 | { |
105 | return m_userContentController.get(); |
106 | } |
107 | |
108 | void PageConfiguration::setUserContentController(WebUserContentControllerProxy* userContentController) |
109 | { |
110 | m_userContentController = userContentController; |
111 | } |
112 | |
113 | WebPageGroup* PageConfiguration::pageGroup() |
114 | { |
115 | return m_pageGroup.get(); |
116 | } |
117 | |
118 | void PageConfiguration::setPageGroup(WebPageGroup* pageGroup) |
119 | { |
120 | m_pageGroup = pageGroup; |
121 | } |
122 | |
123 | WebPreferences* PageConfiguration::preferences() |
124 | { |
125 | return m_preferences.get(); |
126 | } |
127 | |
128 | void PageConfiguration::setPreferences(WebPreferences* preferences) |
129 | { |
130 | m_preferences = preferences; |
131 | } |
132 | |
133 | WebPageProxy* PageConfiguration::relatedPage() const |
134 | { |
135 | return m_relatedPage.get(); |
136 | } |
137 | |
138 | void PageConfiguration::setRelatedPage(WebPageProxy* relatedPage) |
139 | { |
140 | m_relatedPage = relatedPage; |
141 | } |
142 | |
143 | |
144 | VisitedLinkStore* PageConfiguration::visitedLinkStore() |
145 | { |
146 | return m_visitedLinkStore.get(); |
147 | } |
148 | |
149 | void PageConfiguration::setVisitedLinkStore(VisitedLinkStore* visitedLinkStore) |
150 | { |
151 | m_visitedLinkStore = visitedLinkStore; |
152 | } |
153 | |
154 | API::WebsiteDataStore* PageConfiguration::websiteDataStore() |
155 | { |
156 | return m_websiteDataStore.get(); |
157 | } |
158 | |
159 | void PageConfiguration::setWebsiteDataStore(API::WebsiteDataStore* websiteDataStore) |
160 | { |
161 | m_websiteDataStore = websiteDataStore; |
162 | |
163 | if (m_websiteDataStore) |
164 | m_sessionID = m_websiteDataStore->websiteDataStore().sessionID(); |
165 | else |
166 | m_sessionID = PAL::SessionID(); |
167 | } |
168 | |
169 | WebsitePolicies* PageConfiguration::defaultWebsitePolicies() const |
170 | { |
171 | return m_defaultWebsitePolicies.get(); |
172 | } |
173 | |
174 | void PageConfiguration::setDefaultWebsitePolicies(WebsitePolicies* policies) |
175 | { |
176 | m_defaultWebsitePolicies = policies; |
177 | } |
178 | |
179 | PAL::SessionID PageConfiguration::sessionID() |
180 | { |
181 | ASSERT(!m_websiteDataStore || m_websiteDataStore->websiteDataStore().sessionID() == m_sessionID || m_sessionID == PAL::SessionID::legacyPrivateSessionID()); |
182 | |
183 | return m_sessionID; |
184 | } |
185 | |
186 | void PageConfiguration::setSessionID(PAL::SessionID sessionID) |
187 | { |
188 | m_sessionID = sessionID; |
189 | } |
190 | |
191 | RefPtr<WebKit::WebURLSchemeHandler> PageConfiguration::urlSchemeHandlerForURLScheme(const WTF::String& scheme) |
192 | { |
193 | return m_urlSchemeHandlers.get(scheme); |
194 | } |
195 | |
196 | void PageConfiguration::setURLSchemeHandlerForURLScheme(Ref<WebKit::WebURLSchemeHandler>&& handler, const WTF::String& scheme) |
197 | { |
198 | m_urlSchemeHandlers.set(scheme, WTFMove(handler)); |
199 | } |
200 | |
201 | #if ENABLE(APPLICATION_MANIFEST) |
202 | ApplicationManifest* PageConfiguration::applicationManifest() const |
203 | { |
204 | return m_applicationManifest.get(); |
205 | } |
206 | |
207 | void PageConfiguration::setApplicationManifest(ApplicationManifest* applicationManifest) |
208 | { |
209 | m_applicationManifest = applicationManifest; |
210 | } |
211 | #endif |
212 | |
213 | } // namespace API |
214 | |