Turning off custom pasteboard data doesn't actually turn it off in WK2
[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 namespace WebCore {
43
44 #if USE(AVFOUNDATION)
45 bool DeprecatedGlobalSettings::gAVFoundationEnabled = true;
46 bool DeprecatedGlobalSettings::gAVFoundationNSURLSessionEnabled = true;
47 #endif
48
49 #if PLATFORM(COCOA)
50 bool DeprecatedGlobalSettings::gQTKitEnabled = false;
51 #endif
52
53 #if USE(GSTREAMER)
54 bool DeprecatedGlobalSettings::gGStreamerEnabled = true;
55 #endif
56
57 bool DeprecatedGlobalSettings::gMockScrollbarsEnabled = false;
58 bool DeprecatedGlobalSettings::gUsesOverlayScrollbars = false;
59 bool DeprecatedGlobalSettings::gMockScrollAnimatorEnabled = false;
60
61 #if ENABLE(MEDIA_STREAM)
62 bool DeprecatedGlobalSettings::gMockCaptureDevicesEnabled = false;
63 bool DeprecatedGlobalSettings::gMediaCaptureRequiresSecureConnection = true;
64 #endif
65
66 #if PLATFORM(WIN)
67 bool DeprecatedGlobalSettings::gShouldUseHighResolutionTimers = true;
68 #endif
69     
70 bool DeprecatedGlobalSettings::gShouldRespectPriorityInCSSAttributeSetters = false;
71 bool DeprecatedGlobalSettings::gLowPowerVideoAudioBufferSizeEnabled = false;
72 bool DeprecatedGlobalSettings::gResourceLoadStatisticsEnabledEnabled = false;
73 bool DeprecatedGlobalSettings::gAllowsAnySSLCertificate = false;
74
75 #if PLATFORM(IOS)
76 bool DeprecatedGlobalSettings::gNetworkDataUsageTrackingEnabled = false;
77 bool DeprecatedGlobalSettings::gAVKitEnabled = false;
78 bool DeprecatedGlobalSettings::gShouldOptOutOfNetworkStateObservation = false;
79 #endif
80 bool DeprecatedGlobalSettings::gManageAudioSession = false;
81
82 #if PLATFORM(WIN)
83 void DeprecatedGlobalSettings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
84 {
85     gShouldUseHighResolutionTimers = shouldUseHighResolutionTimers;
86 }
87 #endif
88
89 #if USE(AVFOUNDATION)
90 void DeprecatedGlobalSettings::setAVFoundationEnabled(bool enabled)
91 {
92     if (gAVFoundationEnabled == enabled)
93         return;
94
95     gAVFoundationEnabled = enabled;
96     HTMLMediaElement::resetMediaEngines();
97 }
98
99 void DeprecatedGlobalSettings::setAVFoundationNSURLSessionEnabled(bool enabled)
100 {
101     if (gAVFoundationNSURLSessionEnabled == enabled)
102         return;
103
104     gAVFoundationNSURLSessionEnabled = enabled;
105 }
106 #endif
107
108 #if PLATFORM(COCOA)
109 void DeprecatedGlobalSettings::setQTKitEnabled(bool enabled)
110 {
111     if (gQTKitEnabled == enabled)
112         return;
113
114     gQTKitEnabled = enabled;
115     HTMLMediaElement::resetMediaEngines();
116 }
117 #endif
118
119 #if USE(GSTREAMER)
120 void DeprecatedGlobalSettings::setGStreamerEnabled(bool enabled)
121 {
122     if (gGStreamerEnabled == enabled)
123         return;
124
125     gGStreamerEnabled = enabled;
126
127 #if ENABLE(VIDEO)
128     HTMLMediaElement::resetMediaEngines();
129 #endif
130 }
131 #endif
132
133 #if ENABLE(MEDIA_STREAM)
134 bool DeprecatedGlobalSettings::mockCaptureDevicesEnabled()
135 {
136     return gMockCaptureDevicesEnabled;
137 }
138
139 void DeprecatedGlobalSettings::setMockCaptureDevicesEnabled(bool enabled)
140 {
141     gMockCaptureDevicesEnabled = enabled;
142     MockRealtimeMediaSourceCenter::setMockRealtimeMediaSourceCenterEnabled(enabled);
143 }
144
145 bool DeprecatedGlobalSettings::mediaCaptureRequiresSecureConnection()
146 {
147     return gMediaCaptureRequiresSecureConnection;
148 }
149
150 void DeprecatedGlobalSettings::setMediaCaptureRequiresSecureConnection(bool mediaCaptureRequiresSecureConnection)
151 {
152     gMediaCaptureRequiresSecureConnection = mediaCaptureRequiresSecureConnection;
153 }
154 #endif
155
156 // It's very important that this setting doesn't change in the middle of a document's lifetime.
157 // The Mac port uses this flag when registering and deregistering platform-dependent scrollbar
158 // objects. Therefore, if this changes at an unexpected time, deregistration may not happen
159 // correctly, which may cause the platform to follow dangling pointers.
160 void DeprecatedGlobalSettings::setMockScrollbarsEnabled(bool flag)
161 {
162     gMockScrollbarsEnabled = flag;
163     // FIXME: This should update scroll bars in existing pages.
164 }
165
166 bool DeprecatedGlobalSettings::mockScrollbarsEnabled()
167 {
168     return gMockScrollbarsEnabled;
169 }
170
171 void DeprecatedGlobalSettings::setUsesOverlayScrollbars(bool flag)
172 {
173     gUsesOverlayScrollbars = flag;
174     // FIXME: This should update scroll bars in existing pages.
175 }
176
177 bool DeprecatedGlobalSettings::usesOverlayScrollbars()
178 {
179     return gUsesOverlayScrollbars;
180 }
181
182 void DeprecatedGlobalSettings::setUsesMockScrollAnimator(bool flag)
183 {
184     gMockScrollAnimatorEnabled = flag;
185 }
186
187 bool DeprecatedGlobalSettings::usesMockScrollAnimator()
188 {
189     return gMockScrollAnimatorEnabled;
190 }
191
192 void DeprecatedGlobalSettings::setShouldRespectPriorityInCSSAttributeSetters(bool flag)
193 {
194     gShouldRespectPriorityInCSSAttributeSetters = flag;
195 }
196
197 bool DeprecatedGlobalSettings::shouldRespectPriorityInCSSAttributeSetters()
198 {
199     return gShouldRespectPriorityInCSSAttributeSetters;
200 }
201
202 void DeprecatedGlobalSettings::setLowPowerVideoAudioBufferSizeEnabled(bool flag)
203 {
204     gLowPowerVideoAudioBufferSizeEnabled = flag;
205 }
206
207 void DeprecatedGlobalSettings::setResourceLoadStatisticsEnabled(bool flag)
208 {
209     gResourceLoadStatisticsEnabledEnabled = flag;
210 }
211
212 #if PLATFORM(IOS)
213 void DeprecatedGlobalSettings::setAudioSessionCategoryOverride(unsigned sessionCategory)
214 {
215     AudioSession::sharedSession().setCategoryOverride(static_cast<AudioSession::CategoryType>(sessionCategory));
216 }
217
218 unsigned DeprecatedGlobalSettings::audioSessionCategoryOverride()
219 {
220     return AudioSession::sharedSession().categoryOverride();
221 }
222
223 void DeprecatedGlobalSettings::setNetworkDataUsageTrackingEnabled(bool trackingEnabled)
224 {
225     gNetworkDataUsageTrackingEnabled = trackingEnabled;
226 }
227
228 bool DeprecatedGlobalSettings::networkDataUsageTrackingEnabled()
229 {
230     return gNetworkDataUsageTrackingEnabled;
231 }
232
233 static String& sharedNetworkInterfaceNameGlobal()
234 {
235     static NeverDestroyed<String> networkInterfaceName;
236     return networkInterfaceName;
237 }
238
239 void DeprecatedGlobalSettings::setNetworkInterfaceName(const String& networkInterfaceName)
240 {
241     sharedNetworkInterfaceNameGlobal() = networkInterfaceName;
242 }
243
244 const String& DeprecatedGlobalSettings::networkInterfaceName()
245 {
246     return sharedNetworkInterfaceNameGlobal();
247 }
248 #endif
249
250 bool DeprecatedGlobalSettings::globalConstRedeclarationShouldThrow()
251 {
252 #if PLATFORM(MAC)
253     return !MacApplication::isIBooks();
254 #elif PLATFORM(IOS)
255     return !IOSApplication::isIBooks();
256 #else
257     return true;
258 #endif
259 }
260
261 void DeprecatedGlobalSettings::setAllowsAnySSLCertificate(bool allowAnySSLCertificate)
262 {
263     gAllowsAnySSLCertificate = allowAnySSLCertificate;
264 }
265
266 bool DeprecatedGlobalSettings::allowsAnySSLCertificate()
267 {
268     return gAllowsAnySSLCertificate;
269 }
270
271 } // namespace WebCore