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 "ash/ash_switches.h" | |
8 #include "base/chromeos/chromeos_version.h" | 7 #include "base/chromeos/chromeos_version.h" |
9 #include "base/command_line.h" | 8 #include "base/command_line.h" |
10 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
11 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
12 #include "base/string_split.h" | 11 #include "base/string_split.h" |
13 #include "base/string_util.h" | 12 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 15 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
17 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 16 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 prefs, this); | 259 prefs, this); |
261 disable_gdata_hosted_files_.Init(prefs::kDisableGDataHostedFiles, | 260 disable_gdata_hosted_files_.Init(prefs::kDisableGDataHostedFiles, |
262 prefs, this); | 261 prefs, this); |
263 primary_mouse_button_right_.Init(prefs::kPrimaryMouseButtonRight, | 262 primary_mouse_button_right_.Init(prefs::kPrimaryMouseButtonRight, |
264 prefs, this); | 263 prefs, this); |
265 hotkey_next_engine_in_menu_.Init( | 264 hotkey_next_engine_in_menu_.Init( |
266 prefs::kLanguageHotkeyNextEngineInMenu, prefs, this); | 265 prefs::kLanguageHotkeyNextEngineInMenu, prefs, this); |
267 hotkey_previous_engine_.Init( | 266 hotkey_previous_engine_.Init( |
268 prefs::kLanguageHotkeyPreviousEngine, prefs, this); | 267 prefs::kLanguageHotkeyPreviousEngine, prefs, this); |
269 preferred_languages_.Init(prefs::kLanguagePreferredLanguages, | 268 preferred_languages_.Init(prefs::kLanguagePreferredLanguages, |
270 prefs, this); | 269 prefs, this); |
271 preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, this); | 270 preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, this); |
272 current_input_method_.Init(prefs::kLanguageCurrentInputMethod, prefs, this); | |
273 previous_input_method_.Init(prefs::kLanguagePreviousInputMethod, prefs, this); | |
274 | |
275 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { | 271 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
276 chewing_boolean_prefs_[i].Init( | 272 chewing_boolean_prefs_[i].Init( |
277 language_prefs::kChewingBooleanPrefs[i].pref_name, prefs, this); | 273 language_prefs::kChewingBooleanPrefs[i].pref_name, prefs, this); |
278 } | 274 } |
279 for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { | 275 for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
280 chewing_multiple_choice_prefs_[i].Init( | 276 chewing_multiple_choice_prefs_[i].Init( |
281 language_prefs::kChewingMultipleChoicePrefs[i].pref_name, prefs, this); | 277 language_prefs::kChewingMultipleChoicePrefs[i].pref_name, prefs, this); |
282 } | 278 } |
283 chewing_hsu_sel_key_type_.Init( | 279 chewing_hsu_sel_key_type_.Init( |
284 language_prefs::kChewingHsuSelKeyType.pref_name, prefs, this); | 280 language_prefs::kChewingHsuSelKeyType.pref_name, prefs, this); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) || | 416 if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) || |
421 (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) { | 417 (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) { |
422 UpdateAutoRepeatRate(); | 418 UpdateAutoRepeatRate(); |
423 } | 419 } |
424 | 420 |
425 if (!pref_name || *pref_name == prefs::kLanguagePreloadEngines) { | 421 if (!pref_name || *pref_name == prefs::kLanguagePreloadEngines) { |
426 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, | 422 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
427 language_prefs::kPreloadEnginesConfigName, | 423 language_prefs::kPreloadEnginesConfigName, |
428 preload_engines_.GetValue()); | 424 preload_engines_.GetValue()); |
429 } | 425 } |
430 | |
431 // Do not check |*pref_name| for the two prefs. We're only interested in | |
432 // initial values of the prefs. | |
433 // TODO(yusukes): Remove the second condition on R20. | |
434 if (!pref_name && !CommandLine::ForCurrentProcess()->HasSwitch( | |
435 ash::switches::kDisableAshUberTray)) { | |
436 const std::string previous_input_method_id = | |
437 previous_input_method_.GetValue(); | |
438 const std::string current_input_method_id = | |
439 current_input_method_.GetValue(); | |
440 // NOTICE: ChangeInputMethod() has to be called AFTER the value of | |
441 // |preload_engines_| is sent to the InputMethodManager. Otherwise, the | |
442 // ChangeInputMethod request might be ignored as an invalid input method ID. | |
443 input_method::InputMethodManager* manager = | |
444 input_method::InputMethodManager::GetInstance(); | |
445 if (!previous_input_method_id.empty()) | |
446 manager->ChangeInputMethod(previous_input_method_id); | |
447 if (!current_input_method_id.empty()) | |
448 manager->ChangeInputMethod(current_input_method_id); | |
449 } | |
450 | |
451 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { | 426 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
452 if (!pref_name || | 427 if (!pref_name || |
453 *pref_name == language_prefs::kChewingBooleanPrefs[i].pref_name) { | 428 *pref_name == language_prefs::kChewingBooleanPrefs[i].pref_name) { |
454 SetLanguageConfigBoolean( | 429 SetLanguageConfigBoolean( |
455 language_prefs::kChewingSectionName, | 430 language_prefs::kChewingSectionName, |
456 language_prefs::kChewingBooleanPrefs[i].ibus_config_name, | 431 language_prefs::kChewingBooleanPrefs[i].ibus_config_name, |
457 chewing_boolean_prefs_[i].GetValue()); | 432 chewing_boolean_prefs_[i].GetValue()); |
458 } | 433 } |
459 } | 434 } |
460 for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { | 435 for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 | 657 |
683 // Remove invalid prefs. | 658 // Remove invalid prefs. |
684 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); | 659 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); |
685 DictionaryValue* pref_value = updater.Get(); | 660 DictionaryValue* pref_value = updater.Get(); |
686 for (size_t i = 0; i < layouts_to_remove.size(); ++i) { | 661 for (size_t i = 0; i < layouts_to_remove.size(); ++i) { |
687 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); | 662 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); |
688 } | 663 } |
689 } | 664 } |
690 | 665 |
691 } // namespace chromeos | 666 } // namespace chromeos |
OLD | NEW |