diff options
5 files changed, 42 insertions, 19 deletions
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 4d19aa1..40a6775 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc @@ -852,7 +852,8 @@ InputMethodManagerImpl::InputMethodManagerImpl( state_(NULL), util_(delegate_.get()), component_extension_ime_manager_(new ComponentExtensionIMEManager()), - enable_extension_loading_(enable_extension_loading) { + enable_extension_loading_(enable_extension_loading), + is_ime_menu_activated_(false) { if (base::SysInfo::IsRunningOnChromeOS()) keyboard_.reset(ImeKeyboard::Create()); else @@ -865,11 +866,13 @@ InputMethodManagerImpl::InputMethodManagerImpl( const InputMethodDescriptors& descriptors = component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor(); util_.ResetInputMethods(descriptors); + chromeos::UserAddingScreen::Get()->AddObserver(this); } InputMethodManagerImpl::~InputMethodManagerImpl() { if (candidate_window_controller_.get()) candidate_window_controller_->RemoveObserver(this); + chromeos::UserAddingScreen::Get()->RemoveObserver(this); } void InputMethodManagerImpl::RecordInputMethodUsage( @@ -917,21 +920,29 @@ InputMethodManager::UISessionState InputMethodManagerImpl::GetUISessionState() { void InputMethodManagerImpl::SetUISessionState(UISessionState new_ui_session) { ui_session_ = new_ui_session; - switch (ui_session_) { - case STATE_LOGIN_SCREEN: - break; - case STATE_BROWSER_SCREEN: - break; - case STATE_LOCK_SCREEN: - break; - case STATE_TERMINATING: { - if (candidate_window_controller_.get()) - candidate_window_controller_.reset(); - break; - } + if (ui_session_ == STATE_TERMINATING && candidate_window_controller_.get()) + candidate_window_controller_.reset(); + + // The expanded IME menu is only supportive with 'normal' screen type. It + // should be deactivated when the screen type is not 'normal', and be + // re-activated when changing back. + if (is_ime_menu_activated_ && ui_session_ != STATE_TERMINATING) { + FOR_EACH_OBSERVER( + InputMethodManager::ImeMenuObserver, ime_menu_observers_, + ImeMenuActivationChanged(ui_session_ == STATE_BROWSER_SCREEN)); } } +void InputMethodManagerImpl::OnUserAddingStarted() { + if (ui_session_ == STATE_BROWSER_SCREEN) + SetUISessionState(STATE_SECONDARY_LOGIN_SCREEN); +} + +void InputMethodManagerImpl::OnUserAddingFinished() { + if (ui_session_ == STATE_SECONDARY_LOGIN_SCREEN) + SetUISessionState(STATE_BROWSER_SCREEN); +} + scoped_ptr<InputMethodDescriptors> InputMethodManagerImpl::GetSupportedInputMethods() const { return scoped_ptr<InputMethodDescriptors>(new InputMethodDescriptors); @@ -1168,6 +1179,9 @@ void InputMethodManagerImpl::CandidateWindowClosed() { } void InputMethodManagerImpl::ImeMenuActivationChanged(bool is_active) { + // Saves the state that whether the expanded IME menu has been activated by + // users. This method is only called when the preference is changing. + is_ime_menu_activated_ = is_active; FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, ImeMenuActivationChanged(is_active)); } 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 e04d46e..0142001 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.h +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.h @@ -17,6 +17,7 @@ #include "base/threading/thread_checker.h" #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" #include "chrome/browser/chromeos/input_method/input_method_util.h" +#include "chrome/browser/chromeos/login/ui/user_adding_screen.h" #include "chrome/browser/profiles/profile.h" #include "ui/base/ime/chromeos/input_method_manager.h" #include "ui/base/ime/chromeos/input_method_whitelist.h" @@ -36,7 +37,8 @@ class ImeKeyboard; // The implementation of InputMethodManager. class InputMethodManagerImpl : public InputMethodManager, - public CandidateWindowController::Observer { + public CandidateWindowController::Observer, + public UserAddingScreen::Observer { public: class StateImpl : public InputMethodManager::State { public: @@ -168,6 +170,10 @@ class InputMethodManagerImpl : public InputMethodManager, const std::string& engine_id, const std::vector<InputMethodManager::MenuItem>& items) override; + // chromeos::UserAddingScreen: + void OnUserAddingStarted() override; + void OnUserAddingFinished() override; + ImeKeyboard* GetImeKeyboard() override; InputMethodUtil* GetInputMethodUtil() override; ComponentExtensionIMEManager* GetComponentExtensionIMEManager() override; @@ -272,10 +278,12 @@ class InputMethodManagerImpl : public InputMethodManager, // auto-repeat interval. scoped_ptr<ImeKeyboard> keyboard_; - // Whether load IME extensions. bool enable_extension_loading_; + // Whether the expanded IME menu is activated. + bool is_ime_menu_activated_; + // The engine map from extension_id to an engine. typedef std::map<std::string, ui::IMEEngineHandlerInterface*> EngineMap; typedef std::map<Profile*, EngineMap, ProfileCompare> ProfileEngineMap; diff --git a/chrome/browser/chromeos/input_method/input_method_persistence.cc b/chrome/browser/chromeos/input_method/input_method_persistence.cc index 9c7f8ed..0c0e589 100644 --- a/chrome/browser/chromeos/input_method/input_method_persistence.cc +++ b/chrome/browser/chromeos/input_method/input_method_persistence.cc @@ -139,6 +139,7 @@ void InputMethodPersistence::InputMethodChanged(InputMethodManager* manager, PersistUserInputMethod(current_input_method, manager, profile); return; case InputMethodManager::STATE_LOCK_SCREEN: + case InputMethodManager::STATE_SECONDARY_LOGIN_SCREEN: // We use a special set of input methods on the screen. Do not update. return; case InputMethodManager::STATE_TERMINATING: diff --git a/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc b/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc index a18da03..2a6b959 100644 --- a/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc +++ b/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc @@ -11,7 +11,6 @@ #include "chrome/browser/chromeos/input_method/input_method_engine.h" #include "chrome/browser/chromeos/login/lock/screen_locker.h" #include "chrome/browser/chromeos/login/session/user_session_manager.h" -#include "chrome/browser/chromeos/login/ui/user_adding_screen.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile_manager.h" @@ -232,10 +231,10 @@ class ImeObserverChromeOS : public ui::ImeObserver { return "login"; case chromeos::input_method::InputMethodManager::STATE_LOCK_SCREEN: return "lock"; + case chromeos::input_method::InputMethodManager:: + STATE_SECONDARY_LOGIN_SCREEN: + return "secondary-login"; case chromeos::input_method::InputMethodManager::STATE_BROWSER_SCREEN: - return chromeos::UserAddingScreen::Get()->IsRunning() - ? "secondary-login" - : "normal"; case chromeos::input_method::InputMethodManager::STATE_TERMINATING: return "normal"; } diff --git a/ui/base/ime/chromeos/input_method_manager.h b/ui/base/ime/chromeos/input_method_manager.h index 98480f3..e43e482 100644 --- a/ui/base/ime/chromeos/input_method_manager.h +++ b/ui/base/ime/chromeos/input_method_manager.h @@ -42,6 +42,7 @@ class UI_BASE_IME_EXPORT InputMethodManager { STATE_LOGIN_SCREEN = 0, STATE_BROWSER_SCREEN, STATE_LOCK_SCREEN, + STATE_SECONDARY_LOGIN_SCREEN, STATE_TERMINATING, }; |
