| Index: chrome/browser/chromeos/system/timezone_resolver_manager.cc
|
| diff --git a/chrome/browser/chromeos/system/timezone_resolver_manager.cc b/chrome/browser/chromeos/system/timezone_resolver_manager.cc
|
| index b462c39f21854e7703da8b4d92ea718c87c348b0..74c8fad3ef2d3a3ab62e0828a8f5f388cce9114e 100644
|
| --- a/chrome/browser/chromeos/system/timezone_resolver_manager.cc
|
| +++ b/chrome/browser/chromeos/system/timezone_resolver_manager.cc
|
| @@ -26,6 +26,44 @@ enum ServiceConfiguration {
|
| SHOULD_STOP = 2, // This source requires service Stop.
|
| };
|
|
|
| +// Starts or stops TimezoneResolver if required by
|
| +// SystemTimezoneAutomaticDetectionPolicy.
|
| +// Returns SHOULD_* if timezone resolver status is controlled by this policy.
|
| +ServiceConfiguration GetServiceConfigurationFromAutomaticDetectionPolicy() {
|
| + if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + chromeos::switches::kEnableSystemTimezoneAutomaticDetectionPolicy)) {
|
| + return UNSPECIFIED;
|
| + }
|
| +
|
| + PrefService* local_state = g_browser_process->local_state();
|
| + const bool is_managed = local_state->IsManagedPreference(
|
| + prefs::kSystemTimezoneAutomaticDetectionPolicy);
|
| + if (!is_managed)
|
| + return UNSPECIFIED;
|
| +
|
| + int policy_value =
|
| + local_state->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy);
|
| +
|
| + if (policy_value ==
|
| + ResolveDeviceTimezoneByGeolocationPolicyValues::USERS_DECIDE) {
|
| + return UNSPECIFIED;
|
| + }
|
| +
|
| + if (policy_value ==
|
| + ResolveDeviceTimezoneByGeolocationPolicyValues::DISABLED) {
|
| + return SHOULD_STOP;
|
| + } else if (policy_value ==
|
| + ResolveDeviceTimezoneByGeolocationPolicyValues::IP_ONLY) {
|
| + return SHOULD_START;
|
| + } else if (policy_value == ResolveDeviceTimezoneByGeolocationPolicyValues::
|
| + SEND_WIFI_ACCESS_POINTS) {
|
| + return SHOULD_START;
|
| + }
|
| + // Default for unknown policy value.
|
| + NOTREACHED() << "Unrecognized policy value: " << policy_value;
|
| + return SHOULD_STOP;
|
| +}
|
| +
|
| // Stops TimezoneResolver if SystemTimezonePolicy is applied.
|
| // Returns SHOULD_* if timezone resolver status is controlled by this policy.
|
| ServiceConfiguration GetServiceConfigurationFromSystemTimezonePolicy() {
|
| @@ -44,6 +82,7 @@ ServiceConfiguration GetServiceConfigurationFromPolicy() {
|
| if (result != UNSPECIFIED)
|
| return result;
|
|
|
| + result = GetServiceConfigurationFromAutomaticDetectionPolicy();
|
| return result;
|
| }
|
|
|
| @@ -78,6 +117,12 @@ ServiceConfiguration GetServiceConfigurationForSigninScreen() {
|
|
|
| TimeZoneResolverManager::TimeZoneResolverManager()
|
| : primary_user_prefs_(nullptr) {
|
| + local_state_pref_change_registrar_.Init(g_browser_process->local_state());
|
| + local_state_pref_change_registrar_.Add(
|
| + prefs::kSystemTimezoneAutomaticDetectionPolicy,
|
| + base::Bind(
|
| + &::chromeos::system::TimeZoneResolverManager::UpdateTimezoneResolver,
|
| + base::Unretained(this)));
|
| }
|
|
|
| TimeZoneResolverManager::~TimeZoneResolverManager() {}
|
| @@ -87,7 +132,20 @@ void TimeZoneResolverManager::SetPrimaryUserPrefs(PrefService* pref_service) {
|
| }
|
|
|
| bool TimeZoneResolverManager::ShouldSendWiFiGeolocationData() {
|
| - return false;
|
| + PrefService* local_state = g_browser_process->local_state();
|
| + const bool is_managed = local_state->IsManagedPreference(
|
| + prefs::kSystemTimezoneAutomaticDetectionPolicy);
|
| + if (!is_managed)
|
| + return false;
|
| +
|
| + int policy_value =
|
| + local_state->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy);
|
| +
|
| + DCHECK(policy_value <
|
| + ResolveDeviceTimezoneByGeolocationPolicyValues::NUM_ELEMENTS);
|
| +
|
| + return policy_value == ResolveDeviceTimezoneByGeolocationPolicyValues::
|
| + SEND_WIFI_ACCESS_POINTS;
|
| }
|
|
|
| void TimeZoneResolverManager::UpdateTimezoneResolver() {
|
|
|