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

Side by Side Diff: chrome/browser/ui/input_method/input_method_engine.h

Issue 1771173002: Implement input.ime.sendKeyEvents API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update test. Created 4 years, 9 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_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ 5 #ifndef CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_
6 #define CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ 6 #define CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "chrome/browser/ui/ime/ime_window.h" 11 #include "chrome/browser/ui/ime/ime_window.h"
12 #include "chrome/browser/ui/ime/ime_window_observer.h" 12 #include "chrome/browser/ui/ime/ime_window_observer.h"
13 #include "chrome/browser/ui/input_method/input_method_engine_base.h" 13 #include "chrome/browser/ui/input_method/input_method_engine_base.h"
14 14
15 namespace input_method { 15 namespace input_method {
16 16
17 class InputMethodEngine : public InputMethodEngineBase, 17 class InputMethodEngine : public InputMethodEngineBase,
18 public ui::ImeWindowObserver { 18 public ui::ImeWindowObserver {
19 public: 19 public:
20 InputMethodEngine(); 20 InputMethodEngine();
21 21
22 ~InputMethodEngine() override; 22 ~InputMethodEngine() override;
23 23
24 // ui::IMEEngineHandlerInterface: 24 // ui::IMEEngineHandlerInterface:
25 bool SendKeyEvents(int context_id,
26 const std::vector<KeyboardEvent>& events) override;
27 bool IsActive() const override; 25 bool IsActive() const override;
28 std::string GetExtensionId() const override; 26 std::string GetExtensionId() const override;
29 27
30 // Creates and shows the IME window. 28 // Creates and shows the IME window.
31 // Returns 0 for errors and |error| will contains the error message. 29 // Returns 0 for errors and |error| will contains the error message.
32 int CreateImeWindow(const extensions::Extension* extension, 30 int CreateImeWindow(const extensions::Extension* extension,
33 const std::string& url, 31 const std::string& url,
34 ui::ImeWindow::Mode mode, 32 ui::ImeWindow::Mode mode,
35 const gfx::Rect& bounds, 33 const gfx::Rect& bounds,
36 std::string* error); 34 std::string* error);
37 35
38 void CloseImeWindows(); 36 void CloseImeWindows();
39 37
40 private: 38 private:
41 // input_method::InputMethodEngineBase: 39 // input_method::InputMethodEngineBase:
42 void FocusIn(const ui::IMEEngineHandlerInterface::InputContext& input_context) 40 void FocusIn(const ui::IMEEngineHandlerInterface::InputContext& input_context)
43 override; 41 override;
44 void FocusOut() override; 42 void FocusOut() override;
45 void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) override; 43 void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) override;
46 void UpdateComposition(const ui::CompositionText& composition_text, 44 void UpdateComposition(const ui::CompositionText& composition_text,
47 uint32_t cursor_pos, 45 uint32_t cursor_pos,
48 bool is_visible) override; 46 bool is_visible) override;
49 void CommitTextToInputContext(int context_id, 47 void CommitTextToInputContext(int context_id,
50 const std::string& text) override; 48 const std::string& text) override;
49 bool SendKeyEvent(ui::KeyEvent* ui_event) override;
51 50
52 // ui::ImeWindowObserver: 51 // ui::ImeWindowObserver:
53 void OnWindowDestroyed(ui::ImeWindow* ime_window) override; 52 void OnWindowDestroyed(ui::ImeWindow* ime_window) override;
54 53
55 // Holds the IME window instances for properly closing in the destructor. 54 // Holds the IME window instances for properly closing in the destructor.
56 // The follow-cursor window is singleton. 55 // The follow-cursor window is singleton.
57 // The normal windows cannot exceed the max count. 56 // The normal windows cannot exceed the max count.
58 ui::ImeWindow* follow_cursor_window_; // Weak. 57 ui::ImeWindow* follow_cursor_window_; // Weak.
59 std::vector<ui::ImeWindow*> normal_windows_; // Weak. 58 std::vector<ui::ImeWindow*> normal_windows_; // Weak.
60 59
61 // Tracks the current cursor bounds so that the new follow cursor window can 60 // Tracks the current cursor bounds so that the new follow cursor window can
62 // be aligned with cursor once it being created. 61 // be aligned with cursor once it being created.
63 gfx::Rect current_cursor_bounds_; 62 gfx::Rect current_cursor_bounds_;
64 63
65 DISALLOW_COPY_AND_ASSIGN(InputMethodEngine); 64 DISALLOW_COPY_AND_ASSIGN(InputMethodEngine);
66 }; 65 };
67 66
68 } // namespace input_method 67 } // namespace input_method
69 68
70 #endif // CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ 69 #endif // CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698