| 1 | /* |
| 2 | * Copyright (C) 2003-2016 Apple Inc. All rights reserved. |
| 3 | * (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | */ |
| 26 | |
| 27 | #pragma once |
| 28 | |
| 29 | #include <wtf/Forward.h> |
| 30 | |
| 31 | namespace WebCore { |
| 32 | |
| 33 | class DeprecatedGlobalSettings { |
| 34 | public: |
| 35 | DeprecatedGlobalSettings() = delete; |
| 36 | |
| 37 | #if PLATFORM(WIN) |
| 38 | static void setShouldUseHighResolutionTimers(bool); |
| 39 | static bool shouldUseHighResolutionTimers() { return gShouldUseHighResolutionTimers; } |
| 40 | #endif |
| 41 | |
| 42 | static bool isPostLoadCPUUsageMeasurementEnabled(); |
| 43 | static bool isPostBackgroundingCPUUsageMeasurementEnabled(); |
| 44 | static bool isPerActivityStateCPUUsageMeasurementEnabled(); |
| 45 | |
| 46 | static bool isPostLoadMemoryUsageMeasurementEnabled(); |
| 47 | static bool isPostBackgroundingMemoryUsageMeasurementEnabled(); |
| 48 | |
| 49 | static bool globalConstRedeclarationShouldThrow(); |
| 50 | |
| 51 | #if USE(AVFOUNDATION) |
| 52 | WEBCORE_EXPORT static void setAVFoundationEnabled(bool flag); |
| 53 | static bool isAVFoundationEnabled() { return gAVFoundationEnabled; } |
| 54 | WEBCORE_EXPORT static void setAVFoundationNSURLSessionEnabled(bool flag); |
| 55 | static bool isAVFoundationNSURLSessionEnabled() { return gAVFoundationNSURLSessionEnabled; } |
| 56 | #endif |
| 57 | |
| 58 | #if USE(GSTREAMER) |
| 59 | WEBCORE_EXPORT static void setGStreamerEnabled(bool flag); |
| 60 | static bool isGStreamerEnabled() { return gGStreamerEnabled; } |
| 61 | #endif |
| 62 | |
| 63 | WEBCORE_EXPORT static void setMockScrollbarsEnabled(bool flag); |
| 64 | WEBCORE_EXPORT static bool mockScrollbarsEnabled(); |
| 65 | |
| 66 | WEBCORE_EXPORT static void setUsesOverlayScrollbars(bool flag); |
| 67 | static bool usesOverlayScrollbars(); |
| 68 | |
| 69 | WEBCORE_EXPORT static void setUsesMockScrollAnimator(bool); |
| 70 | static bool usesMockScrollAnimator(); |
| 71 | |
| 72 | WEBCORE_EXPORT static void setShouldRespectPriorityInCSSAttributeSetters(bool); |
| 73 | static bool shouldRespectPriorityInCSSAttributeSetters(); |
| 74 | |
| 75 | static bool lowPowerVideoAudioBufferSizeEnabled() { return gLowPowerVideoAudioBufferSizeEnabled; } |
| 76 | WEBCORE_EXPORT static void setLowPowerVideoAudioBufferSizeEnabled(bool); |
| 77 | |
| 78 | static bool resourceLoadStatisticsEnabled() { return gResourceLoadStatisticsEnabledEnabled; } |
| 79 | WEBCORE_EXPORT static void setResourceLoadStatisticsEnabled(bool); |
| 80 | |
| 81 | #if PLATFORM(IOS_FAMILY) |
| 82 | WEBCORE_EXPORT static void setAudioSessionCategoryOverride(unsigned); |
| 83 | static unsigned audioSessionCategoryOverride(); |
| 84 | |
| 85 | WEBCORE_EXPORT static void setNetworkDataUsageTrackingEnabled(bool); |
| 86 | static bool networkDataUsageTrackingEnabled(); |
| 87 | |
| 88 | WEBCORE_EXPORT static void setNetworkInterfaceName(const String&); |
| 89 | static const String& networkInterfaceName(); |
| 90 | |
| 91 | static void setDisableScreenSizeOverride(bool flag) { gDisableScreenSizeOverride = flag; } |
| 92 | static bool disableScreenSizeOverride() { return gDisableScreenSizeOverride; } |
| 93 | #if HAVE(AVKIT) |
| 94 | static void setAVKitEnabled(bool flag) { gAVKitEnabled = flag; } |
| 95 | #endif |
| 96 | static bool avKitEnabled() { return gAVKitEnabled; } |
| 97 | |
| 98 | static void setShouldOptOutOfNetworkStateObservation(bool flag) { gShouldOptOutOfNetworkStateObservation = flag; } |
| 99 | static bool shouldOptOutOfNetworkStateObservation() { return gShouldOptOutOfNetworkStateObservation; } |
| 100 | #endif |
| 101 | |
| 102 | #if USE(AUDIO_SESSION) |
| 103 | static void setShouldManageAudioSessionCategory(bool flag) { gManageAudioSession = flag; } |
| 104 | static bool shouldManageAudioSessionCategory() { return gManageAudioSession; } |
| 105 | #endif |
| 106 | |
| 107 | WEBCORE_EXPORT static void setAllowsAnySSLCertificate(bool); |
| 108 | static bool allowsAnySSLCertificate(); |
| 109 | |
| 110 | private: |
| 111 | #if USE(AVFOUNDATION) |
| 112 | WEBCORE_EXPORT static bool gAVFoundationEnabled; |
| 113 | WEBCORE_EXPORT static bool gAVFoundationNSURLSessionEnabled; |
| 114 | #endif |
| 115 | |
| 116 | #if USE(GSTREAMER) |
| 117 | WEBCORE_EXPORT static bool gGStreamerEnabled; |
| 118 | #endif |
| 119 | |
| 120 | static bool gMockScrollbarsEnabled; |
| 121 | static bool gUsesOverlayScrollbars; |
| 122 | static bool gMockScrollAnimatorEnabled; |
| 123 | |
| 124 | #if PLATFORM(WIN) |
| 125 | static bool gShouldUseHighResolutionTimers; |
| 126 | #endif |
| 127 | static bool gShouldRespectPriorityInCSSAttributeSetters; |
| 128 | #if PLATFORM(IOS_FAMILY) |
| 129 | static bool gNetworkDataUsageTrackingEnabled; |
| 130 | WEBCORE_EXPORT static bool gAVKitEnabled; |
| 131 | WEBCORE_EXPORT static bool gShouldOptOutOfNetworkStateObservation; |
| 132 | WEBCORE_EXPORT static bool gDisableScreenSizeOverride; |
| 133 | #endif |
| 134 | WEBCORE_EXPORT static bool gManageAudioSession; |
| 135 | |
| 136 | static bool gLowPowerVideoAudioBufferSizeEnabled; |
| 137 | static bool gResourceLoadStatisticsEnabledEnabled; |
| 138 | static bool gAllowsAnySSLCertificate; |
| 139 | }; |
| 140 | |
| 141 | inline bool DeprecatedGlobalSettings::isPostLoadCPUUsageMeasurementEnabled() |
| 142 | { |
| 143 | #if PLATFORM(COCOA) |
| 144 | return true; |
| 145 | #else |
| 146 | return false; |
| 147 | #endif |
| 148 | } |
| 149 | |
| 150 | inline bool DeprecatedGlobalSettings::isPostBackgroundingCPUUsageMeasurementEnabled() |
| 151 | { |
| 152 | #if PLATFORM(MAC) |
| 153 | return true; |
| 154 | #else |
| 155 | return false; |
| 156 | #endif |
| 157 | } |
| 158 | |
| 159 | inline bool DeprecatedGlobalSettings::isPerActivityStateCPUUsageMeasurementEnabled() |
| 160 | { |
| 161 | #if PLATFORM(MAC) |
| 162 | return true; |
| 163 | #else |
| 164 | return false; |
| 165 | #endif |
| 166 | } |
| 167 | |
| 168 | inline bool DeprecatedGlobalSettings::isPostLoadMemoryUsageMeasurementEnabled() |
| 169 | { |
| 170 | #if PLATFORM(COCOA) |
| 171 | return true; |
| 172 | #else |
| 173 | return false; |
| 174 | #endif |
| 175 | } |
| 176 | |
| 177 | inline bool DeprecatedGlobalSettings::isPostBackgroundingMemoryUsageMeasurementEnabled() |
| 178 | { |
| 179 | #if PLATFORM(MAC) |
| 180 | return true; |
| 181 | #else |
| 182 | return false; |
| 183 | #endif |
| 184 | } |
| 185 | |
| 186 | } // namespace WebCore |
| 187 | |