Don't convert pasted content to use blob URL in WebKit1
[WebKit-https.git] / Source / WebCore / page / DeprecatedGlobalSettings.cpp
1 /*
2  * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012 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. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #include "config.h"
27 #include "DeprecatedGlobalSettings.h"
28
29 #include "AudioSession.h"
30 #include "HTMLMediaElement.h"
31 #include "RuntimeApplicationChecks.h"
32 #include <wtf/NeverDestroyed.h>
33
34 #if ENABLE(MEDIA_STREAM)
35 #include "MockRealtimeMediaSourceCenter.h"
36
37 #if USE(AVFOUNDATION)
38 #include "RealtimeMediaSourceCenterMac.h"
39 #endif
40 #endif
41
42 #if PLATFORM(COCOA)
43 #include <wtf/spi/darwin/dyldSPI.h>
44 #endif
45
46 namespace WebCore {
47
48 #if USE(AVFOUNDATION)
49 bool DeprecatedGlobalSettings::gAVFoundationEnabled = true;
50 bool DeprecatedGlobalSettings::gAVFoundationNSURLSessionEnabled = true;
51 #endif
52
53 #if PLATFORM(COCOA)
54 bool DeprecatedGlobalSettings::gQTKitEnabled = false;
55 #endif
56
57 #if USE(GSTREAMER)
58 bool DeprecatedGlobalSettings::gGStreamerEnabled = true;
59 #endif
60
61 bool DeprecatedGlobalSettings::gMockScrollbarsEnabled = false;
62 bool DeprecatedGlobalSettings::gUsesOverlayScrollbars = false;
63 bool DeprecatedGlobalSettings::gMockScrollAnimatorEnabled = false;
64
65 #if ENABLE(MEDIA_STREAM)
66 bool DeprecatedGlobalSettings::gMockCaptureDevicesEnabled = false;
67 bool DeprecatedGlobalSettings::gMediaCaptureRequiresSecureConnection = true;
68 #endif
69
70 #if PLATFORM(WIN)
71 bool DeprecatedGlobalSettings::gShouldUseHighResolutionTimers = true;
72 #endif
73     
74 bool DeprecatedGlobalSettings::gShouldRespectPriorityInCSSAttributeSetters = false;
75 bool DeprecatedGlobalSettings::gLowPowerVideoAudioBufferSizeEnabled = false;
76 bool DeprecatedGlobalSettings::gResourceLoadStatisticsEnabledEnabled = false;
77 bool DeprecatedGlobalSettings::gAllowsAnySSLCertificate = false;
78
79 #if PLATFORM(IOS)
80 bool DeprecatedGlobalSettings::gNetworkDataUsageTrackingEnabled = false;
81 bool DeprecatedGlobalSettings::gAVKitEnabled = false;
82 bool DeprecatedGlobalSettings::gShouldOptOutOfNetworkStateObservation = false;
83 #endif
84 bool DeprecatedGlobalSettings::gManageAudioSession = false;
85 bool DeprecatedGlobalSettings::gCustomPasteboardDataEnabled = false;
86
87 bool DeprecatedGlobalSettings::defaultCustomPasteboardDataEnabled()
88 {
89     if (!isInWebProcess())
90         return false;
91 #if PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110300
92     return IOSApplication::isMobileSafari() || dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_11_3;
93 #elif PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
94     return MacApplication::isSafari() || dyld_get_program_sdk_version() > DYLD_MACOSX_VERSION_10_13;
95 #elif PLATFORM(MAC)
96     return MacApplication::isSafari();
97 #else
98     return false;
99 #endif
100 }
101
102 #if PLATFORM(WIN)
103 void DeprecatedGlobalSettings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
104 {
105     gShouldUseHighResolutionTimers = shouldUseHighResolutionTimers;
106 }
107 #endif
108
109 #if USE(AVFOUNDATION)
110 void DeprecatedGlobalSettings::setAVFoundationEnabled(bool enabled)
111 {
112     if (gAVFoundationEnabled == enabled)
113         return;
114
115     gAVFoundationEnabled = enabled;
116     HTMLMediaElement::resetMediaEngines();
117 }
118
119 void DeprecatedGlobalSettings::setAVFoundationNSURLSessionEnabled(bool enabled)
120 {
121     if (gAVFoundationNSURLSessionEnabled == enabled)
122         return;
123
124     gAVFoundationNSURLSessionEnabled = enabled;
125 }
126 #endif
127
128 #if PLATFORM(COCOA)
129 void DeprecatedGlobalSettings::setQTKitEnabled(bool enabled)
130 {
131     if (gQTKitEnabled == enabled)
132         return;
133
134     gQTKitEnabled = enabled;
135     HTMLMediaElement::resetMediaEngines();
136 }
137 #endif
138
139 #if USE(GSTREAMER)
140 void DeprecatedGlobalSettings::setGStreamerEnabled(bool enabled)
141 {
142     if (gGStreamerEnabled == enabled)
143         return;
144
145     gGStreamerEnabled = enabled;
146
147 #if ENABLE(VIDEO)
148     HTMLMediaElement::resetMediaEngines();
149 #endif
150 }
151 #endif
152
153 #if ENABLE(MEDIA_STREAM)
154 bool DeprecatedGlobalSettings::mockCaptureDevicesEnabled()
155 {
156     return gMockCaptureDevicesEnabled;
157 }
158
159 void DeprecatedGlobalSettings::setMockCaptureDevicesEnabled(bool enabled)
160 {
161     gMockCaptureDevicesEnabled = enabled;
162     MockRealtimeMediaSourceCenter::setMockRealtimeMediaSourceCenterEnabled(enabled);
163 }
164
165 bool DeprecatedGlobalSettings::mediaCaptureRequiresSecureConnection()
166 {
167     return gMediaCaptureRequiresSecureConnection;
168 }
169
170 void DeprecatedGlobalSettings::setMediaCaptureRequiresSecureConnection(bool mediaCaptureRequiresSecureConnection)
171 {
172     gMediaCaptureRequiresSecureConnection = mediaCaptureRequiresSecureConnection;
173 }
174 #endif
175
176 // It's very important that this setting doesn't change in the middle of a document's lifetime.
177 // The Mac port uses this flag when registering and deregistering platform-dependent scrollbar
178 // objects. Therefore, if this changes at an unexpected time, deregistration may not happen
179 // correctly, which may cause the platform to follow dangling pointers.
180 void DeprecatedGlobalSettings::setMockScrollbarsEnabled(bool flag)
181 {
182     gMockScrollbarsEnabled = flag;
183     // FIXME: This should update scroll bars in existing pages.
184 }
185
186 bool DeprecatedGlobalSettings::mockScrollbarsEnabled()
187 {
188     return gMockScrollbarsEnabled;
189 }
190
191 void DeprecatedGlobalSettings::setUsesOverlayScrollbars(bool flag)
192 {
193     gUsesOverlayScrollbars = flag;
194     // FIXME: This should update scroll bars in existing pages.
195 }
196
197 bool DeprecatedGlobalSettings::usesOverlayScrollbars()
198 {
199     return gUsesOverlayScrollbars;
200 }
201
202 void DeprecatedGlobalSettings::setUsesMockScrollAnimator(bool flag)
203 {
204     gMockScrollAnimatorEnabled = flag;
205 }
206
207 bool DeprecatedGlobalSettings::usesMockScrollAnimator()
208 {
209     return gMockScrollAnimatorEnabled;
210 }
211
212 void DeprecatedGlobalSettings::setShouldRespectPriorityInCSSAttributeSetters(bool flag)
213 {
214     gShouldRespectPriorityInCSSAttributeSetters = flag;
215 }
216
217 bool DeprecatedGlobalSettings::shouldRespectPriorityInCSSAttributeSetters()
218 {
219     return gShouldRespectPriorityInCSSAttributeSetters;
220 }
221
222 void DeprecatedGlobalSettings::setLowPowerVideoAudioBufferSizeEnabled(bool flag)
223 {
224     gLowPowerVideoAudioBufferSizeEnabled = flag;
225 }
226
227 void DeprecatedGlobalSettings::setResourceLoadStatisticsEnabled(bool flag)
228 {
229     gResourceLoadStatisticsEnabledEnabled = flag;
230 }
231
232 #if PLATFORM(IOS)
233 void DeprecatedGlobalSettings::setAudioSessionCategoryOverride(unsigned sessionCategory)
234 {
235     AudioSession::sharedSession().setCategoryOverride(static_cast<AudioSession::CategoryType>(sessionCategory));
236 }
237
238 unsigned DeprecatedGlobalSettings::audioSessionCategoryOverride()
239 {
240     return AudioSession::sharedSession().categoryOverride();
241 }
242
243 void DeprecatedGlobalSettings::setNetworkDataUsageTrackingEnabled(bool trackingEnabled)
244 {
245     gNetworkDataUsageTrackingEnabled = trackingEnabled;
246 }
247
248 bool DeprecatedGlobalSettings::networkDataUsageTrackingEnabled()
249 {
250     return gNetworkDataUsageTrackingEnabled;
251 }
252
253 static String& sharedNetworkInterfaceNameGlobal()
254 {
255     static NeverDestroyed<String> networkInterfaceName;
256     return networkInterfaceName;
257 }
258
259 void DeprecatedGlobalSettings::setNetworkInterfaceName(const String& networkInterfaceName)
260 {
261     sharedNetworkInterfaceNameGlobal() = networkInterfaceName;
262 }
263
264 const String& DeprecatedGlobalSettings::networkInterfaceName()
265 {
266     return sharedNetworkInterfaceNameGlobal();
267 }
268 #endif
269
270 bool DeprecatedGlobalSettings::globalConstRedeclarationShouldThrow()
271 {
272 #if PLATFORM(MAC)
273     return !MacApplication::isIBooks();
274 #elif PLATFORM(IOS)
275     return !IOSApplication::isIBooks();
276 #else
277     return true;
278 #endif
279 }
280
281 void DeprecatedGlobalSettings::setAllowsAnySSLCertificate(bool allowAnySSLCertificate)
282 {
283     gAllowsAnySSLCertificate = allowAnySSLCertificate;
284 }
285
286 bool DeprecatedGlobalSettings::allowsAnySSLCertificate()
287 {
288     return gAllowsAnySSLCertificate;
289 }
290
291 } // namespace WebCore