| 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" |
| 7 #include "base/chromeos/chromeos_version.h" | 8 #include "base/chromeos/chromeos_version.h" |
| 8 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 9 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| 10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 11 #include "base/string_split.h" | 12 #include "base/string_split.h" |
| 12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 16 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 16 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 17 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 prefs, this); | 260 prefs, this); |
| 260 disable_gdata_hosted_files_.Init(prefs::kDisableGDataHostedFiles, | 261 disable_gdata_hosted_files_.Init(prefs::kDisableGDataHostedFiles, |
| 261 prefs, this); | 262 prefs, this); |
| 262 primary_mouse_button_right_.Init(prefs::kPrimaryMouseButtonRight, | 263 primary_mouse_button_right_.Init(prefs::kPrimaryMouseButtonRight, |
| 263 prefs, this); | 264 prefs, this); |
| 264 hotkey_next_engine_in_menu_.Init( | 265 hotkey_next_engine_in_menu_.Init( |
| 265 prefs::kLanguageHotkeyNextEngineInMenu, prefs, this); | 266 prefs::kLanguageHotkeyNextEngineInMenu, prefs, this); |
| 266 hotkey_previous_engine_.Init( | 267 hotkey_previous_engine_.Init( |
| 267 prefs::kLanguageHotkeyPreviousEngine, prefs, this); | 268 prefs::kLanguageHotkeyPreviousEngine, prefs, this); |
| 268 preferred_languages_.Init(prefs::kLanguagePreferredLanguages, | 269 preferred_languages_.Init(prefs::kLanguagePreferredLanguages, |
| 269 prefs, this); | 270 prefs, this); |
| 270 preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, this); | 271 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 |
| 271 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { | 275 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
| 272 chewing_boolean_prefs_[i].Init( | 276 chewing_boolean_prefs_[i].Init( |
| 273 language_prefs::kChewingBooleanPrefs[i].pref_name, prefs, this); | 277 language_prefs::kChewingBooleanPrefs[i].pref_name, prefs, this); |
| 274 } | 278 } |
| 275 for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { | 279 for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
| 276 chewing_multiple_choice_prefs_[i].Init( | 280 chewing_multiple_choice_prefs_[i].Init( |
| 277 language_prefs::kChewingMultipleChoicePrefs[i].pref_name, prefs, this); | 281 language_prefs::kChewingMultipleChoicePrefs[i].pref_name, prefs, this); |
| 278 } | 282 } |
| 279 chewing_hsu_sel_key_type_.Init( | 283 chewing_hsu_sel_key_type_.Init( |
| 280 language_prefs::kChewingHsuSelKeyType.pref_name, prefs, this); | 284 language_prefs::kChewingHsuSelKeyType.pref_name, prefs, this); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) || | 420 if (!pref_name || ((*pref_name == prefs::kLanguageXkbAutoRepeatDelay) || |
| 417 (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) { | 421 (*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) { |
| 418 UpdateAutoRepeatRate(); | 422 UpdateAutoRepeatRate(); |
| 419 } | 423 } |
| 420 | 424 |
| 421 if (!pref_name || *pref_name == prefs::kLanguagePreloadEngines) { | 425 if (!pref_name || *pref_name == prefs::kLanguagePreloadEngines) { |
| 422 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, | 426 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, |
| 423 language_prefs::kPreloadEnginesConfigName, | 427 language_prefs::kPreloadEnginesConfigName, |
| 424 preload_engines_.GetValue()); | 428 preload_engines_.GetValue()); |
| 425 } | 429 } |
| 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 |
| 426 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { | 451 for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { |
| 427 if (!pref_name || | 452 if (!pref_name || |
| 428 *pref_name == language_prefs::kChewingBooleanPrefs[i].pref_name) { | 453 *pref_name == language_prefs::kChewingBooleanPrefs[i].pref_name) { |
| 429 SetLanguageConfigBoolean( | 454 SetLanguageConfigBoolean( |
| 430 language_prefs::kChewingSectionName, | 455 language_prefs::kChewingSectionName, |
| 431 language_prefs::kChewingBooleanPrefs[i].ibus_config_name, | 456 language_prefs::kChewingBooleanPrefs[i].ibus_config_name, |
| 432 chewing_boolean_prefs_[i].GetValue()); | 457 chewing_boolean_prefs_[i].GetValue()); |
| 433 } | 458 } |
| 434 } | 459 } |
| 435 for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { | 460 for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 | 682 |
| 658 // Remove invalid prefs. | 683 // Remove invalid prefs. |
| 659 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); | 684 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); |
| 660 DictionaryValue* pref_value = updater.Get(); | 685 DictionaryValue* pref_value = updater.Get(); |
| 661 for (size_t i = 0; i < layouts_to_remove.size(); ++i) { | 686 for (size_t i = 0; i < layouts_to_remove.size(); ++i) { |
| 662 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); | 687 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); |
| 663 } | 688 } |
| 664 } | 689 } |
| 665 | 690 |
| 666 } // namespace chromeos | 691 } // namespace chromeos |
| OLD | NEW |