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

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

Issue 834073002: ChromeOS: Implement periodic timezone refresh on geolocation data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch feature to disabled by default. Created 5 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 (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
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
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
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
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 int features = wake_on_wifi_ssid_.GetValue() ? 612 int features = wake_on_wifi_ssid_.GetValue() ?
603 WakeOnWifiManager::WAKE_ON_SSID : WakeOnWifiManager::WAKE_ON_NONE; 613 WakeOnWifiManager::WAKE_ON_SSID : WakeOnWifiManager::WAKE_ON_NONE;
604 // The flag enables wake on packets but doesn't update a preference. 614 // The flag enables wake on packets but doesn't update a preference.
605 if (base::CommandLine::ForCurrentProcess()-> 615 if (base::CommandLine::ForCurrentProcess()->
606 HasSwitch(switches::kWakeOnPackets)) { 616 HasSwitch(switches::kWakeOnPackets)) {
607 features |= WakeOnWifiManager::WAKE_ON_PACKET; 617 features |= WakeOnWifiManager::WAKE_ON_PACKET;
608 } 618 }
609 WakeOnWifiManager::Get()->OnPreferenceChanged( 619 WakeOnWifiManager::Get()->OnPreferenceChanged(
610 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features)); 620 static_cast<WakeOnWifiManager::WakeOnWifiFeature>(features));
611 } 621 }
622
623 if (pref_name == prefs::kResolveTimezoneByGeolocation &&
624 reason != REASON_ACTIVE_USER_CHANGED) {
625 const bool value = prefs_->GetBoolean(prefs::kResolveTimezoneByGeolocation);
626 if (user_is_owner) {
627 g_browser_process->local_state()->SetBoolean(
628 prefs::kResolveDeviceTimezoneByGeolocation, value);
629 }
630 if (user_is_primary_) {
631 if (value) {
632 g_browser_process->platform_part()->timezone_resolver()->Start();
633 } else {
634 g_browser_process->platform_part()->timezone_resolver()->Stop();
635 if (reason == REASON_PREF_CHANGED) {
636 // Allow immediate timezone update on Stop + Start.
637 g_browser_process->local_state()->ClearPref(
638 TimeZoneResolver::kLastTimeZoneRefreshTime);
639 }
640 }
641 }
642 }
612 } 643 }
613 644
614 void Preferences::OnIsSyncingChanged() { 645 void Preferences::OnIsSyncingChanged() {
615 DVLOG(1) << "OnIsSyncingChanged"; 646 DVLOG(1) << "OnIsSyncingChanged";
616 ForceNaturalScrollDefault(); 647 ForceNaturalScrollDefault();
617 } 648 }
618 649
619 void Preferences::ForceNaturalScrollDefault() { 650 void Preferences::ForceNaturalScrollDefault() {
620 DVLOG(1) << "ForceNaturalScrollDefault"; 651 DVLOG(1) << "ForceNaturalScrollDefault";
621 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 652 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 touch_hud_projection_enabled_.SetValue(enabled); 724 touch_hud_projection_enabled_.SetValue(enabled);
694 } 725 }
695 726
696 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { 727 void Preferences::ActiveUserChanged(const user_manager::User* active_user) {
697 if (active_user != user_) 728 if (active_user != user_)
698 return; 729 return;
699 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); 730 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, "");
700 } 731 }
701 732
702 } // namespace chromeos 733 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698