Chromium Code Reviews| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/i18n/time_formatting.h" | 12 #include "base/i18n/time_formatting.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/prefs/pref_member.h" | 14 #include "base/prefs/pref_member.h" |
| 15 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
| 16 #include "base/prefs/scoped_user_pref_update.h" | 16 #include "base/prefs/scoped_user_pref_update.h" |
| 17 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 23 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 23 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 24 #include "chrome/browser/chromeos/drive/file_system_util.h" | 24 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 25 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 25 #include "chrome/browser/chromeos/input_method/input_method_util.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/profiles/profile_helper.h" | 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 28 #include "chrome/browser/chromeos/system/input_device_settings.h" | 29 #include "chrome/browser/chromeos/system/input_device_settings.h" |
| 29 #include "chrome/browser/download/download_prefs.h" | 30 #include "chrome/browser/download/download_prefs.h" |
| 30 #include "chrome/browser/prefs/pref_service_syncable.h" | 31 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 31 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 33 #include "chromeos/chromeos_switches.h" | 34 #include "chromeos/chromeos_switches.h" |
| 34 #include "chromeos/ime/extension_ime_util.h" | 35 #include "chromeos/ime/extension_ime_util.h" |
| 35 #include "chromeos/ime/ime_keyboard.h" | 36 #include "chromeos/ime/ime_keyboard.h" |
| 36 #include "chromeos/ime/input_method_manager.h" | 37 #include "chromeos/ime/input_method_manager.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 268 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 268 registry->RegisterIntegerPref( | 269 registry->RegisterIntegerPref( |
| 269 prefs::kLanguageXkbAutoRepeatDelay, | 270 prefs::kLanguageXkbAutoRepeatDelay, |
| 270 language_prefs::kXkbAutoRepeatDelayInMs, | 271 language_prefs::kXkbAutoRepeatDelayInMs, |
| 271 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 272 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 272 registry->RegisterIntegerPref( | 273 registry->RegisterIntegerPref( |
| 273 prefs::kLanguageXkbAutoRepeatInterval, | 274 prefs::kLanguageXkbAutoRepeatInterval, |
| 274 language_prefs::kXkbAutoRepeatIntervalInMs, | 275 language_prefs::kXkbAutoRepeatIntervalInMs, |
| 275 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 276 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 276 | 277 |
| 278 // We don't sync wake-on-wifi related prefs because they are device specific. | |
| 279 // TODO(chirantan): Default this to on when we are ready to launch. | |
| 280 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 281 switches::kWakeOnPackets)) { | |
| 282 registry->RegisterIntegerPref( | |
| 283 prefs::kWakeOnWiFiEnabled, | |
| 284 WakeOnWifiManager::WAKE_ON_PACKET_AND_SSID, | |
| 285 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 286 } else { | |
| 287 registry->RegisterIntegerPref( | |
|
Lei Zhang
2014/11/18 01:57:55
nit: you can use the if-block to figure out the va
Chirantan Ekbote
2014/11/18 20:37:39
Done.
| |
| 288 prefs::kWakeOnWiFiEnabled, | |
| 289 WakeOnWifiManager::WAKE_ON_NONE, | |
| 290 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 291 } | |
| 292 | |
| 277 // Mobile plan notifications default to on. | 293 // Mobile plan notifications default to on. |
| 278 registry->RegisterBooleanPref( | 294 registry->RegisterBooleanPref( |
| 279 prefs::kShowPlanNotifications, | 295 prefs::kShowPlanNotifications, |
| 280 true, | 296 true, |
| 281 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 297 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 282 | 298 |
| 283 // 3G first-time usage promo will be shown at least once. | 299 // 3G first-time usage promo will be shown at least once. |
| 284 registry->RegisterBooleanPref( | 300 registry->RegisterBooleanPref( |
| 285 prefs::kShow3gPromoNotification, | 301 prefs::kShow3gPromoNotification, |
| 286 true, | 302 true, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 prefs, callback); | 357 prefs, callback); |
| 342 previous_input_method_.Init(prefs::kLanguagePreviousInputMethod, | 358 previous_input_method_.Init(prefs::kLanguagePreviousInputMethod, |
| 343 prefs, callback); | 359 prefs, callback); |
| 344 | 360 |
| 345 xkb_auto_repeat_enabled_.Init( | 361 xkb_auto_repeat_enabled_.Init( |
| 346 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); | 362 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); |
| 347 xkb_auto_repeat_delay_pref_.Init( | 363 xkb_auto_repeat_delay_pref_.Init( |
| 348 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); | 364 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
| 349 xkb_auto_repeat_interval_pref_.Init( | 365 xkb_auto_repeat_interval_pref_.Init( |
| 350 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); | 366 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
| 367 | |
| 368 wake_on_wifi_enabled_.Init(prefs::kWakeOnWiFiEnabled, prefs, callback); | |
| 351 } | 369 } |
| 352 | 370 |
| 353 void Preferences::Init(Profile* profile, const user_manager::User* user) { | 371 void Preferences::Init(Profile* profile, const user_manager::User* user) { |
| 354 DCHECK(profile); | 372 DCHECK(profile); |
| 355 DCHECK(user); | 373 DCHECK(user); |
| 356 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile); | 374 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile); |
| 357 user_ = user; | 375 user_ = user; |
| 358 user_is_primary_ = | 376 user_is_primary_ = |
| 359 user_manager::UserManager::Get()->GetPrimaryUser() == user_; | 377 user_manager::UserManager::Get()->GetPrimaryUser() == user_; |
| 360 InitUserPrefs(prefs); | 378 InitUserPrefs(prefs); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 ->SetAutoRepeatEnabled(enabled); | 564 ->SetAutoRepeatEnabled(enabled); |
| 547 } | 565 } |
| 548 } | 566 } |
| 549 if (reason != REASON_PREF_CHANGED || | 567 if (reason != REASON_PREF_CHANGED || |
| 550 pref_name == prefs::kLanguageXkbAutoRepeatDelay || | 568 pref_name == prefs::kLanguageXkbAutoRepeatDelay || |
| 551 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { | 569 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { |
| 552 if (user_is_active) | 570 if (user_is_active) |
| 553 UpdateAutoRepeatRate(); | 571 UpdateAutoRepeatRate(); |
| 554 } | 572 } |
| 555 | 573 |
| 574 if (user_is_primary_ && (reason != REASON_PREF_CHANGED || | |
| 575 pref_name == prefs::kWakeOnWiFiEnabled)) { | |
| 576 WakeOnWifiManager::Get()->OnPreferenceChanged( | |
| 577 static_cast<WakeOnWifiManager::WakeOnWifiFeature>( | |
| 578 wake_on_wifi_enabled_.GetValue())); | |
| 579 } | |
| 580 | |
| 556 if (reason == REASON_INITIALIZATION) | 581 if (reason == REASON_INITIALIZATION) |
| 557 SetInputMethodList(); | 582 SetInputMethodList(); |
| 558 | 583 |
| 559 if (pref_name == prefs::kLanguagePreloadEngines && | 584 if (pref_name == prefs::kLanguagePreloadEngines && |
| 560 reason == REASON_PREF_CHANGED) { | 585 reason == REASON_PREF_CHANGED) { |
| 561 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, | 586 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 562 language_prefs::kPreloadEnginesConfigName, | 587 language_prefs::kPreloadEnginesConfigName, |
| 563 preload_engines_.GetValue()); | 588 preload_engines_.GetValue()); |
| 564 } | 589 } |
| 565 | 590 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 665 touch_hud_projection_enabled_.SetValue(enabled); | 690 touch_hud_projection_enabled_.SetValue(enabled); |
| 666 } | 691 } |
| 667 | 692 |
| 668 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { | 693 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
| 669 if (active_user != user_) | 694 if (active_user != user_) |
| 670 return; | 695 return; |
| 671 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 696 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
| 672 } | 697 } |
| 673 | 698 |
| 674 } // namespace chromeos | 699 } // namespace chromeos |
| OLD | NEW |