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 "base/chromeos/chromeos_version.h" | 7 #include "base/chromeos/chromeos_version.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 prefs->RegisterBooleanPref(prefs::kLanguageXkbAutoRepeatEnabled, | 227 prefs->RegisterBooleanPref(prefs::kLanguageXkbAutoRepeatEnabled, |
228 true, | 228 true, |
229 PrefService::UNSYNCABLE_PREF); | 229 PrefService::UNSYNCABLE_PREF); |
230 prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatDelay, | 230 prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatDelay, |
231 language_prefs::kXkbAutoRepeatDelayInMs, | 231 language_prefs::kXkbAutoRepeatDelayInMs, |
232 PrefService::UNSYNCABLE_PREF); | 232 PrefService::UNSYNCABLE_PREF); |
233 prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatInterval, | 233 prefs->RegisterIntegerPref(prefs::kLanguageXkbAutoRepeatInterval, |
234 language_prefs::kXkbAutoRepeatIntervalInMs, | 234 language_prefs::kXkbAutoRepeatIntervalInMs, |
235 PrefService::UNSYNCABLE_PREF); | 235 PrefService::UNSYNCABLE_PREF); |
236 | 236 |
237 prefs->RegisterDictionaryPref(prefs::kLanguagePreferredVirtualKeyboard, | |
238 PrefService::SYNCABLE_PREF); | |
239 | |
240 // Screen lock default to off. | 237 // Screen lock default to off. |
241 prefs->RegisterBooleanPref(prefs::kEnableScreenLock, | 238 prefs->RegisterBooleanPref(prefs::kEnableScreenLock, |
242 false, | 239 false, |
243 PrefService::SYNCABLE_PREF); | 240 PrefService::SYNCABLE_PREF); |
244 | 241 |
245 // Mobile plan notifications default to on. | 242 // Mobile plan notifications default to on. |
246 prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, | 243 prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, |
247 true, | 244 true, |
248 PrefService::SYNCABLE_PREF); | 245 PrefService::SYNCABLE_PREF); |
249 | 246 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 348 |
352 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, this); | 349 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, this); |
353 } | 350 } |
354 | 351 |
355 void Preferences::Init(PrefService* prefs) { | 352 void Preferences::Init(PrefService* prefs) { |
356 InitUserPrefs(prefs); | 353 InitUserPrefs(prefs); |
357 | 354 |
358 // Initialize preferences to currently saved state. | 355 // Initialize preferences to currently saved state. |
359 NotifyPrefChanged(NULL); | 356 NotifyPrefChanged(NULL); |
360 | 357 |
361 // Initialize virtual keyboard settings to currently saved state. | |
362 UpdateVirturalKeyboardPreference(prefs); | |
363 | |
364 // If a guest is logged in, initialize the prefs as if this is the first | 358 // If a guest is logged in, initialize the prefs as if this is the first |
365 // login. | 359 // login. |
366 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { | 360 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
367 LoginUtils::Get()->SetFirstLoginPrefs(prefs); | 361 LoginUtils::Get()->SetFirstLoginPrefs(prefs); |
368 } | 362 } |
369 } | 363 } |
370 | 364 |
371 void Preferences::InitUserPrefsForTesting(PrefService* prefs) { | 365 void Preferences::InitUserPrefsForTesting(PrefService* prefs) { |
372 InitUserPrefs(prefs); | 366 InitUserPrefs(prefs); |
373 } | 367 } |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 return; | 697 return; |
704 | 698 |
705 input_method::AutoRepeatRate rate; | 699 input_method::AutoRepeatRate rate; |
706 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); | 700 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); |
707 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); | 701 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); |
708 DCHECK(rate.initial_delay_in_ms > 0); | 702 DCHECK(rate.initial_delay_in_ms > 0); |
709 DCHECK(rate.repeat_interval_in_ms > 0); | 703 DCHECK(rate.repeat_interval_in_ms > 0); |
710 input_method::XKeyboard::SetAutoRepeatRate(rate); | 704 input_method::XKeyboard::SetAutoRepeatRate(rate); |
711 } | 705 } |
712 | 706 |
713 // static | |
714 void Preferences::UpdateVirturalKeyboardPreference(PrefService* prefs) { | |
715 const DictionaryValue* virtual_keyboard_pref = | |
716 prefs->GetDictionary(prefs::kLanguagePreferredVirtualKeyboard); | |
717 DCHECK(virtual_keyboard_pref); | |
718 | |
719 // TODO(yusukes): Clear all virtual keyboard preferences here. | |
720 std::string url; | |
721 std::vector<std::string> layouts_to_remove; | |
722 for (DictionaryValue::key_iterator iter = virtual_keyboard_pref->begin_keys(); | |
723 iter != virtual_keyboard_pref->end_keys(); | |
724 ++iter) { | |
725 const std::string& layout_id = *iter; // e.g. "us", "handwriting-vk" | |
726 if (!virtual_keyboard_pref->GetString(layout_id, &url)) | |
727 continue; | |
728 // TODO(yusukes): add the virtual keyboard preferences here. | |
729 } | |
730 | |
731 // Remove invalid prefs. | |
732 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); | |
733 DictionaryValue* pref_value = updater.Get(); | |
734 for (size_t i = 0; i < layouts_to_remove.size(); ++i) { | |
735 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); | |
736 } | |
737 } | |
738 | |
739 } // namespace chromeos | 707 } // namespace chromeos |
OLD | NEW |