diff --git a/ui/base/ime/input_method_auralinux.cc b/ui/base/ime/input_method_auralinux.cc index ca9931f06f777..0b65ec31dc51b 100644 --- a/ui/base/ime/input_method_auralinux.cc +++ b/ui/base/ime/input_method_auralinux.cc @@ -45,7 +45,6 @@ bool InputMethodAuraLinux::OnUntranslatedIMEMessage( void InputMethodAuraLinux::DispatchKeyEvent(ui::KeyEvent* event) { DCHECK(event->type() == ET_KEY_PRESSED || event->type() == ET_KEY_RELEASED); - DCHECK(system_toplevel_window_focused()); // If no text input client, do nothing. if (!GetTextInputClient()) { diff --git a/ui/base/ime/input_method_base.cc b/ui/base/ime/input_method_base.cc index 3441f928b90ac..df0cb118e5352 100644 --- a/ui/base/ime/input_method_base.cc +++ b/ui/base/ime/input_method_base.cc @@ -16,8 +16,7 @@ namespace ui { InputMethodBase::InputMethodBase() : delegate_(NULL), - text_input_client_(NULL), - system_toplevel_window_focused_(false) { + text_input_client_(NULL) { } InputMethodBase::~InputMethodBase() { @@ -30,13 +29,9 @@ void InputMethodBase::SetDelegate(internal::InputMethodDelegate* delegate) { delegate_ = delegate; } -void InputMethodBase::OnFocus() { - system_toplevel_window_focused_ = true; -} +void InputMethodBase::OnFocus() {} -void InputMethodBase::OnBlur() { - system_toplevel_window_focused_ = false; -} +void InputMethodBase::OnBlur() {} void InputMethodBase::SetFocusedTextInputClient(TextInputClient* client) { SetFocusedTextInputClientInternal(client); @@ -49,7 +44,7 @@ void InputMethodBase::DetachTextInputClient(TextInputClient* client) { } TextInputClient* InputMethodBase::GetTextInputClient() const { - return system_toplevel_window_focused_ ? text_input_client_ : NULL; + return text_input_client_; } void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { diff --git a/ui/base/ime/input_method_base.h b/ui/base/ime/input_method_base.h index e9efb3a29b9fe..e33461138f7a8 100644 --- a/ui/base/ime/input_method_base.h +++ b/ui/base/ime/input_method_base.h @@ -34,9 +34,6 @@ class UI_BASE_IME_EXPORT InputMethodBase // Overriden from InputMethod. void SetDelegate(internal::InputMethodDelegate* delegate) override; - // If a derived class overrides OnFocus()/OnBlur(), it should call parent's - // implementation first, to make sure |system_toplevel_window_focused_| flag - // can be updated correctly. void OnFocus() override; void OnBlur() override; void SetFocusedTextInputClient(TextInputClient* client) override; @@ -87,10 +84,6 @@ class UI_BASE_IME_EXPORT InputMethodBase // |client| which is the text input client with focus. void NotifyTextInputCaretBoundsChanged(const TextInputClient* client); - bool system_toplevel_window_focused() const { - return system_toplevel_window_focused_; - } - private: void SetFocusedTextInputClientInternal(TextInputClient* client); @@ -99,8 +92,6 @@ class UI_BASE_IME_EXPORT InputMethodBase base::ObserverList observer_list_; - bool system_toplevel_window_focused_; - DISALLOW_COPY_AND_ASSIGN(InputMethodBase); }; diff --git a/ui/base/ime/input_method_chromeos.cc b/ui/base/ime/input_method_chromeos.cc index 8062a3c6d8c53..59077b451f004 100644 --- a/ui/base/ime/input_method_chromeos.cc +++ b/ui/base/ime/input_method_chromeos.cc @@ -98,7 +98,6 @@ void InputMethodChromeOS::ProcessKeyEventDone(ui::KeyEvent* event, void InputMethodChromeOS::DispatchKeyEvent(ui::KeyEvent* event) { DCHECK(event->IsKeyEvent()); DCHECK(!(event->flags() & ui::EF_IS_SYNTHESIZED)); - DCHECK(system_toplevel_window_focused()); // For linux_chromeos, the ime keyboard cannot track the caps lock state by // itself, so need to call SetCapsLockEnabled() method to reflect the caps @@ -301,8 +300,6 @@ void InputMethodChromeOS::ResetContext() { if (!IsNonPasswordInputFieldFocused() || !GetTextInputClient()) return; - DCHECK(system_toplevel_window_focused()); - composition_.Clear(); result_text_.clear(); composing_text_ = false; diff --git a/ui/base/ime/input_method_chromeos_unittest.cc b/ui/base/ime/input_method_chromeos_unittest.cc index 40677ea4db6d0..d60d99ec038bf 100644 --- a/ui/base/ime/input_method_chromeos_unittest.cc +++ b/ui/base/ime/input_method_chromeos_unittest.cc @@ -390,32 +390,6 @@ TEST_F(InputMethodChromeOSTest, GetInputTextType_WithoutFocusedClient) { EXPECT_EQ(TEXT_INPUT_TYPE_PASSWORD, ime_->GetTextInputType()); } -TEST_F(InputMethodChromeOSTest, GetInputTextType_WithoutFocusedWindow) { - ime_->OnFocus(); - EXPECT_EQ(TEXT_INPUT_TYPE_NONE, ime_->GetTextInputType()); - ime_->OnBlur(); - input_type_ = TEXT_INPUT_TYPE_PASSWORD; - ime_->OnTextInputTypeChanged(this); - // The OnTextInputTypeChanged() call above should be ignored since the top- - // level window which the ime_ is attached to is not currently focused. - EXPECT_EQ(TEXT_INPUT_TYPE_NONE, ime_->GetTextInputType()); - - ime_->OnFocus(); - ime_->OnTextInputTypeChanged(this); - EXPECT_EQ(TEXT_INPUT_TYPE_PASSWORD, ime_->GetTextInputType()); -} - -TEST_F(InputMethodChromeOSTest, GetInputTextType_WithoutFocusedWindow2) { - EXPECT_EQ(TEXT_INPUT_TYPE_NONE, ime_->GetTextInputType()); - input_type_ = TEXT_INPUT_TYPE_PASSWORD; - ime_->OnTextInputTypeChanged(this); - EXPECT_EQ(TEXT_INPUT_TYPE_NONE, ime_->GetTextInputType()); - - ime_->OnFocus(); - ime_->OnTextInputTypeChanged(this); - EXPECT_EQ(TEXT_INPUT_TYPE_PASSWORD, ime_->GetTextInputType()); -} - // Confirm that IBusClient::FocusIn is called on "connected" if input_type_ is // TEXT. TEST_F(InputMethodChromeOSTest, FocusIn_Text) { diff --git a/ui/base/ime/input_method_win.cc b/ui/base/ime/input_method_win.cc index 56bbac1b3244b..6604c6d31bb6a 100644 --- a/ui/base/ime/input_method_win.cc +++ b/ui/base/ime/input_method_win.cc @@ -297,15 +297,13 @@ LRESULT InputMethodWin::OnImeSetContext(HWND window_handle, BOOL* handled) { if (!!wparam) { imm32_manager_.CreateImeWindow(window_handle); - if (system_toplevel_window_focused()) { - // Delay initialize the tsf to avoid perf regression. - // Loading tsf dll causes some time, so doing it in UpdateIMEState() will - // slow down the browser window creation. - // See crbug.com/509984. - tsf_inputscope::InitializeTsfForInputScopes(); - tsf_inputscope::SetInputScopeForTsfUnawareWindow( - toplevel_window_handle_, GetTextInputType(), GetTextInputMode()); - } + // Delay initialize the tsf to avoid perf regression. + // Loading tsf dll causes some time, so doing it in UpdateIMEState() will + // slow down the browser window creation. + // See crbug.com/509984. + tsf_inputscope::InitializeTsfForInputScopes(); + tsf_inputscope::SetInputScopeForTsfUnawareWindow( + toplevel_window_handle_, GetTextInputType(), GetTextInputMode()); } OnInputMethodChanged();