| 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 registry->RegisterIntegerPref( |
| 281 prefs::kWakeOnWiFiEnabled, |
| 282 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 283 switches::kWakeOnPackets) |
| 284 ? WakeOnWifiManager::WAKE_ON_PACKET_AND_SSID |
| 285 : WakeOnWifiManager::WAKE_ON_NONE, |
| 286 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 287 |
| 277 // Mobile plan notifications default to on. | 288 // Mobile plan notifications default to on. |
| 278 registry->RegisterBooleanPref( | 289 registry->RegisterBooleanPref( |
| 279 prefs::kShowPlanNotifications, | 290 prefs::kShowPlanNotifications, |
| 280 true, | 291 true, |
| 281 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 292 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 282 | 293 |
| 283 // 3G first-time usage promo will be shown at least once. | 294 // 3G first-time usage promo will be shown at least once. |
| 284 registry->RegisterBooleanPref( | 295 registry->RegisterBooleanPref( |
| 285 prefs::kShow3gPromoNotification, | 296 prefs::kShow3gPromoNotification, |
| 286 true, | 297 true, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 prefs, callback); | 352 prefs, callback); |
| 342 previous_input_method_.Init(prefs::kLanguagePreviousInputMethod, | 353 previous_input_method_.Init(prefs::kLanguagePreviousInputMethod, |
| 343 prefs, callback); | 354 prefs, callback); |
| 344 | 355 |
| 345 xkb_auto_repeat_enabled_.Init( | 356 xkb_auto_repeat_enabled_.Init( |
| 346 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); | 357 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); |
| 347 xkb_auto_repeat_delay_pref_.Init( | 358 xkb_auto_repeat_delay_pref_.Init( |
| 348 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); | 359 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
| 349 xkb_auto_repeat_interval_pref_.Init( | 360 xkb_auto_repeat_interval_pref_.Init( |
| 350 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); | 361 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
| 362 |
| 363 wake_on_wifi_enabled_.Init(prefs::kWakeOnWiFiEnabled, prefs, callback); |
| 351 } | 364 } |
| 352 | 365 |
| 353 void Preferences::Init(Profile* profile, const user_manager::User* user) { | 366 void Preferences::Init(Profile* profile, const user_manager::User* user) { |
| 354 DCHECK(profile); | 367 DCHECK(profile); |
| 355 DCHECK(user); | 368 DCHECK(user); |
| 356 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile); | 369 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile); |
| 357 user_ = user; | 370 user_ = user; |
| 358 user_is_primary_ = | 371 user_is_primary_ = |
| 359 user_manager::UserManager::Get()->GetPrimaryUser() == user_; | 372 user_manager::UserManager::Get()->GetPrimaryUser() == user_; |
| 360 InitUserPrefs(prefs); | 373 InitUserPrefs(prefs); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 ->SetAutoRepeatEnabled(enabled); | 559 ->SetAutoRepeatEnabled(enabled); |
| 547 } | 560 } |
| 548 } | 561 } |
| 549 if (reason != REASON_PREF_CHANGED || | 562 if (reason != REASON_PREF_CHANGED || |
| 550 pref_name == prefs::kLanguageXkbAutoRepeatDelay || | 563 pref_name == prefs::kLanguageXkbAutoRepeatDelay || |
| 551 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { | 564 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { |
| 552 if (user_is_active) | 565 if (user_is_active) |
| 553 UpdateAutoRepeatRate(); | 566 UpdateAutoRepeatRate(); |
| 554 } | 567 } |
| 555 | 568 |
| 569 if (user_is_primary_ && (reason != REASON_PREF_CHANGED || |
| 570 pref_name == prefs::kWakeOnWiFiEnabled)) { |
| 571 WakeOnWifiManager::Get()->OnPreferenceChanged( |
| 572 static_cast<WakeOnWifiManager::WakeOnWifiFeature>( |
| 573 wake_on_wifi_enabled_.GetValue())); |
| 574 } |
| 575 |
| 556 if (reason == REASON_INITIALIZATION) | 576 if (reason == REASON_INITIALIZATION) |
| 557 SetInputMethodList(); | 577 SetInputMethodList(); |
| 558 | 578 |
| 559 if (pref_name == prefs::kLanguagePreloadEngines && | 579 if (pref_name == prefs::kLanguagePreloadEngines && |
| 560 reason == REASON_PREF_CHANGED) { | 580 reason == REASON_PREF_CHANGED) { |
| 561 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, | 581 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 562 language_prefs::kPreloadEnginesConfigName, | 582 language_prefs::kPreloadEnginesConfigName, |
| 563 preload_engines_.GetValue()); | 583 preload_engines_.GetValue()); |
| 564 } | 584 } |
| 565 | 585 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 touch_hud_projection_enabled_.SetValue(enabled); | 685 touch_hud_projection_enabled_.SetValue(enabled); |
| 666 } | 686 } |
| 667 | 687 |
| 668 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { | 688 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
| 669 if (active_user != user_) | 689 if (active_user != user_) |
| 670 return; | 690 return; |
| 671 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 691 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
| 672 } | 692 } |
| 673 | 693 |
| 674 } // namespace chromeos | 694 } // namespace chromeos |
| OLD | NEW |