OLD | NEW |
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/shell.h" | 10 #include "ash/shell.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/chromeos/input_method/input_method_syncer.h" | 25 #include "chrome/browser/chromeos/input_method/input_method_syncer.h" |
26 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 26 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
27 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" | 27 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" |
28 #include "chrome/browser/chromeos/system/input_device_settings.h" | 28 #include "chrome/browser/chromeos/system/input_device_settings.h" |
29 #include "chrome/browser/download/download_prefs.h" | 29 #include "chrome/browser/download/download_prefs.h" |
30 #include "chrome/browser/prefs/pref_service_syncable.h" | 30 #include "chrome/browser/prefs/pref_service_syncable.h" |
31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
33 #include "chromeos/chromeos_switches.h" | 33 #include "chromeos/chromeos_switches.h" |
34 #include "chromeos/system/statistics_provider.h" | 34 #include "chromeos/system/statistics_provider.h" |
| 35 #include "chromeos/timezone/timezone_resolver.h" |
35 #include "components/feedback/tracing_manager.h" | 36 #include "components/feedback/tracing_manager.h" |
36 #include "components/pref_registry/pref_registry_syncable.h" | 37 #include "components/pref_registry/pref_registry_syncable.h" |
37 #include "components/user_manager/user.h" | 38 #include "components/user_manager/user.h" |
38 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
39 #include "third_party/icu/source/i18n/unicode/timezone.h" | 40 #include "third_party/icu/source/i18n/unicode/timezone.h" |
40 #include "ui/base/ime/chromeos/extension_ime_util.h" | 41 #include "ui/base/ime/chromeos/extension_ime_util.h" |
41 #include "ui/base/ime/chromeos/ime_keyboard.h" | 42 #include "ui/base/ime/chromeos/ime_keyboard.h" |
42 #include "ui/base/ime/chromeos/input_method_manager.h" | 43 #include "ui/base/ime/chromeos/input_method_manager.h" |
43 #include "ui/chromeos/accessibility_types.h" | 44 #include "ui/chromeos/accessibility_types.h" |
44 #include "ui/events/event_constants.h" | 45 #include "ui/events/event_constants.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 ash::Shell::GetInstance()->RemoveShellObserver(this); | 81 ash::Shell::GetInstance()->RemoveShellObserver(this); |
81 } | 82 } |
82 | 83 |
83 // static | 84 // static |
84 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { | 85 void Preferences::RegisterPrefs(PrefRegistrySimple* registry) { |
85 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); | 86 registry->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); |
86 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); | 87 registry->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); |
87 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled, | 88 registry->RegisterBooleanPref(prefs::kAccessibilityVirtualKeyboardEnabled, |
88 false); | 89 false); |
89 registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string()); | 90 registry->RegisterStringPref(prefs::kLogoutStartedLast, std::string()); |
| 91 registry->RegisterBooleanPref(prefs::kResolveDeviceTimezoneByGeolocation, |
| 92 false); |
90 } | 93 } |
91 | 94 |
92 // static | 95 // static |
93 void Preferences::RegisterProfilePrefs( | 96 void Preferences::RegisterProfilePrefs( |
94 user_prefs::PrefRegistrySyncable* registry) { | 97 user_prefs::PrefRegistrySyncable* registry) { |
95 std::string hardware_keyboard_id; | 98 std::string hardware_keyboard_id; |
96 // TODO(yusukes): Remove the runtime hack. | 99 // TODO(yusukes): Remove the runtime hack. |
97 if (base::SysInfo::IsRunningOnChromeOS()) { | 100 if (base::SysInfo::IsRunningOnChromeOS()) { |
98 DCHECK(g_browser_process); | 101 DCHECK(g_browser_process); |
99 PrefService* local_state = g_browser_process->local_state(); | 102 PrefService* local_state = g_browser_process->local_state(); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 registry->RegisterBooleanPref( | 311 registry->RegisterBooleanPref( |
309 prefs::kTouchHudProjectionEnabled, | 312 prefs::kTouchHudProjectionEnabled, |
310 false, | 313 false, |
311 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 314 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
312 | 315 |
313 registry->RegisterBooleanPref( | 316 registry->RegisterBooleanPref( |
314 prefs::kTouchVirtualKeyboardEnabled, | 317 prefs::kTouchVirtualKeyboardEnabled, |
315 false, | 318 false, |
316 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 319 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
317 | 320 |
| 321 registry->RegisterBooleanPref( |
| 322 prefs::kResolveTimezoneByGeolocation, false, |
| 323 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 324 |
318 input_method::InputMethodSyncer::RegisterProfilePrefs(registry); | 325 input_method::InputMethodSyncer::RegisterProfilePrefs(registry); |
319 } | 326 } |
320 | 327 |
321 void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) { | 328 void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) { |
322 prefs_ = prefs; | 329 prefs_ = prefs; |
323 | 330 |
324 BooleanPrefMember::NamedChangeCallback callback = | 331 BooleanPrefMember::NamedChangeCallback callback = |
325 base::Bind(&Preferences::OnPreferenceChanged, base::Unretained(this)); | 332 base::Bind(&Preferences::OnPreferenceChanged, base::Unretained(this)); |
326 | 333 |
327 performance_tracing_enabled_.Init(prefs::kPerformanceTracingEnabled, | 334 performance_tracing_enabled_.Init(prefs::kPerformanceTracingEnabled, |
(...skipping 20 matching lines...) Expand all Loading... |
348 prefs, callback); | 355 prefs, callback); |
349 | 356 |
350 xkb_auto_repeat_enabled_.Init( | 357 xkb_auto_repeat_enabled_.Init( |
351 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); | 358 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); |
352 xkb_auto_repeat_delay_pref_.Init( | 359 xkb_auto_repeat_delay_pref_.Init( |
353 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); | 360 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
354 xkb_auto_repeat_interval_pref_.Init( | 361 xkb_auto_repeat_interval_pref_.Init( |
355 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); | 362 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
356 | 363 |
357 wake_on_wifi_ssid_.Init(prefs::kWakeOnWifiSsid, prefs, callback); | 364 wake_on_wifi_ssid_.Init(prefs::kWakeOnWifiSsid, prefs, callback); |
| 365 |
| 366 pref_change_registrar_.Init(prefs); |
| 367 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); |
358 } | 368 } |
359 | 369 |
360 void Preferences::Init(Profile* profile, const user_manager::User* user) { | 370 void Preferences::Init(Profile* profile, const user_manager::User* user) { |
361 DCHECK(profile); | 371 DCHECK(profile); |
362 DCHECK(user); | 372 DCHECK(user); |
363 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile); | 373 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile); |
364 // This causes OnIsSyncingChanged to be called when the value of | 374 // This causes OnIsSyncingChanged to be called when the value of |
365 // PrefService::IsSyncing() changes. | 375 // PrefService::IsSyncing() changes. |
366 prefs->AddObserver(this); | 376 prefs->AddObserver(this); |
367 user_ = user; | 377 user_ = user; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 int features = wake_on_wifi_ssid_.GetValue() ? | 610 int features = wake_on_wifi_ssid_.GetValue() ? |
601 WakeOnWifiManager::WAKE_ON_SSID : WakeOnWifiManager::WAKE_ON_NONE; | 611 WakeOnWifiManager::WAKE_ON_SSID : WakeOnWifiManager::WAKE_ON_NONE; |
602 // The flag enables wake on packets but doesn't update a preference. | 612 // The flag enables wake on packets but doesn't update a preference. |
603 if (base::CommandLine::ForCurrentProcess()-> | 613 if (base::CommandLine::ForCurrentProcess()-> |
604 HasSwitch(switches::kWakeOnPackets)) { | 614 HasSwitch(switches::kWakeOnPackets)) { |
605 features |= WakeOnWifiManager::WAKE_ON_PACKET; | 615 features |= WakeOnWifiManager::WAKE_ON_PACKET; |
606 } | 616 } |
607 WakeOnWifiManager::Get()->OnPreferenceChanged( | 617 WakeOnWifiManager::Get()->OnPreferenceChanged( |
608 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features)); | 618 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features)); |
609 } | 619 } |
| 620 |
| 621 if (pref_name == prefs::kResolveTimezoneByGeolocation && |
| 622 reason != REASON_ACTIVE_USER_CHANGED) { |
| 623 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation); |
| 624 if (user_is_owner) { |
| 625 g_browser_process->local_state()->SetBoolean( |
| 626 prefs::kResolveDeviceTimezoneByGeolocation, value); |
| 627 } |
| 628 if (user_is_primary_) { |
| 629 if (value) { |
| 630 g_browser_process->platform_part()->GetTimezoneResolver()->Start(); |
| 631 } else { |
| 632 g_browser_process->platform_part()->GetTimezoneResolver()->Stop(); |
| 633 if (reason == REASON_PREF_CHANGED) { |
| 634 // Allow immediate timezone update on Stop + Start. |
| 635 g_browser_process->local_state()->ClearPref( |
| 636 TimeZoneResolver::kLastTimeZoneRefreshTime); |
| 637 } |
| 638 } |
| 639 } |
| 640 } |
610 } | 641 } |
611 | 642 |
612 void Preferences::OnIsSyncingChanged() { | 643 void Preferences::OnIsSyncingChanged() { |
613 DVLOG(1) << "OnIsSyncingChanged"; | 644 DVLOG(1) << "OnIsSyncingChanged"; |
614 ForceNaturalScrollDefault(); | 645 ForceNaturalScrollDefault(); |
615 } | 646 } |
616 | 647 |
617 void Preferences::ForceNaturalScrollDefault() { | 648 void Preferences::ForceNaturalScrollDefault() { |
618 DVLOG(1) << "ForceNaturalScrollDefault"; | 649 DVLOG(1) << "ForceNaturalScrollDefault"; |
619 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 650 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 touch_hud_projection_enabled_.SetValue(enabled); | 722 touch_hud_projection_enabled_.SetValue(enabled); |
692 } | 723 } |
693 | 724 |
694 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { | 725 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
695 if (active_user != user_) | 726 if (active_user != user_) |
696 return; | 727 return; |
697 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 728 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
698 } | 729 } |
699 | 730 |
700 } // namespace chromeos | 731 } // namespace chromeos |
OLD | NEW |