OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
Yusuke Sato
2016/08/20 01:25:38
Please test the CL on non mus+ash environment too.
Peng
2016/08/20 13:09:23
I tested exo with weston-terminal, and other wayla
| |
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 COMPONENTS_ARC_IME_ARC_IME_SERVICE_H_ | 5 #ifndef COMPONENTS_ARC_IME_ARC_IME_SERVICE_H_ |
6 #define COMPONENTS_ARC_IME_ARC_IME_SERVICE_H_ | 6 #define COMPONENTS_ARC_IME_ARC_IME_SERVICE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/arc/arc_service.h" | 11 #include "components/arc/arc_service.h" |
12 #include "components/arc/ime/arc_ime_bridge.h" | 12 #include "components/arc/ime/arc_ime_bridge.h" |
13 #include "ui/aura/client/focus_change_observer.h" | 13 #include "components/exo/wm_helper.h" |
14 #include "ui/aura/env_observer.h" | 14 #include "ui/aura/env_observer.h" |
15 #include "ui/aura/window_observer.h" | 15 #include "ui/aura/window_observer.h" |
16 #include "ui/aura/window_tracker.h" | 16 #include "ui/aura/window_tracker.h" |
17 #include "ui/base/ime/text_input_client.h" | 17 #include "ui/base/ime/text_input_client.h" |
18 #include "ui/base/ime/text_input_flags.h" | 18 #include "ui/base/ime/text_input_flags.h" |
19 #include "ui/base/ime/text_input_type.h" | 19 #include "ui/base/ime/text_input_type.h" |
20 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
21 #include "ui/keyboard/keyboard_controller.h" | 21 #include "ui/keyboard/keyboard_controller.h" |
22 #include "ui/keyboard/keyboard_controller_observer.h" | 22 #include "ui/keyboard/keyboard_controller_observer.h" |
23 | 23 |
24 namespace aura { | 24 namespace aura { |
25 namespace client { | |
26 class FocusClient; | |
27 } | |
28 | |
29 class Window; | 25 class Window; |
30 } | 26 } |
31 | 27 |
32 namespace ui { | 28 namespace ui { |
33 class InputMethod; | 29 class InputMethod; |
34 } | 30 } |
35 | 31 |
36 namespace arc { | 32 namespace arc { |
37 | 33 |
38 class ArcBridgeService; | 34 class ArcBridgeService; |
39 | 35 |
40 // This class implements ui::TextInputClient and makes ARC windows behave | 36 // This class implements ui::TextInputClient and makes ARC windows behave |
41 // as a text input target in Chrome OS environment. | 37 // as a text input target in Chrome OS environment. |
42 class ArcImeService : public ArcService, | 38 class ArcImeService : public ArcService, |
43 public ArcImeBridge::Delegate, | 39 public ArcImeBridge::Delegate, |
44 public aura::EnvObserver, | 40 public aura::EnvObserver, |
45 public aura::WindowObserver, | 41 public exo::WMHelper::FocusObserver, |
46 public aura::client::FocusChangeObserver, | |
47 public keyboard::KeyboardControllerObserver, | 42 public keyboard::KeyboardControllerObserver, |
48 public ui::TextInputClient { | 43 public ui::TextInputClient { |
49 public: | 44 public: |
50 explicit ArcImeService(ArcBridgeService* bridge_service); | 45 explicit ArcImeService(ArcBridgeService* bridge_service); |
51 ~ArcImeService() override; | 46 ~ArcImeService() override; |
52 | 47 |
53 // Injects the custom IPC bridge object for testing purpose only. | 48 // Injects the custom IPC bridge object for testing purpose only. |
54 void SetImeBridgeForTesting(std::unique_ptr<ArcImeBridge> test_ime_bridge); | 49 void SetImeBridgeForTesting(std::unique_ptr<ArcImeBridge> test_ime_bridge); |
55 | 50 |
56 // Injects the custom IME for testing purpose only. | 51 // Injects the custom IME for testing purpose only. |
57 void SetInputMethodForTesting(ui::InputMethod* test_input_method); | 52 void SetInputMethodForTesting(ui::InputMethod* test_input_method); |
58 | 53 |
59 // Overridden from aura::EnvObserver: | 54 // Overridden from aura::EnvObserver: |
60 void OnWindowInitialized(aura::Window* new_window) override; | 55 void OnWindowInitialized(aura::Window* new_window) override; |
61 | 56 |
62 // Overridden from aura::WindowObserver: | 57 // Overridden from exo::WMHelper::FocusObserver: |
63 void OnWindowAddedToRootWindow(aura::Window* window) override; | |
64 | |
65 // Overridden from aura::client::FocusChangeObserver: | |
66 void OnWindowFocused(aura::Window* gained_focus, | 58 void OnWindowFocused(aura::Window* gained_focus, |
67 aura::Window* lost_focus) override; | 59 aura::Window* lost_focus) override; |
68 | 60 |
69 // Overridden from ArcImeBridge::Delegate: | 61 // Overridden from ArcImeBridge::Delegate: |
70 void OnTextInputTypeChanged(ui::TextInputType type) override; | 62 void OnTextInputTypeChanged(ui::TextInputType type) override; |
71 void OnCursorRectChanged(const gfx::Rect& rect) override; | 63 void OnCursorRectChanged(const gfx::Rect& rect) override; |
72 void OnCancelComposition() override; | 64 void OnCancelComposition() override; |
73 void ShowImeIfNeeded() override; | 65 void ShowImeIfNeeded() override; |
74 | 66 |
75 // Overridden from keyboard::KeyboardControllerObserver. | 67 // Overridden from keyboard::KeyboardControllerObserver. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 } | 103 } |
112 | 104 |
113 private: | 105 private: |
114 ui::InputMethod* GetInputMethod(); | 106 ui::InputMethod* GetInputMethod(); |
115 | 107 |
116 std::unique_ptr<ArcImeBridge> ime_bridge_; | 108 std::unique_ptr<ArcImeBridge> ime_bridge_; |
117 ui::TextInputType ime_type_; | 109 ui::TextInputType ime_type_; |
118 gfx::Rect cursor_rect_; | 110 gfx::Rect cursor_rect_; |
119 bool has_composition_text_; | 111 bool has_composition_text_; |
120 | 112 |
121 aura::WindowTracker arc_windows_; | |
122 aura::WindowTracker focused_arc_window_; | 113 aura::WindowTracker focused_arc_window_; |
123 | 114 |
124 aura::client::FocusClient* focus_client_; | |
125 keyboard::KeyboardController* keyboard_controller_; | 115 keyboard::KeyboardController* keyboard_controller_; |
126 | 116 |
127 ui::InputMethod* test_input_method_; | 117 ui::InputMethod* test_input_method_; |
118 bool is_focus_observer_installed_; | |
128 | 119 |
129 DISALLOW_COPY_AND_ASSIGN(ArcImeService); | 120 DISALLOW_COPY_AND_ASSIGN(ArcImeService); |
130 }; | 121 }; |
131 | 122 |
132 } // namespace arc | 123 } // namespace arc |
133 | 124 |
134 #endif // COMPONENTS_ARC_IME_ARC_IME_SERVICE_H_ | 125 #endif // COMPONENTS_ARC_IME_ARC_IME_SERVICE_H_ |
OLD | NEW |