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

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: Cleanup. 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..e90cbb587940d3144d48efedd6167c0ea6079873 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
@@ -349,9 +350,10 @@ void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) {
prefs::kLanguageXkbAutoRepeatInterval, prefs, callback);
}
-void Preferences::Init(PrefServiceSyncable* prefs,
- const user_manager::User* user) {
+void Preferences::Init(Profile* profile, const user_manager::User* user) {
+ DCHECK(profile);
DCHECK(user);
+ PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile);
user_ = user;
user_is_primary_ = UserManager::Get()->GetPrimaryUser() == user_;
InitUserPrefs(prefs);
@@ -362,6 +364,10 @@ void Preferences::Init(PrefServiceSyncable* prefs,
// PrefService::IsSyncing() changes.
prefs->AddObserver(this);
+ ime_state_ = input_method_manager_->GetDefaultState(
+ ProfileHelper::Get()->GetProfileByUser(user_));
+ input_method_manager_->SetState(ime_state_);
+
// Initialize preferences to currently saved state.
ApplyPreferences(REASON_INITIALIZATION, "");
@@ -369,7 +375,8 @@ void Preferences::Init(PrefServiceSyncable* prefs,
// login. For a regular user this is done in
// UserSessionManager::InitProfilePreferences().
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession))
- UserSessionManager::SetFirstLoginPrefs(prefs, std::string(), std::string());
+ UserSessionManager::SetFirstLoginPrefs(
+ profile, std::string(), std::string());
}
void Preferences::InitUserPrefsForTesting(PrefServiceSyncable* prefs,
@@ -536,25 +543,27 @@ void Preferences::ApplyPreferences(ApplyReason reason,
UpdateAutoRepeatRate();
}
- if (reason != REASON_PREF_CHANGED && user_is_active) {
+ if (reason == REASON_INITIALIZATION) {
SetInputMethodList();
- } else if (pref_name == prefs::kLanguagePreloadEngines && user_is_active) {
+ }
Nikita (slow) 2014/08/13 10:56:41 nit: drop {}
Alexander Alekseev 2014/08/13 23:29:32 Done.
+
+ if (pref_name == prefs::kLanguagePreloadEngines &&
+ reason == REASON_PREF_CHANGED) {
SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName,
language_prefs::kPreloadEnginesConfigName,
preload_engines_.GetValue());
}
- if (reason != REASON_PREF_CHANGED ||
- pref_name == prefs::kLanguageEnabledExtensionImes) {
- if (user_is_active) {
- std::string value(enabled_extension_imes_.GetValue());
+ if ((reason == REASON_INITIALIZATION) ||
+ (pref_name == prefs::kLanguageEnabledExtensionImes &&
+ reason == REASON_PREF_CHANGED)) {
+ std::string value(enabled_extension_imes_.GetValue());
- std::vector<std::string> split_values;
- if (!value.empty())
- base::SplitString(value, ',', &split_values);
+ std::vector<std::string> split_values;
+ if (!value.empty())
+ base::SplitString(value, ',', &split_values);
- input_method_manager_->SetEnabledExtensionImes(&split_values);
- }
+ ime_state_->SetEnabledExtensionImes(&split_values);
}
if (user_is_active) {
@@ -596,7 +605,7 @@ void Preferences::SetLanguageConfigStringListAsCSV(const char* section,
if (section == std::string(language_prefs::kGeneralSectionName) &&
name == std::string(language_prefs::kPreloadEnginesConfigName)) {
- input_method_manager_->ReplaceEnabledInputMethods(split_values);
+ ime_state_->ReplaceEnabledInputMethods(split_values);
return;
}
}
@@ -621,9 +630,11 @@ void Preferences::SetInputMethodList() {
// which could have been modified by the SetLanguageConfigStringListAsCSV call
// above to the original state.
if (!previous_input_method_id.empty())
- input_method_manager_->ChangeInputMethod(previous_input_method_id);
+ ime_state_->ChangeInputMethod(previous_input_method_id,
+ false /* show_message */);
if (!current_input_method_id.empty())
- input_method_manager_->ChangeInputMethod(current_input_method_id);
+ ime_state_->ChangeInputMethod(current_input_method_id,
+ false /* show_message */);
}
void Preferences::UpdateAutoRepeatRate() {

Powered by Google App Engine
This is Rietveld 408576698