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

Side by Side Diff: components/arc/ime/arc_ime_service.h

Issue 2661863002: ARC IME: Fix Crash on ARC Notification (Closed)
Patch Set: Created 3 years, 10 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 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 "components/exo/wm_helper.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"
kinaba 2017/02/01 04:13:27 not needed?
yoshiki 2017/02/01 05:10:10 Removed.
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 class Window; 25 class Window;
26 } 26 }
27 27
28 namespace ui { 28 namespace ui {
29 class InputMethod; 29 class InputMethod;
30 } 30 }
31 31
32 namespace arc { 32 namespace arc {
33 33
34 class ArcBridgeService; 34 class ArcBridgeService;
35 35
36 // This class implements ui::TextInputClient and makes ARC windows behave 36 // This class implements ui::TextInputClient and makes ARC windows behave
37 // as a text input target in Chrome OS environment. 37 // as a text input target in Chrome OS environment.
38 class ArcImeService : public ArcService, 38 class ArcImeService : public ArcService,
39 public ArcImeBridge::Delegate, 39 public ArcImeBridge::Delegate,
40 public aura::EnvObserver, 40 public aura::EnvObserver,
41 public aura::WindowObserver,
41 public exo::WMHelper::FocusObserver, 42 public exo::WMHelper::FocusObserver,
42 public keyboard::KeyboardControllerObserver, 43 public keyboard::KeyboardControllerObserver,
43 public ui::TextInputClient { 44 public ui::TextInputClient {
44 public: 45 public:
45 explicit ArcImeService(ArcBridgeService* bridge_service); 46 explicit ArcImeService(ArcBridgeService* bridge_service);
46 ~ArcImeService() override; 47 ~ArcImeService() override;
47 48
48 class ArcWindowDelegate { 49 class ArcWindowDelegate {
49 public: 50 public:
50 virtual ~ArcWindowDelegate() {} 51 virtual ~ArcWindowDelegate() {}
51 virtual bool IsArcWindow(const aura::Window* window) const = 0; 52 virtual bool IsArcWindow(const aura::Window* window) const = 0;
52 virtual void RegisterFocusObserver() = 0; 53 virtual void RegisterFocusObserver() = 0;
53 virtual void UnregisterFocusObserver() = 0; 54 virtual void UnregisterFocusObserver() = 0;
54 }; 55 };
55 56
56 // Injects the custom IPC bridge object for testing purpose only. 57 // Injects the custom IPC bridge object for testing purpose only.
57 void SetImeBridgeForTesting(std::unique_ptr<ArcImeBridge> test_ime_bridge); 58 void SetImeBridgeForTesting(std::unique_ptr<ArcImeBridge> test_ime_bridge);
58 59
59 // Injects the custom IME for testing purpose only. 60 // Injects the custom IME for testing purpose only.
60 void SetInputMethodForTesting(ui::InputMethod* test_input_method); 61 void SetInputMethodForTesting(ui::InputMethod* test_input_method);
61 62
62 // Injects the custom delegate for ARC windows, for testing purpose only. 63 // Injects the custom delegate for ARC windows, for testing purpose only.
63 void SetArcWindowDelegateForTesting( 64 void SetArcWindowDelegateForTesting(
64 std::unique_ptr<ArcWindowDelegate> delegate); 65 std::unique_ptr<ArcWindowDelegate> delegate);
65 66
66 // Overridden from aura::EnvObserver: 67 // Overridden from aura::EnvObserver:
67 void OnWindowInitialized(aura::Window* new_window) override; 68 void OnWindowInitialized(aura::Window* new_window) override;
68 69
70 // Overridden from aura::WindowObserver:
71 void OnWindowDestroying(aura::Window* window) override;
72 void OnWindowRemovingFromRootWindow(aura::Window* window,
73 aura::Window* new_root) override;
74
69 // Overridden from exo::WMHelper::FocusObserver: 75 // Overridden from exo::WMHelper::FocusObserver:
70 void OnWindowFocused(aura::Window* gained_focus, 76 void OnWindowFocused(aura::Window* gained_focus,
71 aura::Window* lost_focus) override; 77 aura::Window* lost_focus) override;
72 78
73 // Overridden from ArcImeBridge::Delegate: 79 // Overridden from ArcImeBridge::Delegate:
74 void OnTextInputTypeChanged(ui::TextInputType type) override; 80 void OnTextInputTypeChanged(ui::TextInputType type) override;
75 void OnCursorRectChanged(const gfx::Rect& rect) override; 81 void OnCursorRectChanged(const gfx::Rect& rect) override;
76 void OnCancelComposition() override; 82 void OnCancelComposition() override;
77 void ShowImeIfNeeded() override; 83 void ShowImeIfNeeded() override;
78 84
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 123
118 private: 124 private:
119 ui::InputMethod* GetInputMethod(); 125 ui::InputMethod* GetInputMethod();
120 126
121 std::unique_ptr<ArcImeBridge> ime_bridge_; 127 std::unique_ptr<ArcImeBridge> ime_bridge_;
122 std::unique_ptr<ArcWindowDelegate> arc_window_delegate_; 128 std::unique_ptr<ArcWindowDelegate> arc_window_delegate_;
123 ui::TextInputType ime_type_; 129 ui::TextInputType ime_type_;
124 gfx::Rect cursor_rect_; 130 gfx::Rect cursor_rect_;
125 bool has_composition_text_; 131 bool has_composition_text_;
126 132
127 aura::WindowTracker focused_arc_window_; 133 aura::Window* focused_arc_window_ = nullptr;
128 134
129 keyboard::KeyboardController* keyboard_controller_; 135 keyboard::KeyboardController* keyboard_controller_;
130 136
131 ui::InputMethod* test_input_method_; 137 ui::InputMethod* test_input_method_;
132 bool is_focus_observer_installed_; 138 bool is_focus_observer_installed_;
133 139
134 DISALLOW_COPY_AND_ASSIGN(ArcImeService); 140 DISALLOW_COPY_AND_ASSIGN(ArcImeService);
135 }; 141 };
136 142
137 } // namespace arc 143 } // namespace arc
138 144
139 #endif // COMPONENTS_ARC_IME_ARC_IME_SERVICE_H_ 145 #endif // COMPONENTS_ARC_IME_ARC_IME_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | components/arc/ime/arc_ime_service.cc » ('j') | components/arc/ime/arc_ime_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698