| OLD | NEW |
| 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 content { | 15 namespace content { |
| 16 class RenderFrameHost; | 16 class RenderFrameHost; |
| 17 } // namespace content | 17 } // namespace content |
| 18 | 18 |
| 19 namespace input_method { | 19 namespace input_method { |
| 20 | 20 |
| 21 class InputMethodEngine : public InputMethodEngineBase, | 21 class InputMethodEngine : public InputMethodEngineBase, |
| 22 public ui::ImeWindowObserver { | 22 public ui::ImeWindowObserver { |
| 23 public: | 23 public: |
| 24 InputMethodEngine(); | 24 InputMethodEngine(); |
| 25 | 25 |
| 26 ~InputMethodEngine() override; | 26 ~InputMethodEngine() override; |
| 27 | 27 |
| 28 // ui::IMEEngineHandlerInterface: | 28 // ui::IMEEngineHandlerInterface: |
| 29 bool SendKeyEvents(int context_id, | |
| 30 const std::vector<KeyboardEvent>& events) override; | |
| 31 bool IsActive() const override; | 29 bool IsActive() const override; |
| 32 std::string GetExtensionId() const override; | 30 std::string GetExtensionId() const override; |
| 33 | 31 |
| 34 // Creates and shows the IME window. | 32 // Creates and shows the IME window. |
| 35 // Returns 0 for errors and |error| will contains the error message. | 33 // Returns 0 for errors and |error| will contains the error message. |
| 36 int CreateImeWindow(const extensions::Extension* extension, | 34 int CreateImeWindow(const extensions::Extension* extension, |
| 37 content::RenderFrameHost* render_frame_host, | 35 content::RenderFrameHost* render_frame_host, |
| 38 const std::string& url, | 36 const std::string& url, |
| 39 ui::ImeWindow::Mode mode, | 37 ui::ImeWindow::Mode mode, |
| 40 const gfx::Rect& bounds, | 38 const gfx::Rect& bounds, |
| 41 std::string* error); | 39 std::string* error); |
| 42 void ShowImeWindow(int window_id); | 40 void ShowImeWindow(int window_id); |
| 43 void HideImeWindow(int window_id); | 41 void HideImeWindow(int window_id); |
| 44 void CloseImeWindows(); | 42 void CloseImeWindows(); |
| 45 | 43 |
| 46 private: | 44 private: |
| 47 // input_method::InputMethodEngineBase: | 45 // input_method::InputMethodEngineBase: |
| 48 void FocusIn(const ui::IMEEngineHandlerInterface::InputContext& input_context) | 46 void FocusIn(const ui::IMEEngineHandlerInterface::InputContext& input_context) |
| 49 override; | 47 override; |
| 50 void FocusOut() override; | 48 void FocusOut() override; |
| 51 void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) override; | 49 void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) override; |
| 52 void UpdateComposition(const ui::CompositionText& composition_text, | 50 void UpdateComposition(const ui::CompositionText& composition_text, |
| 53 uint32_t cursor_pos, | 51 uint32_t cursor_pos, |
| 54 bool is_visible) override; | 52 bool is_visible) override; |
| 55 void CommitTextToInputContext(int context_id, | 53 void CommitTextToInputContext(int context_id, |
| 56 const std::string& text) override; | 54 const std::string& text) override; |
| 55 bool SendKeyEvent(ui::KeyEvent* ui_event, const std::string& code) override; |
| 57 | 56 |
| 58 // ui::ImeWindowObserver: | 57 // ui::ImeWindowObserver: |
| 59 void OnWindowDestroyed(ui::ImeWindow* ime_window) override; | 58 void OnWindowDestroyed(ui::ImeWindow* ime_window) override; |
| 60 | 59 |
| 61 ui::ImeWindow* FindWindowById(int window_id) const; | 60 ui::ImeWindow* FindWindowById(int window_id) const; |
| 62 | 61 |
| 63 // Holds the IME window instances for properly closing in the destructor. | 62 // Holds the IME window instances for properly closing in the destructor. |
| 64 // The follow-cursor window is singleton. | 63 // The follow-cursor window is singleton. |
| 65 // The normal windows cannot exceed the max count. | 64 // The normal windows cannot exceed the max count. |
| 66 ui::ImeWindow* follow_cursor_window_; // Weak. | 65 ui::ImeWindow* follow_cursor_window_; // Weak. |
| 67 std::vector<ui::ImeWindow*> normal_windows_; // Weak. | 66 std::vector<ui::ImeWindow*> normal_windows_; // Weak. |
| 68 | 67 |
| 69 // Tracks the current cursor bounds so that the new follow cursor window can | 68 // Tracks the current cursor bounds so that the new follow cursor window can |
| 70 // be aligned with cursor once it being created. | 69 // be aligned with cursor once it being created. |
| 71 gfx::Rect current_cursor_bounds_; | 70 gfx::Rect current_cursor_bounds_; |
| 72 | 71 |
| 73 DISALLOW_COPY_AND_ASSIGN(InputMethodEngine); | 72 DISALLOW_COPY_AND_ASSIGN(InputMethodEngine); |
| 74 }; | 73 }; |
| 75 | 74 |
| 76 } // namespace input_method | 75 } // namespace input_method |
| 77 | 76 |
| 78 #endif // CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 77 #endif // CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ |
| OLD | NEW |