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

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

Issue 2624843003: Add support for cellular geolocation (Closed)
Patch Set: Fix policy enum, cleanup browser policy checks 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 return (
134 (GetTimezoneManagementSetting() ==
135 enterprise_management::SystemTimezoneProto::SEND_WIFI_ACCESS_POINTS) ||
136 (GetTimezoneManagementSetting() ==
137 enterprise_management::SystemTimezoneProto::SEND_ALL_LOCATION_INFO));
stevenjb 2017/02/09 20:12:52 This still calls GetTimezoneManagementSetting() tw
can Skylar cook 2017/02/09 21:10:45 D'oh
138 }
139
140 bool TimeZoneResolverManager::ShouldSendCellularGeolocationData() {
141 return (GetTimezoneManagementSetting() ==
142 enterprise_management::SystemTimezoneProto::SEND_ALL_LOCATION_INFO);
143 }
144
145 int TimeZoneResolverManager::GetTimezoneManagementSetting() {
131 PrefService* local_state = g_browser_process->local_state(); 146 PrefService* local_state = g_browser_process->local_state();
132 const bool is_managed = local_state->IsManagedPreference( 147 const bool is_managed = local_state->IsManagedPreference(
133 prefs::kSystemTimezoneAutomaticDetectionPolicy); 148 prefs::kSystemTimezoneAutomaticDetectionPolicy);
134 if (!is_managed) 149 if (!is_managed)
135 return false; 150 return false;
136 151
137 int policy_value = 152 int policy_value =
138 local_state->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); 153 local_state->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy);
139 154
140 DCHECK(policy_value <= enterprise_management::SystemTimezoneProto:: 155 DCHECK(policy_value <= enterprise_management::SystemTimezoneProto::
141 AutomaticTimezoneDetectionType_MAX); 156 AutomaticTimezoneDetectionType_MAX);
142 157
143 return policy_value == 158 return policy_value;
144 enterprise_management::SystemTimezoneProto::SEND_WIFI_ACCESS_POINTS;
145 } 159 }
146 160
147 void TimeZoneResolverManager::UpdateTimezoneResolver() { 161 void TimeZoneResolverManager::UpdateTimezoneResolver() {
148 if (TimeZoneResolverShouldBeRunning()) 162 if (TimeZoneResolverShouldBeRunning())
149 g_browser_process->platform_part()->GetTimezoneResolver()->Start(); 163 g_browser_process->platform_part()->GetTimezoneResolver()->Start();
150 else 164 else
151 g_browser_process->platform_part()->GetTimezoneResolver()->Stop(); 165 g_browser_process->platform_part()->GetTimezoneResolver()->Stop();
152 } 166 }
153 167
154 bool TimeZoneResolverManager::ShouldApplyResolvedTimezone() { 168 bool TimeZoneResolverManager::ShouldApplyResolvedTimezone() {
(...skipping 13 matching lines...) Expand all
168 } else { 182 } else {
169 // We are on a signin page. 183 // We are on a signin page.
170 result = GetServiceConfigurationForSigninScreen(); 184 result = GetServiceConfigurationForSigninScreen();
171 } 185 }
172 } 186 }
173 return result == SHOULD_START; 187 return result == SHOULD_START;
174 } 188 }
175 189
176 } // namespace system 190 } // namespace system
177 } // namespace chromeos 191 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698