Files
cromite/patches/BRM058_Add-flag-to-disable-device-motion-API.patch
T
2018-10-27 20:14:19 +02:00

162 lines
8.2 KiB
Diff

From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Mon, 22 Oct 2018 21:29:53 +0200
Subject: Add flag to disable device motion API
---
chrome/browser/about_flags.cc | 3 +++
chrome/browser/flag_descriptions.cc | 4 ++++
chrome/browser/flag_descriptions.h | 3 +++
content/browser/renderer_host/render_process_host_impl.cc | 1 +
content/child/runtime_features.cc | 3 +++
content/public/common/content_switches.cc | 3 +++
content/public/common/content_switches.h | 1 +
third_party/blink/public/platform/web_runtime_features.h | 1 +
third_party/blink/renderer/modules/modules_initializer.cc | 3 ++-
third_party/blink/renderer/platform/exported/web_runtime_features.cc | 4 ++++
third_party/blink/renderer/platform/runtime_enabled_features.json5 | 4 ++++
11 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -3040,6 +3040,9 @@ const FeatureEntry kFeatureEntries[] = {
{"enable-generic-sensor", flag_descriptions::kEnableGenericSensorName,
flag_descriptions::kEnableGenericSensorDescription, kOsAll,
FEATURE_VALUE_TYPE(features::kGenericSensor)},
+ {"disable-device-motion", flag_descriptions::kDisableDeviceMotionName,
+ flag_descriptions::kDisableDeviceMotionDescription, kOsAll,
+ SINGLE_DISABLE_VALUE_TYPE(switches::kDisableDeviceMotion)},
{"enable-generic-sensor-extra-classes",
flag_descriptions::kEnableGenericSensorExtraClassesName,
flag_descriptions::kEnableGenericSensorExtraClassesDescription, kOsAll,
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -556,6 +556,10 @@ const char kEnableGenericSensorDescription[] =
"Accelerometer, LinearAccelerationSensor, Gyroscope, "
"AbsoluteOrientationSensor and RelativeOrientationSensor interfaces.";
+const char kDisableDeviceMotionName[] = "Disable device motion";
+const char kDisableDeviceMotionDescription[] =
+ "Disable device motion API";
+
const char kEnableGenericSensorExtraClassesName[] =
"Generic Sensor Extra Classes";
const char kEnableGenericSensorExtraClassesDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -366,6 +366,9 @@ extern const char kEnableEnumeratingAudioDevicesDescription[];
extern const char kEnableGenericSensorName[];
extern const char kEnableGenericSensorDescription[];
+extern const char kDisableDeviceMotionName[];
+extern const char kDisableDeviceMotionDescription[];
+
extern const char kEnableGenericSensorExtraClassesName[];
extern const char kEnableGenericSensorExtraClassesDescription[];
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -2938,6 +2938,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kDisableCompositorUkmForTests,
switches::kDisablePreferCompositingToLCDText,
switches::kDisableDatabases,
+ switches::kDisableDeviceMotion,
switches::kDisableFileSystem,
switches::kDisableFrameRateLimit,
switches::kDisableGpuMemoryBufferVideoFrames,
diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc
--- a/content/child/runtime_features.cc
+++ b/content/child/runtime_features.cc
@@ -144,6 +144,9 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
if (command_line.HasSwitch(switches::kDisableSharedWorkers))
WebRuntimeFeatures::EnableSharedWorker(false);
+ if (command_line.HasSwitch(switches::kDisableDeviceMotion))
+ WebRuntimeFeatures::EnableDeviceMotion(false);
+
if (command_line.HasSwitch(switches::kDisableSpeechAPI))
WebRuntimeFeatures::EnableScriptedSpeech(false);
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -98,6 +98,9 @@ const char kDisableCompositorUkmForTests[] = "disable-compositor-ukm-for-tests";
// Disables HTML5 DB support.
const char kDisableDatabases[] = "disable-databases";
+// Disable device motion events.
+const char kDisableDeviceMotion[] = "disable-device-motion";
+
// Disable the per-domain blocking for 3D APIs after GPU reset.
// This switch is intended only for tests.
const char kDisableDomainBlockingFor3DAPIs[] =
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -42,6 +42,7 @@ CONTENT_EXPORT extern const char kDisableBlinkFeatures[];
CONTENT_EXPORT extern const char kDisableCompositorUkmForTests[];
CONTENT_EXPORT extern const char kDisableDatabases[];
CONTENT_EXPORT extern const char kDisableDisplayList2dCanvas[];
+CONTENT_EXPORT extern const char kDisableDeviceMotion[];
extern const char kDisableDomainBlockingFor3DAPIs[];
CONTENT_EXPORT extern const char kDisableWebGL[];
CONTENT_EXPORT extern const char kDisableWebGL2[];
diff --git a/third_party/blink/public/platform/web_runtime_features.h b/third_party/blink/public/platform/web_runtime_features.h
--- a/third_party/blink/public/platform/web_runtime_features.h
+++ b/third_party/blink/public/platform/web_runtime_features.h
@@ -84,6 +84,7 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableCSSFragmentIdentifiers(bool);
BLINK_PLATFORM_EXPORT static void EnableScrollTopLeftInterop(bool);
BLINK_PLATFORM_EXPORT static void EnableDatabase(bool);
+ BLINK_PLATFORM_EXPORT static void EnableDeviceMotion(bool);
BLINK_PLATFORM_EXPORT static void EnableDecodeToYUV(bool);
BLINK_PLATFORM_EXPORT static void EnableDisplayCutoutAPI(bool);
BLINK_PLATFORM_EXPORT static void EnableFastMobileScrolling(bool);
diff --git a/third_party/blink/renderer/modules/modules_initializer.cc b/third_party/blink/renderer/modules/modules_initializer.cc
--- a/third_party/blink/renderer/modules/modules_initializer.cc
+++ b/third_party/blink/renderer/modules/modules_initializer.cc
@@ -233,7 +233,8 @@ void ModulesInitializer::InitInspectorAgentSession(
void ModulesInitializer::OnClearWindowObjectInMainWorld(
Document& document,
const Settings& settings) const {
- DeviceMotionController::From(document);
+ if (RuntimeEnabledFeatures::DeviceMotionEnabled())
+ DeviceMotionController::From(document);
DeviceOrientationController::From(document);
DeviceOrientationAbsoluteController::From(document);
NavigatorGamepad::From(document);
diff --git a/third_party/blink/renderer/platform/exported/web_runtime_features.cc b/third_party/blink/renderer/platform/exported/web_runtime_features.cc
--- a/third_party/blink/renderer/platform/exported/web_runtime_features.cc
+++ b/third_party/blink/renderer/platform/exported/web_runtime_features.cc
@@ -140,6 +140,10 @@ void WebRuntimeFeatures::EnableDatabase(bool enable) {
RuntimeEnabledFeatures::SetDatabaseEnabled(enable);
}
+void WebRuntimeFeatures::EnableDeviceMotion(bool enable) {
+ RuntimeEnabledFeatures::SetDeviceMotionEnabled(enable);
+}
+
void WebRuntimeFeatures::EnableDecodeToYUV(bool enable) {
RuntimeEnabledFeatures::SetDecodeToYUVEnabled(enable);
}
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5
--- a/third_party/blink/renderer/platform/runtime_enabled_features.json5
+++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
@@ -348,6 +348,10 @@
status: "stable",
},
{
+ name: "DeviceMotion",
+ status: "stable",
+ },
+ {
name: "DecodeToYUV",
status: "experimental",
},
--
2.11.0