| 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 #ifndef UI_BASE_IME_INPUT_METHOD_CHROMEOS_H_ | 5 #ifndef UI_BASE_IME_INPUT_METHOD_CHROMEOS_H_ |
| 6 #define UI_BASE_IME_INPUT_METHOD_CHROMEOS_H_ | 6 #define UI_BASE_IME_INPUT_METHOD_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 public chromeos::IMEInputContextHandlerInterface { | 25 public chromeos::IMEInputContextHandlerInterface { |
| 26 public: | 26 public: |
| 27 explicit InputMethodChromeOS(internal::InputMethodDelegate* delegate); | 27 explicit InputMethodChromeOS(internal::InputMethodDelegate* delegate); |
| 28 ~InputMethodChromeOS() override; | 28 ~InputMethodChromeOS() override; |
| 29 | 29 |
| 30 // Overridden from InputMethod: | 30 // Overridden from InputMethod: |
| 31 void OnFocus() override; | 31 void OnFocus() override; |
| 32 void OnBlur() override; | 32 void OnBlur() override; |
| 33 bool OnUntranslatedIMEMessage(const base::NativeEvent& event, | 33 bool OnUntranslatedIMEMessage(const base::NativeEvent& event, |
| 34 NativeEventResult* result) override; | 34 NativeEventResult* result) override; |
| 35 bool DispatchKeyEvent(const ui::KeyEvent& event) override; | 35 void DispatchKeyEvent(ui::KeyEvent* event) override; |
| 36 void OnTextInputTypeChanged(const TextInputClient* client) override; | 36 void OnTextInputTypeChanged(const TextInputClient* client) override; |
| 37 void OnCaretBoundsChanged(const TextInputClient* client) override; | 37 void OnCaretBoundsChanged(const TextInputClient* client) override; |
| 38 void CancelComposition(const TextInputClient* client) override; | 38 void CancelComposition(const TextInputClient* client) override; |
| 39 void OnInputLocaleChanged() override; | 39 void OnInputLocaleChanged() override; |
| 40 std::string GetInputLocale() override; | 40 std::string GetInputLocale() override; |
| 41 bool IsCandidatePopupOpen() const override; | 41 bool IsCandidatePopupOpen() const override; |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 // Converts |text| into CompositionText. | 44 // Converts |text| into CompositionText. |
| 45 void ExtractCompositionText(const chromeos::CompositionText& text, | 45 void ExtractCompositionText(const chromeos::CompositionText& text, |
| 46 uint32 cursor_position, | 46 uint32 cursor_position, |
| 47 CompositionText* out_composition) const; | 47 CompositionText* out_composition) const; |
| 48 | 48 |
| 49 // Process a key returned from the input method. | 49 // Process a key returned from the input method. |
| 50 virtual void ProcessKeyEventPostIME(const ui::KeyEvent& event, | 50 virtual void ProcessKeyEventPostIME(ui::KeyEvent* event, |
| 51 bool handled); | 51 bool handled); |
| 52 | 52 |
| 53 // Resets context and abandon all pending results and key events. | 53 // Resets context and abandon all pending results and key events. |
| 54 void ResetContext(); | 54 void ResetContext(); |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 class PendingKeyEvent; | 57 class PendingKeyEvent; |
| 58 | 58 |
| 59 // Overridden from InputMethodBase: | 59 // Overridden from InputMethodBase: |
| 60 void OnWillChangeFocusedClient(TextInputClient* focused_before, | 60 void OnWillChangeFocusedClient(TextInputClient* focused_before, |
| 61 TextInputClient* focused) override; | 61 TextInputClient* focused) override; |
| 62 void OnDidChangeFocusedClient(TextInputClient* focused_before, | 62 void OnDidChangeFocusedClient(TextInputClient* focused_before, |
| 63 TextInputClient* focused) override; | 63 TextInputClient* focused) override; |
| 64 | 64 |
| 65 // Asks the client to confirm current composition text. | 65 // Asks the client to confirm current composition text. |
| 66 void ConfirmCompositionText(); | 66 void ConfirmCompositionText(); |
| 67 | 67 |
| 68 // Checks the availability of focused text input client and update focus | 68 // Checks the availability of focused text input client and update focus |
| 69 // state. | 69 // state. |
| 70 void UpdateContextFocusState(); | 70 void UpdateContextFocusState(); |
| 71 | 71 |
| 72 // Processes a key event that was already filtered by the input method. | 72 // Processes a key event that was already filtered by the input method. |
| 73 // A VKEY_PROCESSKEY may be dispatched to the EventTargets. | 73 // A VKEY_PROCESSKEY may be dispatched to the EventTargets. |
| 74 // It returns the result of whether the event has been stopped propagation | 74 // It returns the result of whether the event has been stopped propagation |
| 75 // when dispatching post IME. | 75 // when dispatching post IME. |
| 76 bool ProcessFilteredKeyPressEvent(const ui::KeyEvent& event); | 76 void ProcessFilteredKeyPressEvent(ui::KeyEvent* event); |
| 77 | 77 |
| 78 // Processes a key event that was not filtered by the input method. | 78 // Processes a key event that was not filtered by the input method. |
| 79 void ProcessUnfilteredKeyPressEvent(const ui::KeyEvent& event); | 79 void ProcessUnfilteredKeyPressEvent(ui::KeyEvent* event); |
| 80 | 80 |
| 81 // Sends input method result caused by the given key event to the focused text | 81 // Sends input method result caused by the given key event to the focused text |
| 82 // input client. | 82 // input client. |
| 83 void ProcessInputMethodResult(const ui::KeyEvent& event, bool filtered); | 83 void ProcessInputMethodResult(ui::KeyEvent* event, bool filtered); |
| 84 | 84 |
| 85 // Checks if the pending input method result needs inserting into the focused | 85 // Checks if the pending input method result needs inserting into the focused |
| 86 // text input client as a single character. | 86 // text input client as a single character. |
| 87 bool NeedInsertChar() const; | 87 bool NeedInsertChar() const; |
| 88 | 88 |
| 89 // Checks if there is pending input method result. | 89 // Checks if there is pending input method result. |
| 90 bool HasInputMethodResult() const; | 90 bool HasInputMethodResult() const; |
| 91 | 91 |
| 92 // Sends a fake key event for IME composing without physical key events. | 92 // Sends a fake key event for IME composing without physical key events. |
| 93 void SendFakeProcessKeyEvent(bool pressed) const; | 93 // Returns true if the faked key event is stopped propagation. |
| 94 bool SendFakeProcessKeyEvent(bool pressed) const; |
| 94 | 95 |
| 95 // Passes keyevent and executes character composition if necessary. Returns | 96 // Passes keyevent and executes character composition if necessary. Returns |
| 96 // true if character composer comsumes key event. | 97 // true if character composer comsumes key event. |
| 97 bool ExecuteCharacterComposer(const ui::KeyEvent& event); | 98 bool ExecuteCharacterComposer(const ui::KeyEvent& event); |
| 98 | 99 |
| 99 // chromeos::IMEInputContextHandlerInterface overrides: | 100 // chromeos::IMEInputContextHandlerInterface overrides: |
| 100 void CommitText(const std::string& text) override; | 101 void CommitText(const std::string& text) override; |
| 101 void UpdateCompositionText(const chromeos::CompositionText& text, | 102 void UpdateCompositionText(const chromeos::CompositionText& text, |
| 102 uint32 cursor_pos, | 103 uint32 cursor_pos, |
| 103 bool visible) override; | 104 bool visible) override; |
| 104 void DeleteSurroundingText(int32 offset, uint32 length) override; | 105 void DeleteSurroundingText(int32 offset, uint32 length) override; |
| 105 | 106 |
| 106 // Hides the composition text. | 107 // Hides the composition text. |
| 107 void HidePreeditText(); | 108 void HidePreeditText(); |
| 108 | 109 |
| 109 // Callback function for IMEEngineHandlerInterface::ProcessKeyEvent. | 110 // Callback function for IMEEngineHandlerInterface::ProcessKeyEvent. |
| 110 void ProcessKeyEventDone(const ui::KeyEvent* event, bool is_handled); | 111 void ProcessKeyEventDone(ui::KeyEvent* event, bool is_handled); |
| 111 | 112 |
| 112 // Returns whether an non-password input field is focused. | 113 // Returns whether an non-password input field is focused. |
| 113 bool IsNonPasswordInputFieldFocused(); | 114 bool IsNonPasswordInputFieldFocused(); |
| 114 | 115 |
| 115 // Returns true if an text input field is focused. | 116 // Returns true if an text input field is focused. |
| 116 bool IsInputFieldFocused(); | 117 bool IsInputFieldFocused(); |
| 117 | 118 |
| 118 // Pending composition text generated by the current pending key event. | 119 // Pending composition text generated by the current pending key event. |
| 119 // It'll be sent to the focused text input client as soon as we receive the | 120 // It'll be sent to the focused text input client as soon as we receive the |
| 120 // processing result of the pending key event. | 121 // processing result of the pending key event. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 144 | 145 |
| 145 // Used for making callbacks. | 146 // Used for making callbacks. |
| 146 base::WeakPtrFactory<InputMethodChromeOS> weak_ptr_factory_; | 147 base::WeakPtrFactory<InputMethodChromeOS> weak_ptr_factory_; |
| 147 | 148 |
| 148 DISALLOW_COPY_AND_ASSIGN(InputMethodChromeOS); | 149 DISALLOW_COPY_AND_ASSIGN(InputMethodChromeOS); |
| 149 }; | 150 }; |
| 150 | 151 |
| 151 } // namespace ui | 152 } // namespace ui |
| 152 | 153 |
| 153 #endif // UI_BASE_IME_INPUT_METHOD_CHROMEOS_H_ | 154 #endif // UI_BASE_IME_INPUT_METHOD_CHROMEOS_H_ |
| OLD | NEW |