| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/ime/input_method_chromeos.h" | 5 #include "ui/base/ime/input_method_chromeos.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 chromeos::IMEBridge::Get()->SetInputContextHandler(this); | 43 chromeos::IMEBridge::Get()->SetInputContextHandler(this); |
| 44 | 44 |
| 45 UpdateContextFocusState(); | 45 UpdateContextFocusState(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 InputMethodChromeOS::~InputMethodChromeOS() { | 48 InputMethodChromeOS::~InputMethodChromeOS() { |
| 49 ConfirmCompositionText(); | 49 ConfirmCompositionText(); |
| 50 // We are dead, so we need to ask the client to stop relying on us. | 50 // We are dead, so we need to ask the client to stop relying on us. |
| 51 OnInputMethodChanged(); | 51 OnInputMethodChanged(); |
| 52 | 52 |
| 53 chromeos::IMEBridge::Get()->SetInputContextHandler(NULL); | 53 if (chromeos::IMEBridge::Get()) |
| 54 chromeos::IMEBridge::Get()->SetInputContextHandler(NULL); |
| 54 } | 55 } |
| 55 | 56 |
| 56 void InputMethodChromeOS::OnFocus() { | 57 void InputMethodChromeOS::OnFocus() { |
| 57 InputMethodBase::OnFocus(); | 58 InputMethodBase::OnFocus(); |
| 58 OnTextInputTypeChanged(GetTextInputClient()); | 59 OnTextInputTypeChanged(GetTextInputClient()); |
| 59 } | 60 } |
| 60 | 61 |
| 61 void InputMethodChromeOS::OnBlur() { | 62 void InputMethodChromeOS::OnBlur() { |
| 62 ConfirmCompositionText(); | 63 ConfirmCompositionText(); |
| 63 InputMethodBase::OnBlur(); | 64 InputMethodBase::OnBlur(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 85 } | 86 } |
| 86 } | 87 } |
| 87 | 88 |
| 88 if (event->type() == ET_KEY_PRESSED || event->type() == ET_KEY_RELEASED) | 89 if (event->type() == ET_KEY_PRESSED || event->type() == ET_KEY_RELEASED) |
| 89 ProcessKeyEventPostIME(*event, is_handled); | 90 ProcessKeyEventPostIME(*event, is_handled); |
| 90 | 91 |
| 91 handling_key_event_ = false; | 92 handling_key_event_ = false; |
| 92 } | 93 } |
| 93 | 94 |
| 94 bool InputMethodChromeOS::DispatchKeyEvent(const ui::KeyEvent& event) { | 95 bool InputMethodChromeOS::DispatchKeyEvent(const ui::KeyEvent& event) { |
| 95 DCHECK(event.type() == ET_KEY_PRESSED || event.type() == ET_KEY_RELEASED); | 96 DCHECK(event.IsKeyEvent()); |
| 96 DCHECK(system_toplevel_window_focused()); | 97 DCHECK(system_toplevel_window_focused()); |
| 97 | 98 |
| 98 // For linux_chromeos, the ime keyboard cannot track the caps lock state by | 99 // For linux_chromeos, the ime keyboard cannot track the caps lock state by |
| 99 // itself, so need to call SetCapsLockEnabled() method to reflect the caps | 100 // itself, so need to call SetCapsLockEnabled() method to reflect the caps |
| 100 // lock state by the key event. | 101 // lock state by the key event. |
| 101 if (!base::SysInfo::IsRunningOnChromeOS()) { | 102 if (!base::SysInfo::IsRunningOnChromeOS()) { |
| 102 chromeos::input_method::InputMethodManager* manager = | 103 chromeos::input_method::InputMethodManager* manager = |
| 103 chromeos::input_method::InputMethodManager::Get(); | 104 chromeos::input_method::InputMethodManager::Get(); |
| 104 if (manager) { | 105 if (manager) { |
| 105 chromeos::input_method::ImeKeyboard* keyboard = manager->GetImeKeyboard(); | 106 chromeos::input_method::ImeKeyboard* keyboard = manager->GetImeKeyboard(); |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { | 664 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { |
| 664 TextInputType type = GetTextInputType(); | 665 TextInputType type = GetTextInputType(); |
| 665 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); | 666 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); |
| 666 } | 667 } |
| 667 | 668 |
| 668 bool InputMethodChromeOS::IsInputFieldFocused() { | 669 bool InputMethodChromeOS::IsInputFieldFocused() { |
| 669 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; | 670 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; |
| 670 } | 671 } |
| 671 | 672 |
| 672 } // namespace ui | 673 } // namespace ui |
| OLD | NEW |