123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- From: csagan5 <32685696+csagan5@users.noreply.github.com>
- Date: Sun, 27 Jun 2021 17:35:39 +0200
- Subject: Add flag to disable vibration
- ---
- chrome/browser/about_flags.cc | 4 ++++
- chrome/browser/flag_descriptions.cc | 3 +++
- chrome/browser/flag_descriptions.h | 3 +++
- content/child/runtime_features.cc | 1 +
- content/public/common/content_features.cc | 3 +++
- content/public/common/content_features.h | 2 ++
- third_party/blink/public/platform/web_runtime_features.h | 1 +
- .../blink/renderer/modules/vibration/vibration_controller.cc | 3 +++
- .../blink/renderer/platform/exported/web_runtime_features.cc | 4 ++++
- .../blink/renderer/platform/runtime_enabled_features.json5 | 4 ++++
- 10 files changed, 28 insertions(+)
- 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
- @@ -6412,6 +6412,10 @@ const FeatureEntry kFeatureEntries[] = {
- FEATURE_VALUE_TYPE(features::kNewMacNotificationAPI)},
- #endif
-
- + {"enable-vibration", flag_descriptions::kEnableVibrationName,
- + flag_descriptions::kEnableVibrationDescription, kOsAll,
- + FEATURE_VALUE_TYPE(features::kVibration)},
- +
- #if BUILDFLAG(IS_CHROMEOS_ASH)
- {"exo-gamepad-vibration", flag_descriptions::kExoGamepadVibrationName,
- flag_descriptions::kExoGamepadVibrationDescription, kOsCrOS,
- 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
- @@ -5242,6 +5242,9 @@ const char kDefaultMeetWebAppDescription[] =
- "Enables the Meet web app to be installed by default.";
- #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
-
- +const char kEnableVibrationName[] = "Vibration";
- +const char kEnableVibrationDescription[] = "Enable vibration API; an user gesture will still be needed.";
- +
- #if defined(OS_CHROMEOS)
- const char kDeprecateLowUsageCodecsName[] = "Deprecates low usage media codecs";
- const char kDeprecateLowUsageCodecsDescription[] =
- 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
- @@ -3044,6 +3044,9 @@ extern const char kDefaultMeetWebAppName[];
- extern const char kDefaultMeetWebAppDescription[];
- #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
-
- +extern const char kEnableVibrationName[];
- +extern const char kEnableVibrationDescription[];
- +
- #if defined(OS_CHROMEOS)
- extern const char kDeprecateLowUsageCodecsName[];
- extern const char kDeprecateLowUsageCodecsDescription[];
- 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
- @@ -102,6 +102,7 @@ void SetRuntimeFeatureDefaultsForPlatform(
- #if defined(OS_ANDROID)
- if (command_line.HasSwitch(switches::kDisableMediaSessionAPI))
- WebRuntimeFeatures::EnableMediaSession(false);
- + WebRuntimeFeatures::EnableVibration(base::FeatureList::IsEnabled(features::kVibration));
- #endif
-
- #if defined(OS_ANDROID)
- diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc
- --- a/content/public/common/content_features.cc
- +++ b/content/public/common/content_features.cc
- @@ -103,6 +103,9 @@ const base::Feature kBackForwardCacheSameSiteForBots{
-
- // BackForwardCacheMemoryControls is enabled only on Android to disable
- // BackForwardCache for lower memory devices due to memory limiations.
- +// Enables vibration; an user gesture will still be required if enabled.
- +const base::Feature kVibration{"Vibration",
- + base::FEATURE_DISABLED_BY_DEFAULT};
- const base::Feature kBackForwardCacheMemoryControls{
- "BackForwardCacheMemoryControls",
-
- diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h
- --- a/content/public/common/content_features.h
- +++ b/content/public/common/content_features.h
- @@ -273,6 +273,8 @@ CONTENT_EXPORT extern const base::Feature kWarmUpNetworkProcess;
- CONTENT_EXPORT extern const base::Feature kWebNfc;
- #endif // defined(OS_ANDROID)
-
- +CONTENT_EXPORT extern const base::Feature kVibration;
- +
- #if defined(OS_MAC)
- CONTENT_EXPORT extern const base::Feature kDeviceMonitorMac;
- CONTENT_EXPORT extern const base::Feature kIOSurfaceCapturer;
- 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
- @@ -90,6 +90,7 @@ class WebRuntimeFeatures {
- BLINK_PLATFORM_EXPORT static void EnableBlockingFocusWithoutUserActivation(
- bool);
- BLINK_PLATFORM_EXPORT static void EnableCacheInlineScriptCode(bool);
- + BLINK_PLATFORM_EXPORT static void EnableVibration(bool);
- BLINK_PLATFORM_EXPORT static void EnableCapabilityDelegationPaymentRequest(
- bool enable);
- BLINK_PLATFORM_EXPORT static void EnableClickPointerEvent(bool enable);
- diff --git a/third_party/blink/renderer/modules/vibration/vibration_controller.cc b/third_party/blink/renderer/modules/vibration/vibration_controller.cc
- --- a/third_party/blink/renderer/modules/vibration/vibration_controller.cc
- +++ b/third_party/blink/renderer/modules/vibration/vibration_controller.cc
- @@ -30,6 +30,7 @@
- #include "third_party/blink/renderer/core/frame/navigator.h"
- #include "third_party/blink/renderer/core/page/page.h"
- #include "third_party/blink/renderer/platform/mojo/mojo_helper.h"
- +#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
-
- // Maximum number of entries in a vibration pattern.
- const unsigned kVibrationPatternLengthMax = 99;
- @@ -149,6 +150,8 @@ bool VibrationController::vibrate(Navigator& navigator,
- // reference to |window| or |navigator| was retained in another window.
- if (!navigator.DomWindow())
- return false;
- + if (!RuntimeEnabledFeatures::VibrationEnabled())
- + return false;
- return From(navigator).Vibrate(pattern);
- }
-
- 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
- @@ -182,6 +182,10 @@ void WebRuntimeFeatures::EnableScrollTopLeftInterop(bool enable) {
- RuntimeEnabledFeatures::SetScrollTopLeftInteropEnabled(enable);
- }
-
- +void WebRuntimeFeatures::EnableVibration(bool enable) {
- + RuntimeEnabledFeatures::SetVibrationEnabled(enable);
- +}
- +
- void WebRuntimeFeatures::EnableKeyboardAccessibleTooltip(bool enable) {
- RuntimeEnabledFeatures::SetKeyboardAccessibleTooltipEnabled(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
- @@ -1575,6 +1575,10 @@
- name: "OrientationEvent",
- status: {"Android": "stable"},
- },
- + {
- + name: "Vibration",
- + status: "stable",
- + },
- {
- name: "OriginIsolationHeader",
- status: "stable",
- --
- 2.20.1
|