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

Side by Side Diff: ui/base/ime/input_method_base.h

Issue 1657593007: Implement chrome.input.ime.setComposition/commitText API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « ui/base/ime/input_method_auralinux.cc ('k') | ui/base/ime/input_method_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BASE_H_ 5 #ifndef UI_BASE_IME_INPUT_METHOD_BASE_H_
6 #define UI_BASE_IME_INPUT_METHOD_BASE_H_ 6 #define UI_BASE_IME_INPUT_METHOD_BASE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "ui/base/ime/ime_input_context_handler_interface.h"
14 #include "ui/base/ime/input_method.h" 15 #include "ui/base/ime/input_method.h"
15 #include "ui/base/ime/ui_base_ime_export.h" 16 #include "ui/base/ime/ui_base_ime_export.h"
16 #include "ui/events/event_dispatcher.h" 17 #include "ui/events/event_dispatcher.h"
17 18
18 namespace gfx { 19 namespace gfx {
19 class Rect; 20 class Rect;
20 } // namespace gfx 21 } // namespace gfx
21 22
22 namespace ui { 23 namespace ui {
23 24
24 class InputMethodObserver; 25 class InputMethodObserver;
25 class KeyEvent; 26 class KeyEvent;
26 class TextInputClient; 27 class TextInputClient;
27 28
28 // A helper class providing functionalities shared among ui::InputMethod 29 // A helper class providing functionalities shared among ui::InputMethod
29 // implementations. 30 // implementations.
30 class UI_BASE_IME_EXPORT InputMethodBase 31 class UI_BASE_IME_EXPORT InputMethodBase
31 : NON_EXPORTED_BASE(public InputMethod), 32 : NON_EXPORTED_BASE(public InputMethod),
32 public base::SupportsWeakPtr<InputMethodBase> { 33 public base::SupportsWeakPtr<InputMethodBase>,
34 public IMEInputContextHandlerInterface {
33 public: 35 public:
34 InputMethodBase(); 36 InputMethodBase();
35 ~InputMethodBase() override; 37 ~InputMethodBase() override;
36 38
37 // Overriden from InputMethod. 39 // Overriden from InputMethod.
38 void SetDelegate(internal::InputMethodDelegate* delegate) override; 40 void SetDelegate(internal::InputMethodDelegate* delegate) override;
39 void OnFocus() override; 41 void OnFocus() override;
40 void OnBlur() override; 42 void OnBlur() override;
41 void SetFocusedTextInputClient(TextInputClient* client) override; 43 void SetFocusedTextInputClient(TextInputClient* client) override;
42 void DetachTextInputClient(TextInputClient* client) override; 44 void DetachTextInputClient(TextInputClient* client) override;
(...skipping 11 matching lines...) Expand all
54 56
55 void AddObserver(InputMethodObserver* observer) override; 57 void AddObserver(InputMethodObserver* observer) override;
56 void RemoveObserver(InputMethodObserver* observer) override; 58 void RemoveObserver(InputMethodObserver* observer) override;
57 59
58 protected: 60 protected:
59 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, 61 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before,
60 TextInputClient* focused) {} 62 TextInputClient* focused) {}
61 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, 63 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before,
62 TextInputClient* focused) {} 64 TextInputClient* focused) {}
63 65
66 // IMEInputContextHandlerInterface:
67 void CommitText(const std::string& text) override;
68 void UpdateCompositionText(const CompositionText& text,
69 uint32_t cursor_pos,
70 bool visible) override;
71 void DeleteSurroundingText(int32_t offset, uint32_t length) override;
72
73 // Sends a fake key event for IME composing without physical key events.
74 // Returns true if the faked key event is stopped propagation.
75 bool SendFakeProcessKeyEvent(bool pressed) const;
76
64 // Returns true if |client| is currently focused. 77 // Returns true if |client| is currently focused.
65 bool IsTextInputClientFocused(const TextInputClient* client); 78 bool IsTextInputClientFocused(const TextInputClient* client);
66 79
67 // Checks if the focused text input client's text input type is 80 // Checks if the focused text input client's text input type is
68 // TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text 81 // TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text
69 // input client. 82 // input client.
70 bool IsTextInputTypeNone() const; 83 bool IsTextInputTypeNone() const;
71 84
72 // Convenience method to call the focused text input client's 85 // Convenience method to call the focused text input client's
73 // OnInputMethodChanged() method. It'll only take effect if the current text 86 // OnInputMethodChanged() method. It'll only take effect if the current text
74 // input type is not TEXT_INPUT_TYPE_NONE. 87 // input type is not TEXT_INPUT_TYPE_NONE.
75 void OnInputMethodChanged() const; 88 void OnInputMethodChanged() const;
76 89
77 // Convenience method to call delegate_->DispatchKeyEventPostIME(). 90 // Convenience method to call delegate_->DispatchKeyEventPostIME().
78 // Returns true if the event was processed 91 // Returns true if the event was processed
79 ui::EventDispatchDetails DispatchKeyEventPostIME( 92 ui::EventDispatchDetails DispatchKeyEventPostIME(
80 ui::KeyEvent* event) const; 93 ui::KeyEvent* event) const;
81 94
82 // Convenience method to notify all observers of TextInputClient changes. 95 // Convenience method to notify all observers of TextInputClient changes.
83 void NotifyTextInputStateChanged(const TextInputClient* client); 96 void NotifyTextInputStateChanged(const TextInputClient* client);
84 97
85 // Convenience method to notify all observers of CaretBounds changes on 98 // Convenience method to notify all observers of CaretBounds changes on
86 // |client| which is the text input client with focus. 99 // |client| which is the text input client with focus.
87 void NotifyTextInputCaretBoundsChanged(const TextInputClient* client); 100 void NotifyTextInputCaretBoundsChanged(const TextInputClient* client);
88 101
89 // Gets the bounds of the composition text or cursor in |client|. 102 // Gets the bounds of the composition text or cursor in |client|.
90 std::vector<gfx::Rect> GetCompositionBounds(const TextInputClient* client); 103 std::vector<gfx::Rect> GetCompositionBounds(const TextInputClient* client);
91 104
105 // Indicates whether the IME extension is currently handling a physical key
106 // event. This is used in CommitText/UpdateCompositionText/etc.
107 bool handling_key_event_;
Shu Chen 2016/02/03 09:22:29 Can this be moved to InputMethodEngineBase?
Shu Chen 2016/02/03 10:05:41 Per offline discussion, let improve the code struc
108
92 private: 109 private:
93 void SetFocusedTextInputClientInternal(TextInputClient* client); 110 void SetFocusedTextInputClientInternal(TextInputClient* client);
94 111
95 internal::InputMethodDelegate* delegate_; 112 internal::InputMethodDelegate* delegate_;
96 TextInputClient* text_input_client_; 113 TextInputClient* text_input_client_;
97 114
98 base::ObserverList<InputMethodObserver> observer_list_; 115 base::ObserverList<InputMethodObserver> observer_list_;
99 116
100 DISALLOW_COPY_AND_ASSIGN(InputMethodBase); 117 DISALLOW_COPY_AND_ASSIGN(InputMethodBase);
101 }; 118 };
102 119
103 } // namespace ui 120 } // namespace ui
104 121
105 #endif // UI_BASE_IME_INPUT_METHOD_BASE_H_ 122 #endif // UI_BASE_IME_INPUT_METHOD_BASE_H_
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_auralinux.cc ('k') | ui/base/ime/input_method_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698