Add enterprise policy for IntensiveWakeUpThrottling feature.
This allows enterprise admins to force-enable or force-disable
the feature.
BUG=1075553
Change-Id: I1ca1a6373945100f92f0a84f2e27d323000154a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2232772
Reviewed-by: Julian Pastarmov <[email protected]>
Reviewed-by: Jeremy Roman <[email protected]>
Reviewed-by: François Doray <[email protected]>
Reviewed-by: Alexander Timin <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Commit-Queue: Chris Hamilton <[email protected]>
Cr-Commit-Position: refs/heads/master@{#776922}
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 2c4018b..6f09702a 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -224,6 +224,7 @@
#include "components/permissions/quota_permission_context_impl.h"
#include "components/policy/content/policy_blacklist_navigation_throttle.h"
#include "components/policy/content/policy_blacklist_service.h"
+#include "components/policy/core/common/policy_pref_names.h"
#include "components/policy/core/common/policy_service.h"
#include "components/policy/policy_constants.h"
#include "components/pref_registry/pref_registry_syncable.h"
@@ -346,6 +347,7 @@
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/loader/url_loader_throttle.h"
+#include "third_party/blink/public/common/switches.h"
#include "third_party/blink/public/mojom/renderer_preferences.mojom.h"
#include "third_party/blink/public/mojom/site_engagement/site_engagement.mojom.h"
#include "third_party/blink/public/mojom/user_agent/user_agent_metadata.mojom.h"
@@ -2286,6 +2288,22 @@
prefs->GetBoolean(prefs::kAppCacheForceEnabled)) {
command_line->AppendSwitch(switches::kAppCacheForceEnabled);
}
+
+ // The IntensiveWakeUpThrottling feature is typically managed via a
+ // base::Feature, but it has a managed policy override. The override is
+ // communicated to blink via a custom command-line flag. See
+ // PageSchedulerImpl for the other half of related logic.
+ PrefService* local_state = g_browser_process->local_state();
+ const PrefService::Preference* pref = local_state->FindPreference(
+ policy::policy_prefs::kIntensiveWakeUpThrottlingEnabled);
+ if (pref && pref->IsManaged()) {
+ command_line->AppendSwitchASCII(
+ blink::switches::kIntensiveWakeUpThrottlingPolicy,
+ pref->GetValue()->GetBool()
+ ? blink::switches::kIntensiveWakeUpThrottlingPolicy_ForceEnable
+ : blink::switches::
+ kIntensiveWakeUpThrottlingPolicy_ForceDisable);
+ }
}
if (IsAutoReloadEnabled())
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
index fb65b9e1..5bfbd25e 100644
--- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc
+++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -1288,6 +1288,9 @@
{ key::kAppCacheForceEnabled,
prefs::kAppCacheForceEnabled,
base::Value::Type::BOOLEAN },
+ { key::kIntensiveWakeUpThrottlingEnabled,
+ policy::policy_prefs::kIntensiveWakeUpThrottlingEnabled,
+ base::Value::Type::BOOLEAN },
};
// clang-format on
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index e5f9fd62..e7159953 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -655,7 +655,9 @@
} // namespace
void RegisterLocalState(PrefRegistrySimple* registry) {
- // Please keep this list alphabetized.
+ // Call outs to individual subsystems that register Local State (browser-wide)
+ // prefs en masse. See RegisterProfilePrefs for per-profile prefs. Please
+ // keep this list alphabetized.
browser_shutdown::RegisterPrefs(registry);
data_reduction_proxy::RegisterPrefs(registry);
data_use_measurement::ChromeDataUseMeasurement::RegisterPrefs(registry);
@@ -693,6 +695,19 @@
update_client::RegisterPrefs(registry);
variations::VariationsService::RegisterPrefs(registry);
+ // Individual preferences. If you have multiple preferences that should
+ // clearly be grouped together, please group them together into a helper
+ // function called above. Please keep this list alphabetized.
+ registry->RegisterBooleanPref(
+ policy::policy_prefs::kIntensiveWakeUpThrottlingEnabled, false);
+ registry->RegisterInt64Pref(kLastStartupTimestamp, 0);
+ registry->RegisterStringPref(kLastStartupVersion, std::string());
+ registry->RegisterIntegerPref(kSameVersionStartupCount, 0);
+
+ // Below this point is for platform-specific and compile-time conditional
+ // calls. Please follow the helper-function-first-then-direct-calls pattern
+ // established above, and keep things alphabetized.
+
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
BackgroundModeManager::RegisterPrefs(registry);
#endif
@@ -714,6 +729,8 @@
StartupBrowserCreator::RegisterLocalStatePrefs(registry);
task_manager::TaskManagerInterface::RegisterPrefs(registry);
UpgradeDetector::RegisterPrefs(registry);
+
+ registry->RegisterBooleanPref(kNtpActivateHideShortcutsFieldTrial, false);
#endif // !defined(OS_ANDROID)
#if defined(OS_CHROMEOS)
@@ -795,9 +812,6 @@
#if defined(OS_WIN)
OSCrypt::RegisterLocalPrefs(registry);
-#endif
-
-#if defined(OS_WIN)
registry->RegisterBooleanPref(prefs::kRendererCodeIntegrityEnabled, true);
registry->RegisterBooleanPref(
policy::policy_prefs::kNativeWindowOcclusionEnabled, true);
@@ -815,17 +829,11 @@
DeviceOAuth2TokenStoreDesktop::RegisterPrefs(registry);
#endif
-#if !defined(OS_ANDROID)
- registry->RegisterBooleanPref(kNtpActivateHideShortcutsFieldTrial, false);
-#endif // !defined(OS_ANDROID)
- registry->RegisterInt64Pref(kLastStartupTimestamp, 0);
- registry->RegisterStringPref(kLastStartupVersion, std::string());
- registry->RegisterIntegerPref(kSameVersionStartupCount, 0);
-
#if defined(TOOLKIT_VIEWS)
RegisterBrowserViewLocalPrefs(registry);
#endif
+ // This is intentionally last.
RegisterLocalStatePrefsForMigration(registry);
}