summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralemate <alemate@chromium.org>2015-05-12 14:36:07 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-12 21:36:37 +0000
commitf06730290bf11bcbb8d225d5f781e7989c2ddc27 (patch)
tree6cdb46d34b73e730ff414cb8df818fb31fc69570
parent121cbb5f7fce9719ab6152cb2e059575df8139d6 (diff)
downloadchromium_src-f06730290bf11bcbb8d225d5f781e7989c2ddc27.zip
chromium_src-f06730290bf11bcbb8d225d5f781e7989c2ddc27.tar.gz
chromium_src-f06730290bf11bcbb8d225d5f781e7989c2ddc27.tar.bz2
ChromeOS: switch UI language before apps are loaded.
Chrome Apps cannot switch UI language, so we need to initialize apps after app_locale is set correctly. This CL splits ProfileImpl::OnPrefsLoaded into two steps (the former and OnLocaleReady), adding intermediate call to switch to correct locale. Also Profile is added as parameter to InputMethodChanged() observers. chromeos::locale_util::SwitchLanguage() now updates default input methods for user profile, not currently active set. TBR=dmazzoni@chromium.org BUG=469268 TEST=manual Review URL: https://codereview.chromium.org/1055863002 Cr-Commit-Position: refs/heads/master@{#329496}
-rw-r--r--chrome/browser/chromeos/accessibility/accessibility_manager.cc1
-rw-r--r--chrome/browser/chromeos/accessibility/accessibility_manager.h1
-rw-r--r--chrome/browser/chromeos/base/locale_util.cc19
-rw-r--r--chrome/browser/chromeos/base/locale_util.h8
-rw-r--r--chrome/browser/chromeos/customization/customization_document_browsertest.cc4
-rw-r--r--chrome/browser/chromeos/extensions/input_method_event_router.cc7
-rw-r--r--chrome/browser/chromeos/extensions/input_method_event_router.h1
-rw-r--r--chrome/browser/chromeos/input_method/accessibility.cc4
-rw-r--r--chrome/browser/chromeos/input_method/accessibility.h4
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl.cc14
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl.h1
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc1
-rw-r--r--chrome/browser/chromeos/input_method/input_method_persistence.cc11
-rw-r--r--chrome/browser/chromeos/input_method/input_method_persistence.h1
-rw-r--r--chrome/browser/chromeos/input_method/input_method_persistence_unittest.cc18
-rw-r--r--chrome/browser/chromeos/input_method/mode_indicator_controller.cc1
-rw-r--r--chrome/browser/chromeos/input_method/mode_indicator_controller.h1
-rw-r--r--chrome/browser/chromeos/login/screens/network_screen.cc5
-rw-r--r--chrome/browser/chromeos/login/screens/network_screen.h1
-rw-r--r--chrome/browser/chromeos/login/session/user_session_manager.cc5
-rw-r--r--chrome/browser/chromeos/login/session/user_session_manager.h8
-rw-r--r--chrome/browser/chromeos/login/ui/login_display_host_impl.cc4
-rw-r--r--chrome/browser/chromeos/login/wizard_controller_browsertest.cc4
-rw-r--r--chrome/browser/profiles/profile_impl.cc40
-rw-r--r--chrome/browser/profiles/profile_impl.h5
-rw-r--r--chrome/browser/ui/ash/system_tray_delegate_chromeos.cc1
-rw-r--r--chrome/browser/ui/ash/system_tray_delegate_chromeos.h1
-rw-r--r--chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc2
-rw-r--r--tools/metrics/histograms/histograms.xml11
-rw-r--r--ui/base/ime/chromeos/input_method_manager.h1
30 files changed, 130 insertions, 55 deletions
diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.cc b/chrome/browser/chromeos/accessibility/accessibility_manager.cc
index 338a86e..c36c118 100644
--- a/chrome/browser/chromeos/accessibility/accessibility_manager.cc
+++ b/chrome/browser/chromeos/accessibility/accessibility_manager.cc
@@ -842,6 +842,7 @@ void AccessibilityManager::UpdateBrailleImeState() {
// Overridden from InputMethodManager::Observer.
void AccessibilityManager::InputMethodChanged(
input_method::InputMethodManager* manager,
+ Profile* /* profile */,
bool show_message) {
// Sticky keys is implemented only in ash.
// TODO(dpolukhin): support Athena, crbug.com/408733.
diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.h b/chrome/browser/chromeos/accessibility/accessibility_manager.h
index 263ac3c..9f13b71 100644
--- a/chrome/browser/chromeos/accessibility/accessibility_manager.h
+++ b/chrome/browser/chromeos/accessibility/accessibility_manager.h
@@ -240,6 +240,7 @@ class AccessibilityManager
// InputMethodManager::Observer
void InputMethodChanged(input_method::InputMethodManager* manager,
+ Profile* profile,
bool show_message) override;
// Profile which has the current a11y context.
diff --git a/chrome/browser/chromeos/base/locale_util.cc b/chrome/browser/chromeos/base/locale_util.cc
index 37e659b..1dfa962 100644
--- a/chrome/browser/chromeos/base/locale_util.cc
+++ b/chrome/browser/chromeos/base/locale_util.cc
@@ -8,6 +8,8 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
+#include "chrome/browser/chromeos/login/session/user_session_manager.h"
+#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/base/resource/resource_bundle.h"
@@ -21,17 +23,20 @@ struct SwitchLanguageData {
SwitchLanguageData(const std::string& locale,
const bool enable_locale_keyboard_layouts,
const bool login_layouts_only,
- const locale_util::SwitchLanguageCallback& callback)
+ const locale_util::SwitchLanguageCallback& callback,
+ Profile* profile)
: callback(callback),
result(locale, std::string(), false),
enable_locale_keyboard_layouts(enable_locale_keyboard_layouts),
- login_layouts_only(login_layouts_only) {}
+ login_layouts_only(login_layouts_only),
+ profile(profile) {}
const locale_util::SwitchLanguageCallback callback;
locale_util::LanguageSwitchResult result;
const bool enable_locale_keyboard_layouts;
const bool login_layouts_only;
+ Profile* profile;
};
// Runs on SequencedWorkerPool thread under PostTaskAndReply().
@@ -58,7 +63,7 @@ void FinishSwitchLanguage(scoped_ptr<SwitchLanguageData> data) {
input_method::InputMethodManager* manager =
input_method::InputMethodManager::Get();
scoped_refptr<input_method::InputMethodManager::State> ime_state =
- manager->GetActiveIMEState();
+ UserSessionManager::GetInstance()->GetDefaultIMEState(data->profile);
if (data->login_layouts_only) {
// Enable the hardware keyboard layouts and locale-specific layouts
// suitable for use on the login screen. This will also switch to the
@@ -106,10 +111,12 @@ LanguageSwitchResult::LanguageSwitchResult(const std::string& requested_locale,
void SwitchLanguage(const std::string& locale,
const bool enable_locale_keyboard_layouts,
const bool login_layouts_only,
- const SwitchLanguageCallback& callback) {
+ const SwitchLanguageCallback& callback,
+ Profile* profile) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- scoped_ptr<SwitchLanguageData> data(new SwitchLanguageData(
- locale, enable_locale_keyboard_layouts, login_layouts_only, callback));
+ scoped_ptr<SwitchLanguageData> data(
+ new SwitchLanguageData(locale, enable_locale_keyboard_layouts,
+ login_layouts_only, callback, profile));
base::Closure reloader(
base::Bind(&SwitchLanguageDoReloadLocale, base::Unretained(data.get())));
content::BrowserThread::PostBlockingPoolTaskAndReply(
diff --git a/chrome/browser/chromeos/base/locale_util.h b/chrome/browser/chromeos/base/locale_util.h
index 751378d..6f76ec6 100644
--- a/chrome/browser/chromeos/base/locale_util.h
+++ b/chrome/browser/chromeos/base/locale_util.h
@@ -11,6 +11,8 @@
#include "base/memory/scoped_ptr.h"
+class Profile;
+
namespace base {
template <typename T>
@@ -42,7 +44,8 @@ typedef base::Callback<void(const LanguageSwitchResult& result)>
SwitchLanguageCallback;
// This function updates input methods only if requested. In general, you want
-// |enable_locale_keyboard_layouts = true|.
+// |enable_locale_keyboard_layouts = true|. |profile| is needed because IME
+// extensions are per-user.
// Note: in case of |enable_locale_keyboard_layouts = false|, the input method
// currently in use may not be supported by the new locale. Using the new locale
// with an unsupported input method may lead to undefined behavior. Use
@@ -51,7 +54,8 @@ typedef base::Callback<void(const LanguageSwitchResult& result)>
void SwitchLanguage(const std::string& locale,
const bool enable_locale_keyboard_layouts,
const bool login_layouts_only,
- const SwitchLanguageCallback& callback);
+ const SwitchLanguageCallback& callback,
+ Profile* profile);
} // namespace locale_util
} // namespace chromeos
diff --git a/chrome/browser/chromeos/customization/customization_document_browsertest.cc b/chrome/browser/chromeos/customization/customization_document_browsertest.cc
index ab22264..7ba8243 100644
--- a/chrome/browser/chromeos/customization/customization_document_browsertest.cc
+++ b/chrome/browser/chromeos/customization/customization_document_browsertest.cc
@@ -9,6 +9,7 @@
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/chromeos/base/locale_util.h"
#include "chrome/browser/chromeos/customization/customization_document.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chromeos/system/fake_statistics_provider.h"
@@ -183,7 +184,8 @@ IN_PROC_BROWSER_TEST_F(CustomizationLocaleTest, CheckAvailableLocales) {
for (size_t i = 0; i < languages_available.size(); ++i) {
LanguageSwitchedWaiter waiter(base::Bind(&VerifyLanguageSwitched));
locale_util::SwitchLanguage(languages_available[i], true, true,
- waiter.Callback());
+ waiter.Callback(),
+ ProfileManager::GetActiveUserProfile());
waiter.Wait();
{
std::string resolved_locale;
diff --git a/chrome/browser/chromeos/extensions/input_method_event_router.cc b/chrome/browser/chromeos/extensions/input_method_event_router.cc
index 79e4f73..86c32d1 100644
--- a/chrome/browser/chromeos/extensions/input_method_event_router.cc
+++ b/chrome/browser/chromeos/extensions/input_method_event_router.cc
@@ -9,6 +9,7 @@
#include "base/json/json_writer.h"
#include "base/values.h"
#include "chrome/browser/chromeos/extensions/input_method_api.h"
+#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_context.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_system.h"
@@ -26,8 +27,12 @@ ExtensionInputMethodEventRouter::~ExtensionInputMethodEventRouter() {
}
void ExtensionInputMethodEventRouter::InputMethodChanged(
- input_method::InputMethodManager *manager,
+ input_method::InputMethodManager* manager,
+ Profile* profile,
bool show_message) {
+ // This should probably be CHECK, as delivering event to a wrong
+ // profile means delivering it to a wrong extension instance.
+ DCHECK(profile->IsSameProfile(Profile::FromBrowserContext(context_)));
extensions::EventRouter* router = extensions::EventRouter::Get(context_);
if (!router->HasEventListener(
diff --git a/chrome/browser/chromeos/extensions/input_method_event_router.h b/chrome/browser/chromeos/extensions/input_method_event_router.h
index 078ca99..a0cf03b 100644
--- a/chrome/browser/chromeos/extensions/input_method_event_router.h
+++ b/chrome/browser/chromeos/extensions/input_method_event_router.h
@@ -24,6 +24,7 @@ class ExtensionInputMethodEventRouter
// Implements input_method::InputMethodManager::Observer:
void InputMethodChanged(input_method::InputMethodManager* manager,
+ Profile* profile,
bool show_message) override;
private:
diff --git a/chrome/browser/chromeos/input_method/accessibility.cc b/chrome/browser/chromeos/input_method/accessibility.cc
index 59ef865..084f720 100644
--- a/chrome/browser/chromeos/input_method/accessibility.cc
+++ b/chrome/browser/chromeos/input_method/accessibility.cc
@@ -25,6 +25,7 @@ Accessibility::~Accessibility() {
}
void Accessibility::InputMethodChanged(InputMethodManager* imm,
+ Profile* profile,
bool show_message) {
DCHECK_EQ(imm, imm_);
if (!show_message)
@@ -36,8 +37,7 @@ void Accessibility::InputMethodChanged(InputMethodManager* imm,
const std::string medium_name = base::UTF16ToUTF8(
imm_->GetInputMethodUtil()->GetInputMethodMediumName(descriptor));
- AutomationManagerAura::GetInstance()->HandleAlert(
- ProfileManager::GetActiveUserProfile(), medium_name);
+ AutomationManagerAura::GetInstance()->HandleAlert(profile, medium_name);
}
} // namespace input_method
diff --git a/chrome/browser/chromeos/input_method/accessibility.h b/chrome/browser/chromeos/input_method/accessibility.h
index d295d28..9f4b067 100644
--- a/chrome/browser/chromeos/input_method/accessibility.h
+++ b/chrome/browser/chromeos/input_method/accessibility.h
@@ -19,7 +19,9 @@ class Accessibility
private:
// InputMethodManager::Observer implementation.
- void InputMethodChanged(InputMethodManager* imm, bool show_message) override;
+ void InputMethodChanged(InputMethodManager* imm,
+ Profile* profile,
+ bool show_message) override;
InputMethodManager* imm_;
DISALLOW_COPY_AND_ASSIGN(Accessibility);
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
index 32504e4..7494515 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
@@ -422,7 +422,8 @@ void InputMethodManagerImpl::StateImpl::ChangeInputMethod(
// Always change input method even if it is the same.
// TODO(komatsu): Revisit if this is neccessary.
if (IsActive())
- manager_->ChangeInputMethodInternal(*descriptor, show_message, notify_menu);
+ manager_->ChangeInputMethodInternal(*descriptor, profile, show_message,
+ notify_menu);
manager_->RecordInputMethodUsage(current_input_method.id());
}
@@ -825,9 +826,8 @@ void InputMethodManagerImpl::SetState(
// Always call ChangeInputMethodInternal even when the input method id
// remain unchanged, because onActivate event needs to be sent to IME
// extension to update the current screen type correctly.
- ChangeInputMethodInternal(state_->current_input_method,
- false /* show_message */,
- true /* notify_menu */);
+ ChangeInputMethodInternal(state_->current_input_method, state_->profile,
+ false /* show_message */, true /* notify_menu */);
}
}
@@ -975,6 +975,7 @@ const InputMethodDescriptor* InputMethodManagerImpl::LookupInputMethod(
void InputMethodManagerImpl::ChangeInputMethodInternal(
const InputMethodDescriptor& descriptor,
+ Profile* profile,
bool show_message,
bool notify_menu) {
// No need to switch input method when terminating.
@@ -1033,9 +1034,8 @@ void InputMethodManagerImpl::ChangeInputMethodInternal(
}
// Update input method indicators (e.g. "US", "DV") in Chrome windows.
- FOR_EACH_OBSERVER(InputMethodManager::Observer,
- observers_,
- InputMethodChanged(this, show_message));
+ FOR_EACH_OBSERVER(InputMethodManager::Observer, observers_,
+ InputMethodChanged(this, profile, show_message));
}
void InputMethodManagerImpl::LoadNecessaryComponentExtensions(
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.h b/chrome/browser/chromeos/input_method/input_method_manager_impl.h
index 8c930d5..966d479 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.h
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.h
@@ -207,6 +207,7 @@ class InputMethodManagerImpl : public InputMethodManager,
// Change system input method.
void ChangeInputMethodInternal(const InputMethodDescriptor& descriptor,
+ Profile* profile,
bool show_message,
bool notify_menu);
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
index 4cde59c..f48c5f83 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
@@ -71,6 +71,7 @@ class TestObserver : public InputMethodManager::Observer,
~TestObserver() override {}
void InputMethodChanged(InputMethodManager* manager,
+ Profile* /* profile */,
bool show_message) override {
++input_method_changed_count_;
last_show_message_ = show_message;
diff --git a/chrome/browser/chromeos/input_method/input_method_persistence.cc b/chrome/browser/chromeos/input_method/input_method_persistence.cc
index b89404b..7bc298f 100644
--- a/chrome/browser/chromeos/input_method/input_method_persistence.cc
+++ b/chrome/browser/chromeos/input_method/input_method_persistence.cc
@@ -83,12 +83,12 @@ static void SetUserLRUInputMethod(
}
void PersistUserInputMethod(const std::string& input_method,
- InputMethodManager* const manager) {
+ InputMethodManager* const manager,
+ Profile* profile) {
PrefService* user_prefs = NULL;
// Persist the method on a per user basis. Note that the keyboard settings are
// stored per user desktop and a visiting window will use the same input
// method as the desktop it is on (and not of the owner of the window).
- Profile* profile = ProfileManager::GetActiveUserProfile();
if (profile)
user_prefs = profile->GetPrefs();
if (!user_prefs)
@@ -119,8 +119,9 @@ InputMethodPersistence::~InputMethodPersistence() {
input_method_manager_->RemoveObserver(this);
}
-void InputMethodPersistence::InputMethodChanged(
- InputMethodManager* manager, bool show_message) {
+void InputMethodPersistence::InputMethodChanged(InputMethodManager* manager,
+ Profile* profile,
+ bool show_message) {
DCHECK_EQ(input_method_manager_, manager);
const std::string current_input_method =
manager->GetActiveIMEState()->GetCurrentInputMethod().id();
@@ -135,7 +136,7 @@ void InputMethodPersistence::InputMethodChanged(
PersistSystemInputMethod(current_input_method);
return;
case InputMethodManager::STATE_BROWSER_SCREEN:
- PersistUserInputMethod(current_input_method, manager);
+ PersistUserInputMethod(current_input_method, manager, profile);
return;
case InputMethodManager::STATE_LOCK_SCREEN:
// We use a special set of input methods on the screen. Do not update.
diff --git a/chrome/browser/chromeos/input_method/input_method_persistence.h b/chrome/browser/chromeos/input_method/input_method_persistence.h
index fc7c802..73af6d0 100644
--- a/chrome/browser/chromeos/input_method/input_method_persistence.h
+++ b/chrome/browser/chromeos/input_method/input_method_persistence.h
@@ -33,6 +33,7 @@ class InputMethodPersistence : public InputMethodManager::Observer {
// InputMethodManager::Observer overrides.
void InputMethodChanged(InputMethodManager* manager,
+ Profile* profile,
bool show_message) override;
private:
diff --git a/chrome/browser/chromeos/input_method/input_method_persistence_unittest.cc b/chrome/browser/chromeos/input_method/input_method_persistence_unittest.cc
index 0592181..8bb561e 100644
--- a/chrome/browser/chromeos/input_method/input_method_persistence_unittest.cc
+++ b/chrome/browser/chromeos/input_method/input_method_persistence_unittest.cc
@@ -90,32 +90,38 @@ TEST_F(InputMethodPersistenceTest, TestPrefPersistenceByState) {
persistence.OnSessionStateChange(InputMethodManager::STATE_LOGIN_SCREEN);
mock_manager_.SetCurrentInputMethodId(kInputId1);
- persistence.InputMethodChanged(&mock_manager_, false);
+ persistence.InputMethodChanged(&mock_manager_,
+ ProfileManager::GetActiveUserProfile(), false);
VerifyPrefs("", "", kInputId1);
persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN);
mock_manager_.SetCurrentInputMethodId(kInputId2);
- persistence.InputMethodChanged(&mock_manager_, false);
+ persistence.InputMethodChanged(&mock_manager_,
+ ProfileManager::GetActiveUserProfile(), false);
VerifyPrefs(kInputId2, "", kInputId1);
persistence.OnSessionStateChange(InputMethodManager::STATE_LOCK_SCREEN);
mock_manager_.SetCurrentInputMethodId(kInputId1);
- persistence.InputMethodChanged(&mock_manager_, false);
+ persistence.InputMethodChanged(&mock_manager_,
+ ProfileManager::GetActiveUserProfile(), false);
VerifyPrefs(kInputId2, "", kInputId1);
persistence.OnSessionStateChange(InputMethodManager::STATE_TERMINATING);
mock_manager_.SetCurrentInputMethodId(kInputId1);
- persistence.InputMethodChanged(&mock_manager_, false);
+ persistence.InputMethodChanged(&mock_manager_,
+ ProfileManager::GetActiveUserProfile(), false);
VerifyPrefs(kInputId2, "", kInputId1);
persistence.OnSessionStateChange(InputMethodManager::STATE_LOGIN_SCREEN);
mock_manager_.SetCurrentInputMethodId(kInputId2);
- persistence.InputMethodChanged(&mock_manager_, false);
+ persistence.InputMethodChanged(&mock_manager_,
+ ProfileManager::GetActiveUserProfile(), false);
VerifyPrefs(kInputId2, "", kInputId2);
persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN);
mock_manager_.SetCurrentInputMethodId(kInputId1);
- persistence.InputMethodChanged(&mock_manager_, false);
+ persistence.InputMethodChanged(&mock_manager_,
+ ProfileManager::GetActiveUserProfile(), false);
VerifyPrefs(kInputId1, kInputId2, kInputId2);
}
diff --git a/chrome/browser/chromeos/input_method/mode_indicator_controller.cc b/chrome/browser/chromeos/input_method/mode_indicator_controller.cc
index 64c30a3..2540032 100644
--- a/chrome/browser/chromeos/input_method/mode_indicator_controller.cc
+++ b/chrome/browser/chromeos/input_method/mode_indicator_controller.cc
@@ -84,6 +84,7 @@ ModeIndicatorController::GetModeIndicatorObserverForTesting() {
}
void ModeIndicatorController::InputMethodChanged(InputMethodManager* manager,
+ Profile* /* profile */,
bool show_message) {
if (!show_message)
return;
diff --git a/chrome/browser/chromeos/input_method/mode_indicator_controller.h b/chrome/browser/chromeos/input_method/mode_indicator_controller.h
index ad6e905..0c7c196 100644
--- a/chrome/browser/chromeos/input_method/mode_indicator_controller.h
+++ b/chrome/browser/chromeos/input_method/mode_indicator_controller.h
@@ -47,6 +47,7 @@ class ModeIndicatorController
private:
// InputMethodManager::Observer implementation.
void InputMethodChanged(InputMethodManager* manager,
+ Profile* profile,
bool show_message) override;
// Show the mode inidicator with the current ime's short name if all
diff --git a/chrome/browser/chromeos/login/screens/network_screen.cc b/chrome/browser/chromeos/login/screens/network_screen.cc
index 25d3e8b..a98dd15 100644
--- a/chrome/browser/chromeos/login/screens/network_screen.cc
+++ b/chrome/browser/chromeos/login/screens/network_screen.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/chromeos/login/screens/network_view.h"
#include "chrome/browser/chromeos/login/ui/input_events_blocker.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/chromium_strings.h"
@@ -175,6 +176,7 @@ void NetworkScreen::DefaultNetworkChanged(const NetworkState* network) {
void NetworkScreen::InputMethodChanged(
input_method::InputMethodManager* manager,
+ Profile* /* proflie */,
bool /* show_message */) {
GetContextEditor().SetString(
kContextKeyInputMethod,
@@ -195,7 +197,8 @@ void NetworkScreen::SetApplicationLocale(const std::string& locale) {
&NetworkScreen::OnLanguageChangedCallback, weak_factory_.GetWeakPtr(),
base::Owned(new chromeos::InputEventsBlocker)));
locale_util::SwitchLanguage(locale, true /* enableLocaleKeyboardLayouts */,
- true /* login_layouts_only */, callback);
+ true /* login_layouts_only */, callback,
+ ProfileManager::GetActiveUserProfile());
}
std::string NetworkScreen::GetApplicationLocale() {
diff --git a/chrome/browser/chromeos/login/screens/network_screen.h b/chrome/browser/chromeos/login/screens/network_screen.h
index 9c1ae66..740b0f7 100644
--- a/chrome/browser/chromeos/login/screens/network_screen.h
+++ b/chrome/browser/chromeos/login/screens/network_screen.h
@@ -77,6 +77,7 @@ class NetworkScreen : public NetworkModel,
// InputMethodManager::Observer implementation:
void InputMethodChanged(input_method::InputMethodManager* manager,
+ Profile* profile,
bool show_message) override;
void SetApplicationLocale(const std::string& locale);
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.cc b/chrome/browser/chromeos/login/session/user_session_manager.cc
index 9018d8a..5b3ade2 100644
--- a/chrome/browser/chromeos/login/session/user_session_manager.cc
+++ b/chrome/browser/chromeos/login/session/user_session_manager.cc
@@ -610,8 +610,9 @@ bool UserSessionManager::RespectLocalePreference(
// So input methods should be enabled somewhere.
const bool enable_layouts =
user_manager::UserManager::Get()->IsLoggedInAsGuest();
- locale_util::SwitchLanguage(
- pref_locale, enable_layouts, false /* login_layouts_only */, callback);
+ locale_util::SwitchLanguage(pref_locale, enable_layouts,
+ false /* login_layouts_only */, callback,
+ profile);
return true;
}
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.h b/chrome/browser/chromeos/login/session/user_session_manager.h
index c8eec25..b86b203 100644
--- a/chrome/browser/chromeos/login/session/user_session_manager.h
+++ b/chrome/browser/chromeos/login/session/user_session_manager.h
@@ -191,6 +191,10 @@ class UserSessionManager
const user_manager::User* user,
const locale_util::SwitchLanguageCallback& callback) const;
+ // Switch to the locale that |profile| wishes to use and invoke |callback|.
+ void RespectLocalePreferenceWrapper(Profile* profile,
+ const base::Closure& callback);
+
// Restarts Chrome if needed. This happens when user session has custom
// flags/switches enabled. Another case when owner has setup custom flags,
// they are applied on login screen as well but not to user session.
@@ -351,10 +355,6 @@ class UserSessionManager
LoginDisplayHost* login_host,
bool locale_pref_checked);
- // Switch to the locale that |profile| wishes to use and invoke |callback|.
- void RespectLocalePreferenceWrapper(Profile* profile,
- const base::Closure& callback);
-
static void RunCallbackOnLocaleLoaded(
const base::Closure& callback,
InputEventsBlocker* input_events_blocker,
diff --git a/chrome/browser/chromeos/login/ui/login_display_host_impl.cc b/chrome/browser/chromeos/login/ui/login_display_host_impl.cc
index 272bb68..7409b6b 100644
--- a/chrome/browser/chromeos/login/ui/login_display_host_impl.cc
+++ b/chrome/browser/chromeos/login/ui/login_display_host_impl.cc
@@ -1274,8 +1274,8 @@ void ShowLoginWizard(const std::string& first_screen_name) {
base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())));
// Load locale keyboards here. Hardware layout would be automatically enabled.
- locale_util::SwitchLanguage(
- locale, true, true /* login_layouts_only */, callback);
+ locale_util::SwitchLanguage(locale, true, true /* login_layouts_only */,
+ callback, ProfileManager::GetActiveUserProfile());
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc
index 9e9f1a8..136ce50 100644
--- a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc
+++ b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc
@@ -48,6 +48,7 @@
#include "chrome/browser/chromeos/policy/server_backed_device_state.h"
#include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chrome/common/chrome_constants.h"
@@ -147,7 +148,8 @@ void RunSwitchLanguageTest(const std::string& locale,
SwitchLanguageTestData data;
locale_util::SwitchLanguageCallback callback(
base::Bind(&OnLocaleSwitched, base::Unretained(&data)));
- locale_util::SwitchLanguage(locale, true, false, callback);
+ locale_util::SwitchLanguage(locale, true, false, callback,
+ ProfileManager::GetActiveUserProfile());
// Token writing moves control to BlockingPool and back.
content::RunAllBlockingPoolTasksUntilIdle();
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index f1767ec..e352d51 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -475,11 +475,11 @@ ProfileImpl::ProfileImpl(
// (successfully or not). Note that we can use base::Unretained
// because the PrefService is owned by this class and lives on
// the same thread.
- prefs_->AddPrefInitObserver(base::Bind(&ProfileImpl::OnPrefsLoaded,
- base::Unretained(this)));
+ prefs_->AddPrefInitObserver(base::Bind(
+ &ProfileImpl::OnPrefsLoaded, base::Unretained(this), create_mode));
} else {
// Prefs were loaded synchronously so we can continue directly.
- OnPrefsLoaded(true);
+ OnPrefsLoaded(create_mode, true);
}
}
@@ -802,15 +802,9 @@ ExtensionSpecialStoragePolicy*
#endif
}
-void ProfileImpl::OnPrefsLoaded(bool success) {
- TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded");
- SCOPED_UMA_HISTOGRAM_TIMER("Profile.OnPrefsLoadedTime");
- if (!success) {
- if (delegate_)
- delegate_->OnProfileCreated(this, false, false);
- return;
- }
-
+void ProfileImpl::OnLocaleReady() {
+ TRACE_EVENT0("browser", "ProfileImpl::OnLocaleReady");
+ SCOPED_UMA_HISTOGRAM_TIMER("Profile.OnLocaleReadyTime");
// Migrate obsolete prefs.
if (g_browser_process->local_state())
chrome::MigrateObsoleteBrowserPrefs(this, g_browser_process->local_state());
@@ -861,6 +855,28 @@ void ProfileImpl::OnPrefsLoaded(bool success) {
DoFinalInit();
}
+void ProfileImpl::OnPrefsLoaded(CreateMode create_mode, bool success) {
+ TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded");
+ if (!success) {
+ if (delegate_)
+ delegate_->OnProfileCreated(this, false, false);
+ return;
+ }
+
+#if defined(OS_CHROMEOS)
+ if (create_mode == CREATE_MODE_SYNCHRONOUS) {
+ // Synchronous create mode implies that either it is restart after crash,
+ // or we are in tests. In both cases the first loaded locale is correct.
+ OnLocaleReady();
+ } else {
+ chromeos::UserSessionManager::GetInstance()->RespectLocalePreferenceWrapper(
+ this, base::Bind(&ProfileImpl::OnLocaleReady, base::Unretained(this)));
+ }
+#else
+ OnLocaleReady();
+#endif
+}
+
bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) {
Version profile_version(ChromeVersionService::GetVersion(prefs_.get()));
Version arg_version(version);
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 3765fc2..2d58c93 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -165,8 +165,11 @@ class ProfileImpl : public Profile {
// Does final initialization. Should be called after prefs were loaded.
void DoFinalInit();
+ // Switch locale (when possible) and proceed to OnLocaleReady().
+ void OnPrefsLoaded(CreateMode create_mode, bool success);
+
// Does final prefs initialization and calls Init().
- void OnPrefsLoaded(bool success);
+ void OnLocaleReady();
#if defined(ENABLE_SESSION_SERVICE)
void StopCreateSessionServiceTimer();
diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
index c70275f..28c6c48 100644
--- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
@@ -1233,6 +1233,7 @@ void SystemTrayDelegateChromeOS::UpdatePerformanceTracing() {
// Overridden from InputMethodManager::Observer.
void SystemTrayDelegateChromeOS::InputMethodChanged(
input_method::InputMethodManager* manager,
+ Profile* /* profile */,
bool show_message) {
GetSystemTrayNotifier()->NotifyRefreshIME();
}
diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.h b/chrome/browser/ui/ash/system_tray_delegate_chromeos.h
index 167e3f4..cf9bcee 100644
--- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.h
+++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.h
@@ -213,6 +213,7 @@ class SystemTrayDelegateChromeOS
// Overridden from InputMethodManager::Observer.
void InputMethodChanged(input_method::InputMethodManager* manager,
+ Profile* profile,
bool show_message) override;
// Overridden from InputMethodMenuManager::Observer.
diff --git a/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc
index 8764bfd..51a1634 100644
--- a/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc
@@ -105,7 +105,7 @@ void TermsOfServiceScreenHandler::Show() {
locale_util::SwitchLanguage(locale,
true, // enable_locale_keyboard_layouts
false, // login_layouts_only
- callback);
+ callback, ProfileManager::GetActiveUserProfile());
}
void TermsOfServiceScreenHandler::Hide() {
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index d0c7d3f7..c65963a 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -31274,7 +31274,18 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>
+<histogram name="Profile.OnLocaleReadyTime" units="milliseconds">
+ <owner>rkaplow@chromium.org</owner>
+ <summary>
+ The amount of time that elapsed during ProfileImpl::OnLocaleReady. This
+ happens once after profile was loaded.
+ </summary>
+</histogram>
+
<histogram name="Profile.OnPrefsLoadedTime" units="milliseconds">
+ <obsolete>
+ Deprecated 04/2015, and replaced by Profile.OnLocaleReadyTime.
+ </obsolete>
<owner>rkaplow@chromium.org</owner>
<summary>
The amount of time that elapsed during ProfileImpl::OnPrefsLoaded.
diff --git a/ui/base/ime/chromeos/input_method_manager.h b/ui/base/ime/chromeos/input_method_manager.h
index a7eb3a9..0b903df 100644
--- a/ui/base/ime/chromeos/input_method_manager.h
+++ b/ui/base/ime/chromeos/input_method_manager.h
@@ -49,6 +49,7 @@ class UI_BASE_IME_EXPORT InputMethodManager {
// Called when the current input method is changed. |show_message|
// indicates whether the user should be notified of this change.
virtual void InputMethodChanged(InputMethodManager* manager,
+ Profile* profile,
bool show_message) = 0;
};