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

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: Unit test fixed. Re-sorted methods of StateImpl and IMM. 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
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/browser/chromeos/preferences_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/preferences.cc
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 60f7bae8923f291e742665542e3a7325bc430c41..06b4030279312c0a73765bc12b9d69b948d3feb6 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_ =
user_manager::UserManager::Get()->GetPrimaryUser() == user_;
@@ -363,6 +365,12 @@ void Preferences::Init(PrefServiceSyncable* prefs,
// PrefService::IsSyncing() changes.
prefs->AddObserver(this);
+ UserSessionManager* session_manager = UserSessionManager::GetInstance();
+ DCHECK(session_manager);
+ ime_state_ = session_manager->GetDefaultIMEState(
+ ProfileHelper::Get()->GetProfileByUser(user_));
+ input_method_manager_->SetState(ime_state_);
+
// Initialize preferences to currently saved state.
ApplyPreferences(REASON_INITIALIZATION, "");
@@ -370,12 +378,19 @@ 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());
+ session_manager->SetFirstLoginPrefs(profile, std::string(), std::string());
}
-void Preferences::InitUserPrefsForTesting(PrefServiceSyncable* prefs,
- const user_manager::User* user) {
+void Preferences::InitUserPrefsForTesting(
+ PrefServiceSyncable* prefs,
+ const user_manager::User* user,
+ scoped_refptr<input_method::InputMethodManager::State> ime_state) {
user_ = user;
+ ime_state_ = ime_state;
+
+ if (ime_state)
+ input_method_manager_->SetState(ime_state);
+
InitUserPrefs(prefs);
}
@@ -537,25 +552,26 @@ 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) {
+
+ 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) {
@@ -597,7 +613,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;
}
}
@@ -622,9 +638,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() {
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/browser/chromeos/preferences_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698