| 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 | 40 |
| 43 void CloseImeWindows(); | 41 void CloseImeWindows(); |
| 44 | 42 |
| 45 private: | 43 private: |
| 46 // input_method::InputMethodEngineBase: | 44 // input_method::InputMethodEngineBase: |
| 47 void FocusIn(const ui::IMEEngineHandlerInterface::InputContext& input_context) | 45 void FocusIn(const ui::IMEEngineHandlerInterface::InputContext& input_context) |
| 48 override; | 46 override; |
| 49 void FocusOut() override; | 47 void FocusOut() override; |
| 50 void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) override; | 48 void SetCompositionBounds(const std::vector<gfx::Rect>& bounds) override; |
| 51 void UpdateComposition(const ui::CompositionText& composition_text, | 49 void UpdateComposition(const ui::CompositionText& composition_text, |
| 52 uint32_t cursor_pos, | 50 uint32_t cursor_pos, |
| 53 bool is_visible) override; | 51 bool is_visible) override; |
| 54 void CommitTextToInputContext(int context_id, | 52 void CommitTextToInputContext(int context_id, |
| 55 const std::string& text) override; | 53 const std::string& text) override; |
| 54 bool SendKeyEvent(ui::KeyEvent* ui_event) override; |
| 56 | 55 |
| 57 // ui::ImeWindowObserver: | 56 // ui::ImeWindowObserver: |
| 58 void OnWindowDestroyed(ui::ImeWindow* ime_window) override; | 57 void OnWindowDestroyed(ui::ImeWindow* ime_window) override; |
| 59 | 58 |
| 60 // Holds the IME window instances for properly closing in the destructor. | 59 // Holds the IME window instances for properly closing in the destructor. |
| 61 // The follow-cursor window is singleton. | 60 // The follow-cursor window is singleton. |
| 62 // The normal windows cannot exceed the max count. | 61 // The normal windows cannot exceed the max count. |
| 63 ui::ImeWindow* follow_cursor_window_; // Weak. | 62 ui::ImeWindow* follow_cursor_window_; // Weak. |
| 64 std::vector<ui::ImeWindow*> normal_windows_; // Weak. | 63 std::vector<ui::ImeWindow*> normal_windows_; // Weak. |
| 65 | 64 |
| 66 // Tracks the current cursor bounds so that the new follow cursor window can | 65 // Tracks the current cursor bounds so that the new follow cursor window can |
| 67 // be aligned with cursor once it being created. | 66 // be aligned with cursor once it being created. |
| 68 gfx::Rect current_cursor_bounds_; | 67 gfx::Rect current_cursor_bounds_; |
| 69 | 68 |
| 70 DISALLOW_COPY_AND_ASSIGN(InputMethodEngine); | 69 DISALLOW_COPY_AND_ASSIGN(InputMethodEngine); |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 } // namespace input_method | 72 } // namespace input_method |
| 74 | 73 |
| 75 #endif // CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 74 #endif // CHROME_BROWSER_UI_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ |
| OLD | NEW |