cc: Default value for use_distance_field_text was not set in the layer tree settings
[chromium-blink-merge.git] / content / child / runtime_features.cc
blob57395df32f4a346d7152166a31a7fc60d0d89514
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/child/runtime_features.h"
7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h"
9 #include "content/common/content_switches_internal.h"
10 #include "content/public/common/content_switches.h"
11 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
12 #include "ui/native_theme/native_theme_switches.h"
14 #if defined(OS_ANDROID)
15 #include <cpu-features.h>
16 #include "base/android/build_info.h"
17 #include "base/metrics/field_trial.h"
18 #include "media/base/android/media_codec_bridge.h"
19 #elif defined(OS_WIN)
20 #include "base/win/windows_version.h"
21 #endif
23 using blink::WebRuntimeFeatures;
25 namespace content {
27 static void SetRuntimeFeatureDefaultsForPlatform() {
28 #if defined(OS_ANDROID)
29 // MSE/EME implementation needs Android MediaCodec API.
30 if (!media::MediaCodecBridge::IsAvailable()) {
31 WebRuntimeFeatures::enableMediaSource(false);
32 WebRuntimeFeatures::enablePrefixedEncryptedMedia(false);
33 WebRuntimeFeatures::enableEncryptedMedia(false);
35 // WebAudio is enabled by default but only when the MediaCodec API
36 // is available.
37 AndroidCpuFamily cpu_family = android_getCpuFamily();
38 WebRuntimeFeatures::enableWebAudio(
39 media::MediaCodecBridge::IsAvailable() &&
40 ((cpu_family == ANDROID_CPU_FAMILY_ARM) ||
41 (cpu_family == ANDROID_CPU_FAMILY_ARM64) ||
42 (cpu_family == ANDROID_CPU_FAMILY_X86) ||
43 (cpu_family == ANDROID_CPU_FAMILY_MIPS)));
45 // Android does not have support for PagePopup
46 WebRuntimeFeatures::enablePagePopup(false);
47 // Android does not yet support the Web Notification API. crbug.com/115320
48 WebRuntimeFeatures::enableNotifications(false);
49 // Android does not yet support SharedWorker. crbug.com/154571
50 WebRuntimeFeatures::enableSharedWorker(false);
51 // Android does not yet support NavigatorContentUtils.
52 WebRuntimeFeatures::enableNavigatorContentUtils(false);
53 WebRuntimeFeatures::enableTouchIconLoading(true);
54 WebRuntimeFeatures::enableOrientationEvent(true);
55 WebRuntimeFeatures::enableFastMobileScrolling(true);
56 WebRuntimeFeatures::enableMediaCapture(true);
57 WebRuntimeFeatures::enableCompositedSelectionUpdate(true);
58 // If navigation transitions gets activated via field trial, enable it in
59 // blink. We don't set this to false in case the user has manually enabled
60 // the feature via experimental web platform features.
61 if (base::FieldTrialList::FindFullName("NavigationTransitions") == "Enabled")
62 WebRuntimeFeatures::enableNavigationTransitions(true);
63 #else
64 WebRuntimeFeatures::enableNavigatorContentUtils(true);
65 #endif // defined(OS_ANDROID)
67 #if !(defined OS_ANDROID || defined OS_CHROMEOS || defined OS_IOS)
68 // Only Android, ChromeOS, and IOS support NetInfo right now.
69 WebRuntimeFeatures::enableNetworkInformation(false);
70 #endif
72 #if defined(OS_WIN)
73 // Screen Orientation API is currently broken on Windows 8 Metro mode and
74 // until we can find how to disable it only for Blink instances running in a
75 // renderer process in Metro, we need to disable the API altogether for Win8.
76 // See http://crbug.com/400846
77 if (base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_WIN8)
78 WebRuntimeFeatures::enableScreenOrientation(false);
79 #endif // OS_WIN
82 void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
83 const base::CommandLine& command_line) {
84 if (command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures))
85 WebRuntimeFeatures::enableExperimentalFeatures(true);
87 SetRuntimeFeatureDefaultsForPlatform();
89 if (command_line.HasSwitch(switches::kDisableDatabases))
90 WebRuntimeFeatures::enableDatabase(false);
92 if (command_line.HasSwitch(switches::kDisableApplicationCache))
93 WebRuntimeFeatures::enableApplicationCache(false);
95 if (command_line.HasSwitch(switches::kDisableDesktopNotifications))
96 WebRuntimeFeatures::enableNotifications(false);
98 if (command_line.HasSwitch(switches::kDisableLocalStorage))
99 WebRuntimeFeatures::enableLocalStorage(false);
101 if (command_line.HasSwitch(switches::kDisableSessionStorage))
102 WebRuntimeFeatures::enableSessionStorage(false);
104 if (command_line.HasSwitch(switches::kDisableMediaSource))
105 WebRuntimeFeatures::enableMediaSource(false);
107 if (command_line.HasSwitch(switches::kDisableSharedWorkers))
108 WebRuntimeFeatures::enableSharedWorker(false);
110 #if defined(OS_ANDROID)
111 if (command_line.HasSwitch(switches::kDisableWebRTC))
112 WebRuntimeFeatures::enablePeerConnection(false);
114 if (!command_line.HasSwitch(switches::kEnableSpeechRecognition))
115 WebRuntimeFeatures::enableScriptedSpeech(false);
117 // WebAudio is enabled by default on ARM and X86, if the MediaCodec
118 // API is available.
119 WebRuntimeFeatures::enableWebAudio(
120 !command_line.HasSwitch(switches::kDisableWebAudio) &&
121 media::MediaCodecBridge::IsAvailable());
122 #else
123 if (command_line.HasSwitch(switches::kDisableWebAudio))
124 WebRuntimeFeatures::enableWebAudio(false);
125 #endif
127 if (command_line.HasSwitch(switches::kEnableEncryptedMedia))
128 WebRuntimeFeatures::enableEncryptedMedia(true);
130 if (command_line.HasSwitch(switches::kDisablePrefixedEncryptedMedia))
131 WebRuntimeFeatures::enablePrefixedEncryptedMedia(false);
133 if (command_line.HasSwitch(switches::kEnableWebMIDI))
134 WebRuntimeFeatures::enableWebMIDI(true);
136 if (command_line.HasSwitch(switches::kDisableFileSystem))
137 WebRuntimeFeatures::enableFileSystem(false);
139 if (command_line.HasSwitch(switches::kEnableExperimentalCanvasFeatures))
140 WebRuntimeFeatures::enableExperimentalCanvasFeatures(true);
142 if (command_line.HasSwitch(switches::kDisableDisplayList2dCanvas)) {
143 WebRuntimeFeatures::enableDisplayList2dCanvas(false);
144 } else if (command_line.HasSwitch(switches::kEnableDisplayList2dCanvas)) {
145 WebRuntimeFeatures::enableDisplayList2dCanvas(true);
146 } else {
147 WebRuntimeFeatures::enableDisplayList2dCanvas(
148 base::FieldTrialList::FindFullName("DisplayList2dCanvas") == "Enabled"
152 if (command_line.HasSwitch(switches::kEnableWebGLDraftExtensions))
153 WebRuntimeFeatures::enableWebGLDraftExtensions(true);
155 if (command_line.HasSwitch(switches::kEnableWebGLImageChromium))
156 WebRuntimeFeatures::enableWebGLImageChromium(true);
158 if (command_line.HasSwitch(switches::kEnableOverlayFullscreenVideo))
159 WebRuntimeFeatures::enableOverlayFullscreenVideo(true);
161 if (ui::IsOverlayScrollbarEnabled())
162 WebRuntimeFeatures::enableOverlayScrollbars(true);
164 if (command_line.HasSwitch(switches::kEnableBleedingEdgeRenderingFastPaths))
165 WebRuntimeFeatures::enableBleedingEdgeFastPaths(true);
167 if (command_line.HasSwitch(switches::kEnablePreciseMemoryInfo))
168 WebRuntimeFeatures::enablePreciseMemoryInfo(true);
170 if (command_line.HasSwitch(switches::kEnableLayerSquashing))
171 WebRuntimeFeatures::enableLayerSquashing(true);
173 if (command_line.HasSwitch(switches::kEnableNetworkInformation) ||
174 command_line.HasSwitch(
175 switches::kEnableExperimentalWebPlatformFeatures)) {
176 WebRuntimeFeatures::enableNetworkInformation(true);
180 } // namespace content