[iOS] Expose SPI to access the current sentence boundary and selection state
[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 "WebURLSchemeHandler.h"
35 #include "WebUserContentControllerProxy.h"
36
37 #if ENABLE(APPLICATION_MANIFEST)
38 #include "APIApplicationManifest.h"
39 #endif
40
41 namespace API {
42 using namespace WebCore;
43 using namespace WebKit;
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_FAMILY)
73     copy->m_alwaysRunsAtForegroundPriority = this->m_alwaysRunsAtForegroundPriority;
74 #endif
75     copy->m_initialCapitalizationEnabled = this->m_initialCapitalizationEnabled;
76     copy->m_waitsForPaintAfterViewDidMoveToWindow = this->m_waitsForPaintAfterViewDidMoveToWindow;
77     copy->m_drawsBackground = this->m_drawsBackground;
78     copy->m_controlledByAutomation = this->m_controlledByAutomation;
79     copy->m_cpuLimit = this->m_cpuLimit;
80     copy->m_overrideContentSecurityPolicy = this->m_overrideContentSecurityPolicy;
81 #if ENABLE(APPLICATION_MANIFEST)
82     copy->m_applicationManifest = this->m_applicationManifest;
83 #endif
84     for (auto& pair : this->m_urlSchemeHandlers)
85         copy->m_urlSchemeHandlers.set(pair.key, pair.value.copyRef());
86
87     return copy;
88 }
89
90
91 WebProcessPool* PageConfiguration::processPool()
92 {
93     return m_processPool.get();
94 }
95
96 void PageConfiguration::setProcessPool(WebProcessPool* processPool)
97 {
98     m_processPool = processPool;
99 }
100
101 WebUserContentControllerProxy* PageConfiguration::userContentController()
102 {
103     return m_userContentController.get();
104 }
105
106 void PageConfiguration::setUserContentController(WebUserContentControllerProxy* userContentController)
107 {
108     m_userContentController = userContentController;
109 }
110
111 WebPageGroup* PageConfiguration::pageGroup()
112 {
113     return m_pageGroup.get();
114 }
115
116 void PageConfiguration::setPageGroup(WebPageGroup* pageGroup)
117 {
118     m_pageGroup = pageGroup;
119 }
120
121 WebPreferences* PageConfiguration::preferences()
122 {
123     return m_preferences.get();
124 }
125
126 void PageConfiguration::setPreferences(WebPreferences* preferences)
127 {
128     m_preferences = preferences;
129 }
130
131 WebPageProxy* PageConfiguration::relatedPage() const
132 {
133     return m_relatedPage.get();
134 }
135
136 void PageConfiguration::setRelatedPage(WebPageProxy* relatedPage)
137 {
138     m_relatedPage = relatedPage;
139 }
140
141
142 VisitedLinkStore* PageConfiguration::visitedLinkStore()
143 {
144     return m_visitedLinkStore.get();
145 }
146
147 void PageConfiguration::setVisitedLinkStore(VisitedLinkStore* visitedLinkStore)
148 {
149     m_visitedLinkStore = visitedLinkStore;
150 }
151
152 API::WebsiteDataStore* PageConfiguration::websiteDataStore()
153 {
154     return m_websiteDataStore.get();
155 }
156
157 void PageConfiguration::setWebsiteDataStore(API::WebsiteDataStore* websiteDataStore)
158 {
159     m_websiteDataStore = websiteDataStore;
160
161     if (m_websiteDataStore)
162         m_sessionID = m_websiteDataStore->websiteDataStore().sessionID();
163     else
164         m_sessionID = PAL::SessionID();
165 }
166
167 PAL::SessionID PageConfiguration::sessionID()
168 {
169     ASSERT(!m_websiteDataStore || m_websiteDataStore->websiteDataStore().sessionID() == m_sessionID || m_sessionID == PAL::SessionID::legacyPrivateSessionID());
170
171     return m_sessionID;
172 }
173
174 void PageConfiguration::setSessionID(PAL::SessionID sessionID)
175 {
176     m_sessionID = sessionID;
177 }
178
179 RefPtr<WebKit::WebURLSchemeHandler> PageConfiguration::urlSchemeHandlerForURLScheme(const WTF::String& scheme)
180 {
181     return m_urlSchemeHandlers.get(scheme);
182 }
183
184 void PageConfiguration::setURLSchemeHandlerForURLScheme(Ref<WebKit::WebURLSchemeHandler>&& handler, const WTF::String& scheme)
185 {
186     m_urlSchemeHandlers.set(scheme, WTFMove(handler));
187 }
188
189 #if ENABLE(APPLICATION_MANIFEST)
190 ApplicationManifest* PageConfiguration::applicationManifest() const
191 {
192     return m_applicationManifest.get();
193 }
194
195 void PageConfiguration::setApplicationManifest(ApplicationManifest* applicationManifest)
196 {
197     m_applicationManifest = applicationManifest;
198 }
199 #endif
200
201 } // namespace API