Index: chrome/browser/chromeos/preferences.cc |
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc |
index 365d53e88c22d5d8d31f9adf1e177aae833b5358..6ab83e2f9f6e41b19920cf30e8dc5a7434cfd1d1 100644 |
--- a/chrome/browser/chromeos/preferences.cc |
+++ b/chrome/browser/chromeos/preferences.cc |
@@ -22,10 +22,9 @@ |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
#include "chrome/browser/chromeos/drive/file_system_util.h" |
-#include "chrome/browser/chromeos/input_method/input_method_util.h" |
+#include "chrome/browser/chromeos/input_method/input_method_syncer.h" |
#include "chrome/browser/chromeos/login/session/user_session_manager.h" |
#include "chrome/browser/chromeos/net/wake_on_wifi_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" |
@@ -36,6 +35,7 @@ |
#include "components/feedback/tracing_manager.h" |
#include "components/pref_registry/pref_registry_syncable.h" |
#include "components/user_manager/user.h" |
+#include "content/public/browser/browser_thread.h" |
#include "third_party/icu/source/i18n/unicode/timezone.h" |
#include "ui/base/ime/chromeos/extension_ime_util.h" |
#include "ui/base/ime/chromeos/ime_keyboard.h" |
@@ -216,9 +216,6 @@ void Preferences::RegisterProfilePrefs( |
prefs::kLanguagePreviousInputMethod, |
"", |
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
- // We don't sync the list of input methods and preferred languages since a |
- // user might use two or more devices with different hardware keyboards. |
- // crosbug.com/15181 |
registry->RegisterStringPref( |
prefs::kLanguagePreferredLanguages, |
kFallbackInputMethodLocale, |
@@ -322,6 +319,8 @@ void Preferences::RegisterProfilePrefs( |
prefs::kTouchVirtualKeyboardEnabled, |
false, |
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ |
+ input_method::InputMethodSyncer::RegisterProfilePrefs(registry); |
} |
void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) { |
@@ -367,6 +366,9 @@ void Preferences::Init(Profile* profile, const user_manager::User* user) { |
DCHECK(profile); |
DCHECK(user); |
PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile); |
+ // This causes OnIsSyncingChanged to be called when the value of |
+ // PrefService::IsSyncing() changes. |
+ prefs->AddObserver(this); |
user_ = user; |
user_is_primary_ = |
user_manager::UserManager::Get()->GetPrimaryUser() == user_; |
@@ -374,10 +376,6 @@ void Preferences::Init(Profile* profile, const user_manager::User* user) { |
user_manager::UserManager::Get()->AddSessionStateObserver(this); |
- // This causes OnIsSyncingChanged to be called when the value of |
- // PrefService::IsSyncing() changes. |
- prefs->AddObserver(this); |
- |
UserSessionManager* session_manager = UserSessionManager::GetInstance(); |
DCHECK(session_manager); |
ime_state_ = session_manager->GetDefaultIMEState(profile); |
@@ -385,6 +383,9 @@ void Preferences::Init(Profile* profile, const user_manager::User* user) { |
// Initialize preferences to currently saved state. |
ApplyPreferences(REASON_INITIALIZATION, ""); |
+ input_method_syncer_.reset( |
+ new input_method::InputMethodSyncer(prefs, ime_state_)); |
+ input_method_syncer_->Initialize(); |
// If a guest is logged in, initialize the prefs as if this is the first |
// login. For a regular user this is done in |
@@ -404,6 +405,10 @@ void Preferences::InitUserPrefsForTesting( |
input_method_manager_->SetState(ime_state); |
InitUserPrefs(prefs); |
+ |
+ input_method_syncer_.reset( |
+ new input_method::InputMethodSyncer(prefs, ime_state_)); |
+ input_method_syncer_->Initialize(); |
} |
void Preferences::SetInputMethodListForTesting() { |
@@ -545,7 +550,9 @@ void Preferences::ApplyPreferences(ApplyReason reason, |
#if !defined(USE_ATHENA) |
if (user_is_active) { |
const bool enabled = touch_hud_projection_enabled_.GetValue(); |
- ash::Shell::GetInstance()->SetTouchHudProjectionEnabled(enabled); |
+ // There may not be a shell, e.g., in some unit tests. |
+ if (ash::Shell::HasInstance()) |
+ ash::Shell::GetInstance()->SetTouchHudProjectionEnabled(enabled); |
} |
#endif |
} |