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

Side by Side Diff: chrome/browser/input_method/input_method_engine_base.h

Issue 1590863002: Move the local struct definitions off ui/base/ime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CHROME_BROWSER_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ 5 #ifndef CHROME_BROWSER_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_
6 #define CHROME_BROWSER_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ 6 #define CHROME_BROWSER_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "ui/base/ime/chromeos/input_method_descriptor.h" 12 #include "ui/base/ime/chromeos/input_method_descriptor.h"
13 #include "ui/base/ime/ime_engine_handler_interface.h" 13 #include "ui/base/ime/ime_engine_handler_interface.h"
14 #include "ui/base/ime/ime_engine_observer.h"
15 #include "url/gurl.h" 14 #include "url/gurl.h"
16 15
17 class Profile; 16 class Profile;
18 17
19 namespace ui { 18 namespace ui {
20 struct CompositionText; 19 struct CompositionText;
21 class IMEEngineHandlerInterface; 20 class IMEEngineHandlerInterface;
22 class IMEEngineObserver;
23 class KeyEvent; 21 class KeyEvent;
24 } // namespace ui 22 } // namespace ui
25 23
26 namespace input_method { 24 namespace input_method {
27 25
28 class InputMethodEngineBase : virtual public ui::IMEEngineHandlerInterface { 26 class InputMethodEngineBase : virtual public ui::IMEEngineHandlerInterface {
29 public: 27 public:
28 struct KeyboardEvent {
29 KeyboardEvent();
30 virtual ~KeyboardEvent();
31
32 std::string type;
33 std::string key;
34 std::string code;
35 int key_code; // only used by on-screen keyboards.
36 std::string extension_id;
37 bool alt_key;
38 bool ctrl_key;
39 bool shift_key;
40 bool caps_lock;
41 };
42
43 enum SegmentStyle {
44 SEGMENT_STYLE_UNDERLINE,
45 SEGMENT_STYLE_DOUBLE_UNDERLINE,
46 SEGMENT_STYLE_NO_UNDERLINE,
47 };
48
49 struct SegmentInfo {
50 int start;
51 int end;
52 SegmentStyle style;
53 };
54
55 #if defined(OS_CHROMEOS)
56 enum MouseButtonEvent {
57 MOUSE_BUTTON_LEFT,
58 MOUSE_BUTTON_RIGHT,
59 MOUSE_BUTTON_MIDDLE,
60 };
61 #endif
62
63 class Observer {
64 public:
65 virtual ~Observer() {}
66
67 // Called when the IME becomes the active IME.
68 virtual void OnActivate(const std::string& engine_id) = 0;
69
70 // Called when a text field gains focus, and will be sending key events.
71 virtual void OnFocus(
72 const IMEEngineHandlerInterface::InputContext& context) = 0;
73
74 // Called when a text field loses focus, and will no longer generate events.
75 virtual void OnBlur(int context_id) = 0;
76
77 // Called when the user pressed a key with a text field focused.
78 virtual void OnKeyEvent(
79 const std::string& engine_id,
80 const InputMethodEngineBase::KeyboardEvent& event,
81 ui::IMEEngineHandlerInterface::KeyEventDoneCallback& key_data) = 0;
82
83 // Called when Chrome terminates on-going text input session.
84 virtual void OnReset(const std::string& engine_id) = 0;
85
86 // Called when the IME is no longer active.
87 virtual void OnDeactivated(const std::string& engine_id) = 0;
88
89 // Called when composition bounds are changed.
90 virtual void OnCompositionBoundsChanged(
91 const std::vector<gfx::Rect>& bounds) = 0;
92
93 // Returns whether the observer is interested in key events.
94 virtual bool IsInterestedInKeyEvent() const = 0;
95
96 // Called when a surrounding text is changed.
97 virtual void OnSurroundingTextChanged(const std::string& engine_id,
98 const std::string& text,
99 int cursor_pos,
100 int anchor_pos,
101 int offset_pos) = 0;
102
103 #if defined(OS_CHROMEOS)
104
105 // Called when an InputContext's properties change while it is focused.
106 virtual void OnInputContextUpdate(
107 const IMEEngineHandlerInterface::InputContext& context) = 0;
108
109 // Called when the user clicks on an item in the candidate list.
110 virtual void OnCandidateClicked(
111 const std::string& component_id,
112 int candidate_id,
113 InputMethodEngineBase::MouseButtonEvent button) = 0;
114
115 // Called when a menu item for this IME is interacted with.
116 virtual void OnMenuItemActivated(const std::string& component_id,
117 const std::string& menu_id) = 0;
118 #endif // defined(OS_CHROMEOS)
119 };
120
30 InputMethodEngineBase(); 121 InputMethodEngineBase();
31 122
32 ~InputMethodEngineBase() override; 123 ~InputMethodEngineBase() override;
33 124
34 void Initialize(scoped_ptr<ui::IMEEngineObserver> observer, 125 void Initialize(scoped_ptr<InputMethodEngineBase::Observer> observer,
35 const char* extension_id, 126 const char* extension_id,
36 Profile* profile); 127 Profile* profile);
37 128
38 // IMEEngineHandlerInterface overrides. 129 // IMEEngineHandlerInterface overrides.
39 void FocusIn(const ui::IMEEngineHandlerInterface::InputContext& input_context) 130 void FocusIn(const ui::IMEEngineHandlerInterface::InputContext& input_context)
40 override; 131 override;
41 void FocusOut() override; 132 void FocusOut() override;
42 void Enable(const std::string& component_id) override; 133 void Enable(const std::string& component_id) override;
43 void Disable() override; 134 void Disable() override;
44 void Reset() override; 135 void Reset() override;
45 void ProcessKeyEvent(const ui::KeyEvent& key_event, 136 void ProcessKeyEvent(const ui::KeyEvent& key_event,
46 KeyEventDoneCallback& callback) override; 137 KeyEventDoneCallback& callback) override;
47 void SetSurroundingText(const std::string& text, 138 void SetSurroundingText(const std::string& text,
48 uint32_t cursor_pos, 139 uint32_t cursor_pos,
49 uint32_t anchor_pos, 140 uint32_t anchor_pos,
50 uint32_t offset_pos) override; 141 uint32_t offset_pos) override;
51 void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) override; 142 void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) override;
52 bool SetComposition(int context_id,
53 const char* text,
54 int selection_start,
55 int selection_end,
56 int cursor,
57 const std::vector<SegmentInfo>& segments,
58 std::string* error) override;
59 bool ClearComposition(int context_id, std::string* error) override; 143 bool ClearComposition(int context_id, std::string* error) override;
60 bool CommitText(int context_id, 144 bool CommitText(int context_id,
61 const char* text, 145 const char* text,
62 std::string* error) override; 146 std::string* error) override;
63 const std::string& GetActiveComponentId() const override; 147 const std::string& GetActiveComponentId() const override;
64 bool DeleteSurroundingText(int context_id, 148 bool DeleteSurroundingText(int context_id,
65 int offset, 149 int offset,
66 size_t number_of_chars, 150 size_t number_of_chars,
67 std::string* error) override; 151 std::string* error) override;
68 int GetCotextIdForTesting() { return context_id_; } 152 int GetCotextIdForTesting() { return context_id_; }
69 bool IsInterestedInKeyEvent() const override; 153 bool IsInterestedInKeyEvent() const override;
70 154
155 // Send the sequence of key events.
156 virtual bool SendKeyEvents(int context_id,
157 const std::vector<KeyboardEvent>& events) = 0;
158
159 // Set the current composition and associated properties.
160 bool SetComposition(int context_id,
161 const char* text,
162 int selection_start,
163 int selection_end,
164 int cursor,
165 const std::vector<SegmentInfo>& segments,
166 std::string* error);
167
71 protected: 168 protected:
72 ui::TextInputType current_input_type_; 169 ui::TextInputType current_input_type_;
73 170
74 // ID that is used for the current input context. False if there is no focus. 171 // ID that is used for the current input context. False if there is no focus.
75 int context_id_; 172 int context_id_;
76 173
77 // Next id that will be assigned to a context. 174 // Next id that will be assigned to a context.
78 int next_context_id_; 175 int next_context_id_;
79 176
80 // The input_component ID in IME extension's manifest. 177 // The input_component ID in IME extension's manifest.
81 std::string active_component_id_; 178 std::string active_component_id_;
82 179
83 // The IME extension ID. 180 // The IME extension ID.
84 std::string extension_id_; 181 std::string extension_id_;
85 182
86 // The observer object recieving events for this IME. 183 // The observer object recieving events for this IME.
87 scoped_ptr<ui::IMEEngineObserver> observer_; 184 scoped_ptr<InputMethodEngineBase::Observer> observer_;
88 185
89 // The current preedit text, and it's cursor position. 186 // The current preedit text, and it's cursor position.
90 scoped_ptr<ui::CompositionText> composition_text_; 187 scoped_ptr<ui::CompositionText> composition_text_;
91 int composition_cursor_; 188 int composition_cursor_;
92 189
93 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event 190 // Used with SendKeyEvents and ProcessKeyEvent to check if the key event
94 // sent to ProcessKeyEvent is sent by SendKeyEvents. 191 // sent to ProcessKeyEvent is sent by SendKeyEvents.
95 const ui::KeyEvent* sent_key_event_; 192 const ui::KeyEvent* sent_key_event_;
96 193
97 Profile* profile_; 194 Profile* profile_;
98 }; 195 };
99 196
100 } // namespace input_method 197 } // namespace input_method
101 198
102 #endif // CHROME_BROWSER_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_ 199 #endif // CHROME_BROWSER_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698