| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chromeos/cros/cros_library.h" | 14 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 15 #include "chrome/browser/chromeos/cros/power_library.h" | 15 #include "chrome/browser/chromeos/cros/power_library.h" |
| 16 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 16 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 17 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 17 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 18 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 18 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| 19 #include "chrome/browser/chromeos/login/login_utils.h" | 19 #include "chrome/browser/chromeos/login/login_utils.h" |
| 20 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | |
| 21 #include "chrome/browser/chromeos/system/touchpad_settings.h" | 20 #include "chrome/browser/chromeos/system/touchpad_settings.h" |
| 22 #include "chrome/browser/prefs/pref_member.h" | 21 #include "chrome/browser/prefs/pref_member.h" |
| 23 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
| 24 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 27 #include "content/browser/browser_thread.h" |
| 28 #include "content/public/browser/notification_details.h" | 28 #include "content/public/browser/notification_details.h" |
| 29 #include "content/public/browser/notification_source.h" | 29 #include "content/public/browser/notification_source.h" |
| 30 #include "googleurl/src/gurl.h" |
| 30 #include "unicode/timezone.h" | 31 #include "unicode/timezone.h" |
| 31 | 32 |
| 32 namespace chromeos { | 33 namespace chromeos { |
| 33 | 34 |
| 34 static const char kFallbackInputMethodLocale[] = "en-US"; | 35 static const char kFallbackInputMethodLocale[] = "en-US"; |
| 35 | 36 |
| 36 Preferences::Preferences() {} | 37 Preferences::Preferences() {} |
| 37 | 38 |
| 38 Preferences::~Preferences() {} | 39 Preferences::~Preferences() {} |
| 39 | 40 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // Mobile plan notifications default to on. | 189 // Mobile plan notifications default to on. |
| 189 prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, | 190 prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, |
| 190 true, | 191 true, |
| 191 PrefService::SYNCABLE_PREF); | 192 PrefService::SYNCABLE_PREF); |
| 192 | 193 |
| 193 // 3G first-time usage promo will be shown at least once. | 194 // 3G first-time usage promo will be shown at least once. |
| 194 prefs->RegisterBooleanPref(prefs::kShow3gPromoNotification, | 195 prefs->RegisterBooleanPref(prefs::kShow3gPromoNotification, |
| 195 true, | 196 true, |
| 196 PrefService::UNSYNCABLE_PREF); | 197 PrefService::UNSYNCABLE_PREF); |
| 197 | 198 |
| 198 // Use shared proxies default to off. | |
| 199 prefs->RegisterBooleanPref(prefs::kUseSharedProxies, | |
| 200 false, | |
| 201 PrefService::SYNCABLE_PREF); | |
| 202 | |
| 203 // OAuth1 all access token and secret pair. | 199 // OAuth1 all access token and secret pair. |
| 204 prefs->RegisterStringPref(prefs::kOAuth1Token, | 200 prefs->RegisterStringPref(prefs::kOAuth1Token, |
| 205 "", | 201 "", |
| 206 PrefService::UNSYNCABLE_PREF); | 202 PrefService::UNSYNCABLE_PREF); |
| 207 prefs->RegisterStringPref(prefs::kOAuth1Secret, | 203 prefs->RegisterStringPref(prefs::kOAuth1Secret, |
| 208 "", | 204 "", |
| 209 PrefService::UNSYNCABLE_PREF); | 205 PrefService::UNSYNCABLE_PREF); |
| 210 } | 206 } |
| 211 | 207 |
| 212 void Preferences::Init(PrefService* prefs) { | 208 void Preferences::Init(PrefService* prefs) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 prefs::kLanguageXkbRemapAltKeyTo, prefs, this); | 264 prefs::kLanguageXkbRemapAltKeyTo, prefs, this); |
| 269 language_xkb_auto_repeat_enabled_.Init( | 265 language_xkb_auto_repeat_enabled_.Init( |
| 270 prefs::kLanguageXkbAutoRepeatEnabled, prefs, this); | 266 prefs::kLanguageXkbAutoRepeatEnabled, prefs, this); |
| 271 language_xkb_auto_repeat_delay_pref_.Init( | 267 language_xkb_auto_repeat_delay_pref_.Init( |
| 272 prefs::kLanguageXkbAutoRepeatDelay, prefs, this); | 268 prefs::kLanguageXkbAutoRepeatDelay, prefs, this); |
| 273 language_xkb_auto_repeat_interval_pref_.Init( | 269 language_xkb_auto_repeat_interval_pref_.Init( |
| 274 prefs::kLanguageXkbAutoRepeatInterval, prefs, this); | 270 prefs::kLanguageXkbAutoRepeatInterval, prefs, this); |
| 275 | 271 |
| 276 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this); | 272 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this); |
| 277 | 273 |
| 278 use_shared_proxies_.Init(prefs::kUseSharedProxies, prefs, this); | |
| 279 | |
| 280 // Initialize preferences to currently saved state. | 274 // Initialize preferences to currently saved state. |
| 281 NotifyPrefChanged(NULL); | 275 NotifyPrefChanged(NULL); |
| 282 | 276 |
| 283 // Initialize virtual keyboard settings to currently saved state. | 277 // Initialize virtual keyboard settings to currently saved state. |
| 284 UpdateVirturalKeyboardPreference(prefs); | 278 UpdateVirturalKeyboardPreference(prefs); |
| 285 | 279 |
| 286 // If a guest is logged in, initialize the prefs as if this is the first | 280 // If a guest is logged in, initialize the prefs as if this is the first |
| 287 // login. | 281 // login. |
| 288 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { | 282 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 289 LoginUtils::Get()->SetFirstLoginPrefs(prefs); | 283 LoginUtils::Get()->SetFirstLoginPrefs(prefs); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 language_prefs::kMozcIntegerPrefs[i].ibus_config_name, | 453 language_prefs::kMozcIntegerPrefs[i].ibus_config_name, |
| 460 language_mozc_integer_prefs_[i].GetValue()); | 454 language_mozc_integer_prefs_[i].GetValue()); |
| 461 } | 455 } |
| 462 } | 456 } |
| 463 | 457 |
| 464 // Init or update power manager config. | 458 // Init or update power manager config. |
| 465 if (!pref_name || *pref_name == prefs::kEnableScreenLock) { | 459 if (!pref_name || *pref_name == prefs::kEnableScreenLock) { |
| 466 CrosLibrary::Get()->GetPowerLibrary()->EnableScreenLock( | 460 CrosLibrary::Get()->GetPowerLibrary()->EnableScreenLock( |
| 467 enable_screen_lock_.GetValue()); | 461 enable_screen_lock_.GetValue()); |
| 468 } | 462 } |
| 469 | |
| 470 if (!pref_name || *pref_name == prefs::kUseSharedProxies) { | |
| 471 g_browser_process->chromeos_proxy_config_service_impl()-> | |
| 472 UISetUseSharedProxies(use_shared_proxies_.GetValue()); | |
| 473 } | |
| 474 } | 463 } |
| 475 | 464 |
| 476 void Preferences::SetLanguageConfigBoolean(const char* section, | 465 void Preferences::SetLanguageConfigBoolean(const char* section, |
| 477 const char* name, | 466 const char* name, |
| 478 bool value) { | 467 bool value) { |
| 479 input_method::ImeConfigValue config; | 468 input_method::ImeConfigValue config; |
| 480 config.type = input_method::ImeConfigValue::kValueTypeBool; | 469 config.type = input_method::ImeConfigValue::kValueTypeBool; |
| 481 config.bool_value = value; | 470 config.bool_value = value; |
| 482 input_method::InputMethodManager::GetInstance()-> | 471 input_method::InputMethodManager::GetInstance()-> |
| 483 SetImeConfig(section, name, config); | 472 SetImeConfig(section, name, config); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 587 |
| 599 // Remove invalid prefs. | 588 // Remove invalid prefs. |
| 600 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); | 589 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); |
| 601 DictionaryValue* pref_value = updater.Get(); | 590 DictionaryValue* pref_value = updater.Get(); |
| 602 for (size_t i = 0; i < layouts_to_remove.size(); ++i) { | 591 for (size_t i = 0; i < layouts_to_remove.size(); ++i) { |
| 603 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); | 592 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); |
| 604 } | 593 } |
| 605 } | 594 } |
| 606 | 595 |
| 607 } // namespace chromeos | 596 } // namespace chromeos |
| OLD | NEW |