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