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

Unified Diff: chrome/browser/chromeos/status/input_method_menu.cc

Issue 8585031: [cros, Aura] Make screen_mode static variable in StatusAreaViewChromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years, 1 month 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/status/input_method_menu.cc
diff --git a/chrome/browser/chromeos/status/input_method_menu.cc b/chrome/browser/chromeos/status/input_method_menu.cc
index 1a6771f1bb1fbc787abd874ab4352ad460787339..e0e8695de5ac6eec2db697cbd0c910c896cfd37d 100644
--- a/chrome/browser/chromeos/status/input_method_menu.cc
+++ b/chrome/browser/chromeos/status/input_method_menu.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/language_preferences.h"
+#include "chrome/browser/chromeos/status/status_area_view_chromeos.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
@@ -132,7 +133,6 @@ using input_method::InputMethodManager;
// InputMethodMenu
InputMethodMenu::InputMethodMenu(PrefService* pref_service,
- StatusAreaViewChromeos::ScreenMode screen_mode,
bool for_out_of_box_experience_dialog)
: input_method_descriptors_(InputMethodManager::GetInstance()->
GetActiveInputMethods()),
@@ -145,28 +145,32 @@ InputMethodMenu::InputMethodMenu(PrefService* pref_service,
minimum_input_method_menu_width_(0),
menu_alignment_(views::MenuItemView::TOPRIGHT),
pref_service_(pref_service),
- screen_mode_(screen_mode),
for_out_of_box_experience_dialog_(for_out_of_box_experience_dialog) {
DCHECK(input_method_descriptors_.get() &&
!input_method_descriptors_->empty());
// Sync current and previous input methods on Chrome prefs with ibus-daemon.
- if (pref_service_ && (screen_mode_ == StatusAreaViewChromeos::BROWSER_MODE)) {
- previous_input_method_pref_.Init(
- prefs::kLanguagePreviousInputMethod, pref_service, this);
- current_input_method_pref_.Init(
- prefs::kLanguageCurrentInputMethod, pref_service, this);
+ if (pref_service_ && StatusAreaViewChromeos::IsBrowserMode()) {
+ InitializePrefMembers();
}
InputMethodManager* manager = InputMethodManager::GetInstance();
- if (screen_mode_ == StatusAreaViewChromeos::LOGIN_MODE_VIEWS ||
- screen_mode_ == StatusAreaViewChromeos::LOGIN_MODE_WEBUI) {
+ if (StatusAreaViewChromeos::IsLoginMode()) {
// This button is for the login screen.
manager->AddPreLoginPreferenceObserver(this);
registrar_.Add(this,
chrome::NOTIFICATION_LOGIN_USER_CHANGED,
content::NotificationService::AllSources());
- } else if (screen_mode_ == StatusAreaViewChromeos::BROWSER_MODE) {
+#if defined(USE_AURA)
+ // On Aura status area is not recreated on sign in.
+ // In case of Chrome crash, Chrome will be reloaded but IsLoginMode() will
+ // return false at this point so NOTIFICATION_PROFILE_CREATED will be
+ // ignored and all initialization will happen in ctor.
+ registrar_.Add(this,
+ chrome::NOTIFICATION_PROFILE_CREATED,
+ content::NotificationService::AllSources());
+#endif
+ } else if (StatusAreaViewChromeos::IsBrowserMode()) {
manager->AddPostLoginPreferenceObserver(this);
}
@@ -421,15 +425,14 @@ void InputMethodMenu::PreferenceUpdateNeeded(
InputMethodManager* manager,
const input_method::InputMethodDescriptor& previous_input_method,
const input_method::InputMethodDescriptor& current_input_method) {
- if (screen_mode_ == StatusAreaViewChromeos::BROWSER_MODE) {
+ if (StatusAreaViewChromeos::IsBrowserMode()) {
if (pref_service_) { // make sure we're not in unit tests.
// Sometimes (e.g. initial boot) |previous_input_method.id()| is empty.
previous_input_method_pref_.SetValue(previous_input_method.id());
current_input_method_pref_.SetValue(current_input_method.id());
pref_service_->ScheduleSavePersistentPrefs();
}
- } else if (screen_mode_ == StatusAreaViewChromeos::LOGIN_MODE_VIEWS ||
- screen_mode_ == StatusAreaViewChromeos::LOGIN_MODE_WEBUI) {
+ } else if (StatusAreaViewChromeos::IsLoginMode()) {
if (g_browser_process && g_browser_process->local_state()) {
g_browser_process->local_state()->SetString(
language_prefs::kPreferredKeyboardLayout, current_input_method.id());
@@ -465,7 +468,7 @@ void InputMethodMenu::FirstObserverIsAdded(InputMethodManager* manager) {
// NOTICE: Since this function might be called from the constructor of this
// class, it's better to avoid calling virtual functions.
- if (pref_service_ && (screen_mode_ == StatusAreaViewChromeos::BROWSER_MODE)) {
+ if (pref_service_ && (StatusAreaViewChromeos::IsBrowserMode())) {
// Get the input method name in the Preferences file which was in use last
// time, and switch to the method. We remember two input method names in the
// preference so that the Control+space hot-key could work fine from the
@@ -712,6 +715,16 @@ void InputMethodMenu::Observe(int type,
// anymore.
RemoveObservers();
}
+#if defined(USE_AURA)
+ if (type == chrome::NOTIFICATION_PROFILE_CREATED) {
+ // On Aura status area is not recreated on login for normal user sign in.
+ // NOTIFICATION_LOGIN_USER_CHANGED has been notified early in login process.
+ InitializePrefMembers();
+ InputMethodManager* manager = InputMethodManager::GetInstance();
+ manager->AddPostLoginPreferenceObserver(this);
+ manager->AddObserver(this);
+ }
+#endif
}
void InputMethodMenu::SetMinimumWidth(int width) {
@@ -721,13 +734,19 @@ void InputMethodMenu::SetMinimumWidth(int width) {
void InputMethodMenu::RemoveObservers() {
InputMethodManager* manager = InputMethodManager::GetInstance();
- if (screen_mode_ == StatusAreaViewChromeos::LOGIN_MODE_VIEWS ||
- screen_mode_ == StatusAreaViewChromeos::LOGIN_MODE_WEBUI) {
+ if (StatusAreaViewChromeos::IsLoginMode()) {
manager->RemovePreLoginPreferenceObserver(this);
- } else if (screen_mode_ == StatusAreaViewChromeos::BROWSER_MODE) {
+ } else if (StatusAreaViewChromeos::IsBrowserMode()) {
manager->RemovePostLoginPreferenceObserver(this);
}
manager->RemoveObserver(this);
}
+void InputMethodMenu::InitializePrefMembers() {
+ previous_input_method_pref_.Init(
+ prefs::kLanguagePreviousInputMethod, pref_service_, this);
+ current_input_method_pref_.Init(
+ prefs::kLanguageCurrentInputMethod, pref_service_, this);
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/status/input_method_menu.h ('k') | chrome/browser/chromeos/status/input_method_menu_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698