| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_util.h" | 5 #include "chrome/browser/chromeos/system/timezone_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 21 #include "chrome/browser/chromeos/settings/cros_settings.h" | 21 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" |
| 23 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 24 #include "chromeos/settings/timezone_settings.h" | 24 #include "chromeos/settings/timezone_settings.h" |
| 25 #include "chromeos/timezone/timezone_request.h" | 25 #include "chromeos/timezone/timezone_request.h" |
| 26 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
| 27 #include "components/user_manager/user_manager.h" | 27 #include "components/user_manager/user_manager.h" |
| 28 #include "third_party/icu/source/common/unicode/ures.h" | 28 #include "third_party/icu/source/common/unicode/ures.h" |
| 29 #include "third_party/icu/source/common/unicode/utypes.h" | 29 #include "third_party/icu/source/common/unicode/utypes.h" |
| 30 #include "third_party/icu/source/i18n/unicode/calendar.h" | 30 #include "third_party/icu/source/i18n/unicode/calendar.h" |
| 31 #include "third_party/icu/source/i18n/unicode/timezone.h" | 31 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 &policy_timezone) && | 172 &policy_timezone) && |
| 173 !policy_timezone.empty()) { | 173 !policy_timezone.empty()) { |
| 174 VLOG(1) << "Refresh TimeZone: TimeZone settings are overridden" | 174 VLOG(1) << "Refresh TimeZone: TimeZone settings are overridden" |
| 175 << " by DevicePolicy."; | 175 << " by DevicePolicy."; |
| 176 return true; | 176 return true; |
| 177 } | 177 } |
| 178 return false; | 178 return false; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void ApplyTimeZone(const TimeZoneResponseData* timezone) { | 181 void ApplyTimeZone(const TimeZoneResponseData* timezone) { |
| 182 if (HasSystemTimezonePolicy()) | 182 if (!g_browser_process->platform_part() |
| 183 ->GetTimezoneResolverManager() |
| 184 ->ShouldApplyResolvedTimezone()) { |
| 183 return; | 185 return; |
| 184 | |
| 185 const user_manager::User* primary_user = | |
| 186 user_manager::UserManager::Get()->GetPrimaryUser(); | |
| 187 if (primary_user) { | |
| 188 if (!primary_user->is_profile_created()) | |
| 189 return; | |
| 190 | |
| 191 Profile* profile = | |
| 192 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); | |
| 193 if (!profile->GetPrefs()->GetBoolean( | |
| 194 prefs::kResolveTimezoneByGeolocation)) { | |
| 195 return; | |
| 196 } | |
| 197 } | 186 } |
| 198 | 187 |
| 199 if (!timezone->timeZoneId.empty()) { | 188 if (!timezone->timeZoneId.empty()) { |
| 200 VLOG(1) << "Refresh TimeZone: setting timezone to '" << timezone->timeZoneId | 189 VLOG(1) << "Refresh TimeZone: setting timezone to '" << timezone->timeZoneId |
| 201 << "'"; | 190 << "'"; |
| 202 | 191 |
| 203 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 192 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
| 204 base::UTF8ToUTF16(timezone->timeZoneId)); | 193 base::UTF8ToUTF16(timezone->timeZoneId)); |
| 205 } | 194 } |
| 206 } | 195 } |
| 207 | 196 |
| 208 } // namespace system | 197 } // namespace system |
| 209 } // namespace chromeos | 198 } // namespace chromeos |
| OLD | NEW |