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