Commit 81cd0c80 authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Fetch optimizations hints when data saver is enabled via flags

Currently, optimization hints are fetched only when data saver pref is
set. This can be done by going to data saver setting or by
installing the extension on the desktop.

This CL additionally checks if data saver is enabled via command
line switch. This makes it simpler to test hints on Linux without
having to install the extension.

This is not really a user-facing change since users are not expected
to turn data saver via that switch.

Bug: 878131
Change-Id: I4f728a3e9bbfe30119257ff43c8eeb52b211732d
TBR: dougarnett@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/1313274
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604833}
parent 28c5a3cf
......@@ -14,6 +14,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/common/pref_names.h"
#include "components/component_updater/component_updater_paths.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "components/optimization_guide/optimization_guide_constants.h"
#include "components/optimization_guide/optimization_guide_service.h"
#include "components/prefs/pref_service.h"
......@@ -136,9 +137,13 @@ void RegisterOptimizationHintsComponent(ComponentUpdateService* cus,
if (!previews::params::IsOptimizationHintsEnabled()) {
return;
}
if (!profile_prefs || !profile_prefs->GetBoolean(prefs::kDataSaverEnabled)) {
bool data_saver_enabled =
base::CommandLine::ForCurrentProcess()->HasSwitch(
data_reduction_proxy::switches::kEnableDataReductionProxy) ||
(profile_prefs && profile_prefs->GetBoolean(prefs::kDataSaverEnabled));
if (!data_saver_enabled)
return;
}
auto installer = base::MakeRefCounted<ComponentInstaller>(
std::make_unique<OptimizationHintsComponentInstallerPolicy>());
installer->Register(cus, base::OnceClosure());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment