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

Side by Side Diff: chrome/browser/chromeos/preferences.cc

Issue 1843523002: ChromeOS: Add SystemTimezoneAutomaticDetection policy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@596690--Implement-better-timezone-detection--refactoring-before-policy
Patch Set: Moved policy to SystemTimezone. Created 4 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/preferences.h" 5 #include "chrome/browser/chromeos/preferences.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/autoclick/autoclick_controller.h" 9 #include "ash/autoclick/autoclick_controller.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/i18n/time_formatting.h" 13 #include "base/i18n/time_formatting.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/sys_info.h" 18 #include "base/sys_info.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 21 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
22 #include "chrome/browser/chromeos/drive/file_system_util.h" 22 #include "chrome/browser/chromeos/drive/file_system_util.h"
23 #include "chrome/browser/chromeos/input_method/input_method_syncer.h" 23 #include "chrome/browser/chromeos/input_method/input_method_syncer.h"
24 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 24 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
25 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" 25 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h"
26 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
26 #include "chrome/browser/chromeos/system/input_device_settings.h" 27 #include "chrome/browser/chromeos/system/input_device_settings.h"
27 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" 28 #include "chrome/browser/chromeos/system/timezone_resolver_manager.h"
28 #include "chrome/browser/download/download_prefs.h" 29 #include "chrome/browser/download/download_prefs.h"
29 #include "chrome/browser/prefs/pref_service_syncable_util.h" 30 #include "chrome/browser/prefs/pref_service_syncable_util.h"
30 #include "chrome/common/chrome_features.h" 31 #include "chrome/common/chrome_features.h"
31 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
32 #include "chromeos/chromeos_switches.h" 33 #include "chromeos/chromeos_switches.h"
33 #include "chromeos/system/statistics_provider.h" 34 #include "chromeos/system/statistics_provider.h"
34 #include "chromeos/timezone/timezone_resolver.h" 35 #include "chromeos/timezone/timezone_resolver.h"
35 #include "components/drive/drive_pref_names.h" 36 #include "components/drive/drive_pref_names.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 90
90 // static 91 // static
91 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { 92 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) {
92 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); 93 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false);
93 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); 94 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true);
94 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled, 95 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled,
95 false); 96 false);
96 registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string()); 97 registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string());
97 registry->RegisterBooleanPref(prefs::kResolveDeviceTimezoneByGeolocation, 98 registry->RegisterBooleanPref(prefs::kResolveDeviceTimezoneByGeolocation,
98 true); 99 true);
100 registry->RegisterIntegerPref(
101 prefs::kSystemTimezoneAutomaticDetectionPolicy,
102 enterprise_management::SystemTimezoneProto::USERS_DECIDE);
99 } 103 }
100 104
101 // static 105 // static
102 void Preferences::RegisterProfilePrefs( 106 void Preferences::RegisterProfilePrefs(
103 user_prefs::PrefRegistrySyncable* registry) { 107 user_prefs::PrefRegistrySyncable* registry) {
104 std::string hardware_keyboard_id; 108 std::string hardware_keyboard_id;
105 // TODO(yusukes): Remove the runtime hack. 109 // TODO(yusukes): Remove the runtime hack.
106 if (base::SysInfo::IsRunningOnChromeOS()) { 110 if (base::SysInfo::IsRunningOnChromeOS()) {
107 DCHECK(g_browser_process); 111 DCHECK(g_browser_process);
108 PrefService* local_state = g_browser_process->local_state(); 112 PrefService* local_state = g_browser_process->local_state();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 user_is_primary_ = 371 user_is_primary_ =
368 user_manager::UserManager::Get()->GetPrimaryUser() == user_; 372 user_manager::UserManager::Get()->GetPrimaryUser() == user_;
369 InitUserPrefs(prefs); 373 InitUserPrefs(prefs);
370 374
371 user_manager::UserManager::Get()->AddSessionStateObserver(this); 375 user_manager::UserManager::Get()->AddSessionStateObserver(this);
372 376
373 UserSessionManager* session_manager = UserSessionManager::GetInstance(); 377 UserSessionManager* session_manager = UserSessionManager::GetInstance();
374 DCHECK(session_manager); 378 DCHECK(session_manager);
375 ime_state_ = session_manager->GetDefaultIMEState(profile); 379 ime_state_ = session_manager->GetDefaultIMEState(profile);
376 380
381 if (user_is_primary_) {
382 g_browser_process->platform_part()
383 ->GetTimezoneResolverManager()
384 ->SetPrimaryUserPrefs(prefs_);
385 }
386
377 // Initialize preferences to currently saved state. 387 // Initialize preferences to currently saved state.
378 ApplyPreferences(REASON_INITIALIZATION, ""); 388 ApplyPreferences(REASON_INITIALIZATION, "");
379 389
380 // Note that |ime_state_| was modified by ApplyPreferences(), and 390 // Note that |ime_state_| was modified by ApplyPreferences(), and
381 // SetState() is modifying |current_input_method_| (via 391 // SetState() is modifying |current_input_method_| (via
382 // PersistUserInputMethod() ). This way SetState() here may be called only 392 // PersistUserInputMethod() ). This way SetState() here may be called only
383 // after ApplyPreferences(). 393 // after ApplyPreferences().
384 input_method_manager_->SetState(ime_state_); 394 input_method_manager_->SetState(ime_state_);
385 395
386 input_method_syncer_.reset( 396 input_method_syncer_.reset(
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 } 644 }
635 645
636 if (pref_name == prefs::kResolveTimezoneByGeolocation && 646 if (pref_name == prefs::kResolveTimezoneByGeolocation &&
637 reason != REASON_ACTIVE_USER_CHANGED) { 647 reason != REASON_ACTIVE_USER_CHANGED) {
638 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation); 648 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation);
639 if (user_is_owner) { 649 if (user_is_owner) {
640 g_browser_process->local_state()->SetBoolean( 650 g_browser_process->local_state()->SetBoolean(
641 prefs::kResolveDeviceTimezoneByGeolocation, value); 651 prefs::kResolveDeviceTimezoneByGeolocation, value);
642 } 652 }
643 if (user_is_primary_) { 653 if (user_is_primary_) {
644 system::TimeZoneResolverManager* manager = 654 g_browser_process->platform_part()
645 g_browser_process->platform_part()->GetTimezoneResolverManager(); 655 ->GetTimezoneResolverManager()
646 manager->SetPrimaryUserPrefs(prefs_); 656 ->UpdateTimezoneResolver();
647 manager->UpdateTimezoneResolver();
648 if (!value && reason == REASON_PREF_CHANGED) { 657 if (!value && reason == REASON_PREF_CHANGED) {
649 // Allow immediate timezone update on Stop + Start. 658 // Allow immediate timezone update on Stop + Start.
650 g_browser_process->local_state()->ClearPref( 659 g_browser_process->local_state()->ClearPref(
651 TimeZoneResolver::kLastTimeZoneRefreshTime); 660 TimeZoneResolver::kLastTimeZoneRefreshTime);
652 } 661 }
653 } 662 }
654 } 663 }
655 664
656 if (pref_name == prefs::kUse24HourClock || 665 if (pref_name == prefs::kUse24HourClock ||
657 reason != REASON_ACTIVE_USER_CHANGED) { 666 reason != REASON_ACTIVE_USER_CHANGED) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 touch_hud_projection_enabled_.SetValue(enabled); 754 touch_hud_projection_enabled_.SetValue(enabled);
746 } 755 }
747 756
748 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { 757 void Preferences::ActiveUserChanged(const user_manager::User* active_user) {
749 if (active_user != user_) 758 if (active_user != user_)
750 return; 759 return;
751 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); 760 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, "");
752 } 761 }
753 762
754 } // namespace chromeos 763 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698