Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5399)

Unified Diff: chrome/browser/chromeos/preferences.cc

Issue 419293002: IME refactoring: ChromeOS introduce input methods State. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/preferences.cc
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index f6492543705bf18d2a44a259f6b39d03a87ffb2a..7cd4f109f49dcb76eac6eba60c323f425a569e01 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -51,7 +51,8 @@ Preferences::Preferences()
: prefs_(NULL),
input_method_manager_(input_method::InputMethodManager::Get()),
user_(NULL),
- user_is_primary_(false) {
+ user_is_primary_(false),
+ ime_state_outdated_(true) {
// Do not observe shell, if there is no shell instance; e.g., in some unit
// tests.
if (ash::Shell::HasInstance())
@@ -62,7 +63,8 @@ Preferences::Preferences(input_method::InputMethodManager* input_method_manager)
: prefs_(NULL),
input_method_manager_(input_method_manager),
user_(NULL),
- user_is_primary_(false) {
+ user_is_primary_(false),
+ ime_state_outdated_(true) {
// Do not observe shell, if there is no shell instance; e.g., in some unit
// tests.
if (ash::Shell::HasInstance())
@@ -536,12 +538,15 @@ void Preferences::ApplyPreferences(ApplyReason reason,
UpdateAutoRepeatRate();
}
- if (reason != REASON_PREF_CHANGED && user_is_active) {
- SetInputMethodList();
- } else if (pref_name == prefs::kLanguagePreloadEngines && user_is_active) {
- SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName,
- language_prefs::kPreloadEnginesConfigName,
- preload_engines_.GetValue());
+ if (pref_name == prefs::kLanguagePreloadEngines) {
+ if (reason == REASON_PREF_CHANGED && user_is_active) {
+ SetLanguageConfigStringListAsCSV(
+ language_prefs::kGeneralSectionName,
+ language_prefs::kPreloadEnginesConfigName,
+ preload_engines_.GetValue());
+ } else {
+ ime_state_outdated_ = true;
+ }
}
if (reason != REASON_PREF_CHANGED ||
@@ -645,9 +650,26 @@ void Preferences::OnTouchHudProjectionToggled(bool enabled) {
touch_hud_projection_enabled_.SetValue(enabled);
}
+void Preferences::ActivateInputMethods(const user_manager::User* active_user) {
+ bool just_created = false;
+ if (!ime_state_) {
+ ime_state_ = input_method::InputMethodManager::Get()->CreateNewState(
+ active_user->email());
+ just_created = true;
+ }
+ input_method::InputMethodManager::Get()->SetState(ime_state_);
+ if (just_created || ime_state_outdated_) {
+ SetInputMethodList();
+ ime_state_outdated_ = false;
+ }
+}
+
void Preferences::ActiveUserChanged(const user_manager::User* active_user) {
if (active_user != user_)
return;
+
+ ActivateInputMethods(active_user);
+
ApplyPreferences(REASON_ACTIVE_USER_CHANGED, "");
}

Powered by Google App Engine
This is Rietveld 408576698