Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: chrome/browser/chromeos/system/timezone_resolver_manager.cc

Issue 2624843003: Add support for cellular geolocation (Closed)
Patch Set: Update device tests to use correct dict key Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_LOCATION_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
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 int timezone_setting = GetTimezoneManagementSetting();
134 return (
135 (timezone_setting ==
136 enterprise_management::SystemTimezoneProto::SEND_WIFI_ACCESS_POINTS) ||
137 (timezone_setting ==
138 enterprise_management::SystemTimezoneProto::SEND_ALL_LOCATION_INFO));
139 }
140
141 bool TimeZoneResolverManager::ShouldSendCellularGeolocationData() {
142 return (GetTimezoneManagementSetting() ==
143 enterprise_management::SystemTimezoneProto::SEND_ALL_LOCATION_INFO);
144 }
145
146 int TimeZoneResolverManager::GetTimezoneManagementSetting() {
131 PrefService* local_state = g_browser_process->local_state(); 147 PrefService* local_state = g_browser_process->local_state();
132 const bool is_managed = local_state->IsManagedPreference( 148 const bool is_managed = local_state->IsManagedPreference(
133 prefs::kSystemTimezoneAutomaticDetectionPolicy); 149 prefs::kSystemTimezoneAutomaticDetectionPolicy);
134 if (!is_managed) 150 if (!is_managed)
135 return false; 151 return false;
136 152
137 int policy_value = 153 int policy_value =
138 local_state->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); 154 local_state->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy);
139 155
140 DCHECK(policy_value <= enterprise_management::SystemTimezoneProto:: 156 DCHECK(policy_value <= enterprise_management::SystemTimezoneProto::
141 AutomaticTimezoneDetectionType_MAX); 157 AutomaticTimezoneDetectionType_MAX);
142 158
143 return policy_value == 159 return policy_value;
144 enterprise_management::SystemTimezoneProto::SEND_WIFI_ACCESS_POINTS;
145 } 160 }
146 161
147 void TimeZoneResolverManager::UpdateTimezoneResolver() { 162 void TimeZoneResolverManager::UpdateTimezoneResolver() {
148 if (TimeZoneResolverShouldBeRunning()) 163 if (TimeZoneResolverShouldBeRunning())
149 g_browser_process->platform_part()->GetTimezoneResolver()->Start(); 164 g_browser_process->platform_part()->GetTimezoneResolver()->Start();
150 else 165 else
151 g_browser_process->platform_part()->GetTimezoneResolver()->Stop(); 166 g_browser_process->platform_part()->GetTimezoneResolver()->Stop();
152 } 167 }
153 168
154 bool TimeZoneResolverManager::ShouldApplyResolvedTimezone() { 169 bool TimeZoneResolverManager::ShouldApplyResolvedTimezone() {
(...skipping 13 matching lines...) Expand all
168 } else { 183 } else {
169 // We are on a signin page. 184 // We are on a signin page.
170 result = GetServiceConfigurationForSigninScreen(); 185 result = GetServiceConfigurationForSigninScreen();
171 } 186 }
172 } 187 }
173 return result == SHOULD_START; 188 return result == SHOULD_START;
174 } 189 }
175 190
176 } // namespace system 191 } // namespace system
177 } // namespace chromeos 192 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/timezone_resolver_manager.h ('k') | chrome/browser/policy/policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698