Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" | 5 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 10 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 | 47 |
| 48 switch (policy_value) { | 48 switch (policy_value) { |
| 49 case enterprise_management::SystemTimezoneProto::USERS_DECIDE: | 49 case enterprise_management::SystemTimezoneProto::USERS_DECIDE: |
| 50 return UNSPECIFIED; | 50 return UNSPECIFIED; |
| 51 case enterprise_management::SystemTimezoneProto::DISABLED: | 51 case enterprise_management::SystemTimezoneProto::DISABLED: |
| 52 return SHOULD_STOP; | 52 return SHOULD_STOP; |
| 53 case enterprise_management::SystemTimezoneProto::IP_ONLY: | 53 case enterprise_management::SystemTimezoneProto::IP_ONLY: |
| 54 return SHOULD_START; | 54 return SHOULD_START; |
| 55 case enterprise_management::SystemTimezoneProto::SEND_WIFI_ACCESS_POINTS: | 55 case enterprise_management::SystemTimezoneProto::SEND_WIFI_ACCESS_POINTS: |
| 56 return SHOULD_START; | 56 return SHOULD_START; |
| 57 case enterprise_management::SystemTimezoneProto::SEND_ALL_NETWORK_INFO: | |
| 58 return SHOULD_START; | |
| 57 } | 59 } |
| 58 // Default for unknown policy value. | 60 // Default for unknown policy value. |
| 59 NOTREACHED() << "Unrecognized policy value: " << policy_value; | 61 NOTREACHED() << "Unrecognized policy value: " << policy_value; |
| 60 return SHOULD_STOP; | 62 return SHOULD_STOP; |
| 61 } | 63 } |
| 62 | 64 |
| 63 // Stops TimezoneResolver if SystemTimezonePolicy is applied. | 65 // Stops TimezoneResolver if SystemTimezonePolicy is applied. |
| 64 // Returns SHOULD_* if timezone resolver status is controlled by this policy. | 66 // Returns SHOULD_* if timezone resolver status is controlled by this policy. |
| 65 ServiceConfiguration GetServiceConfigurationFromSystemTimezonePolicy() { | 67 ServiceConfiguration GetServiceConfigurationFromSystemTimezonePolicy() { |
| 66 if (!HasSystemTimezonePolicy()) | 68 if (!HasSystemTimezonePolicy()) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 base::Unretained(this))); | 123 base::Unretained(this))); |
| 122 } | 124 } |
| 123 | 125 |
| 124 TimeZoneResolverManager::~TimeZoneResolverManager() {} | 126 TimeZoneResolverManager::~TimeZoneResolverManager() {} |
| 125 | 127 |
| 126 void TimeZoneResolverManager::SetPrimaryUserPrefs(PrefService* pref_service) { | 128 void TimeZoneResolverManager::SetPrimaryUserPrefs(PrefService* pref_service) { |
| 127 primary_user_prefs_ = pref_service; | 129 primary_user_prefs_ = pref_service; |
| 128 } | 130 } |
| 129 | 131 |
| 130 bool TimeZoneResolverManager::ShouldSendWiFiGeolocationData() { | 132 bool TimeZoneResolverManager::ShouldSendWiFiGeolocationData() { |
| 133 return CheckTimezoneManagementSetting( | |
| 134 enterprise_management::SystemTimezoneProto::SEND_WIFI_ACCESS_POINTS); | |
|
stevenjb
2017/02/07 23:54:29
Should this be | SEND_ALL_NETWORK_INFO ?
can Skylar cook
2017/02/08 21:15:48
Done.
| |
| 135 } | |
| 136 | |
| 137 bool TimeZoneResolverManager::ShouldSendCellularGeolocationData() { | |
| 138 return CheckTimezoneManagementSetting( | |
| 139 enterprise_management::SystemTimezoneProto::SEND_ALL_NETWORK_INFO); | |
| 140 } | |
| 141 | |
| 142 bool TimeZoneResolverManager::CheckTimezoneManagementSetting(int expected_policy _value){ | |
|
stevenjb
2017/02/07 23:54:29
clang format
can Skylar cook
2017/02/08 21:15:48
Done.
| |
| 131 PrefService* local_state = g_browser_process->local_state(); | 143 PrefService* local_state = g_browser_process->local_state(); |
| 132 const bool is_managed = local_state->IsManagedPreference( | 144 const bool is_managed = local_state->IsManagedPreference( |
| 133 prefs::kSystemTimezoneAutomaticDetectionPolicy); | 145 prefs::kSystemTimezoneAutomaticDetectionPolicy); |
| 134 if (!is_managed) | 146 if (!is_managed) |
| 135 return false; | 147 return false; |
| 136 | 148 |
| 137 int policy_value = | 149 int policy_value = |
| 138 local_state->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); | 150 local_state->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); |
| 139 | 151 |
| 140 DCHECK(policy_value <= enterprise_management::SystemTimezoneProto:: | 152 DCHECK(policy_value <= enterprise_management::SystemTimezoneProto:: |
| 141 AutomaticTimezoneDetectionType_MAX); | 153 AutomaticTimezoneDetectionType_MAX); |
| 142 | 154 |
| 143 return policy_value == | 155 return policy_value == expected_policy_value; |
| 144 enterprise_management::SystemTimezoneProto::SEND_WIFI_ACCESS_POINTS; | |
| 145 } | 156 } |
| 146 | 157 |
| 147 void TimeZoneResolverManager::UpdateTimezoneResolver() { | 158 void TimeZoneResolverManager::UpdateTimezoneResolver() { |
| 148 if (TimeZoneResolverShouldBeRunning()) | 159 if (TimeZoneResolverShouldBeRunning()) |
| 149 g_browser_process->platform_part()->GetTimezoneResolver()->Start(); | 160 g_browser_process->platform_part()->GetTimezoneResolver()->Start(); |
| 150 else | 161 else |
| 151 g_browser_process->platform_part()->GetTimezoneResolver()->Stop(); | 162 g_browser_process->platform_part()->GetTimezoneResolver()->Stop(); |
| 152 } | 163 } |
| 153 | 164 |
| 154 bool TimeZoneResolverManager::ShouldApplyResolvedTimezone() { | 165 bool TimeZoneResolverManager::ShouldApplyResolvedTimezone() { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 168 } else { | 179 } else { |
| 169 // We are on a signin page. | 180 // We are on a signin page. |
| 170 result = GetServiceConfigurationForSigninScreen(); | 181 result = GetServiceConfigurationForSigninScreen(); |
| 171 } | 182 } |
| 172 } | 183 } |
| 173 return result == SHOULD_START; | 184 return result == SHOULD_START; |
| 174 } | 185 } |
| 175 | 186 |
| 176 } // namespace system | 187 } // namespace system |
| 177 } // namespace chromeos | 188 } // namespace chromeos |
| OLD | NEW |