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

Side by Side Diff: ui/aura/window_tree_host.h

Issue 1155013005: Refactoring the ownership of ui::InputMethod. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pls be green! Created 5 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_AURA_WINDOW_TREE_HOST_H_ 5 #ifndef UI_AURA_WINDOW_TREE_HOST_H_
6 #define UI_AURA_WINDOW_TREE_HOST_H_ 6 #define UI_AURA_WINDOW_TREE_HOST_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/event_types.h" 10 #include "base/event_types.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "ui/aura/aura_export.h" 12 #include "ui/aura/aura_export.h"
13 #include "ui/base/cursor/cursor.h" 13 #include "ui/base/cursor/cursor.h"
14 #include "ui/base/ime/input_method.h"
James Cook 2015/06/01 22:21:00 optional: you could forward-declare ui::InputMetho
Shu Chen 2015/06/02 04:11:16 Done.
15 #include "ui/base/ime/input_method_delegate.h"
14 #include "ui/events/event_source.h" 16 #include "ui/events/event_source.h"
15 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
16 18
17 namespace gfx { 19 namespace gfx {
18 class Insets; 20 class Insets;
19 class Point; 21 class Point;
20 class Rect; 22 class Rect;
21 class Size; 23 class Size;
22 class Transform; 24 class Transform;
23 } 25 }
24 26
25 namespace ui { 27 namespace ui {
26 class Compositor; 28 class Compositor;
27 class EventProcessor; 29 class EventProcessor;
28 class ViewProp; 30 class ViewProp;
29 } 31 }
30 32
31 namespace aura { 33 namespace aura {
32 namespace test { 34 namespace test {
33 class WindowTreeHostTestApi; 35 class WindowTreeHostTestApi;
34 } 36 }
35 37
36 class WindowEventDispatcher; 38 class WindowEventDispatcher;
37 class WindowTreeHostObserver; 39 class WindowTreeHostObserver;
38 40
39 // WindowTreeHost bridges between a native window and the embedded RootWindow. 41 // WindowTreeHost bridges between a native window and the embedded RootWindow.
40 // It provides the accelerated widget and maps events from the native os to 42 // It provides the accelerated widget and maps events from the native os to
41 // aura. 43 // aura.
42 class AURA_EXPORT WindowTreeHost { 44 class AURA_EXPORT WindowTreeHost
45 : public ui::internal::InputMethodDelegate,
46 public ui::EventSource {
43 public: 47 public:
44 virtual ~WindowTreeHost(); 48 ~WindowTreeHost() override;
45 49
46 // Creates a new WindowTreeHost. The caller owns the returned value. 50 // Creates a new WindowTreeHost. The caller owns the returned value.
47 static WindowTreeHost* Create(const gfx::Rect& bounds); 51 static WindowTreeHost* Create(const gfx::Rect& bounds);
48 52
49 // Returns the WindowTreeHost for the specified accelerated widget, or NULL 53 // Returns the WindowTreeHost for the specified accelerated widget, or NULL
50 // if there is none associated. 54 // if there is none associated.
51 static WindowTreeHost* GetForAcceleratedWidget(gfx::AcceleratedWidget widget); 55 static WindowTreeHost* GetForAcceleratedWidget(gfx::AcceleratedWidget widget);
52 56
53 void InitHost(); 57 void InitHost();
54 58
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 void OnCursorVisibilityChanged(bool visible); 113 void OnCursorVisibilityChanged(bool visible);
110 114
111 // Moves the cursor to the specified location relative to the root window. 115 // Moves the cursor to the specified location relative to the root window.
112 void MoveCursorTo(const gfx::Point& location); 116 void MoveCursorTo(const gfx::Point& location);
113 117
114 // Moves the cursor to the |host_location| given in host coordinates. 118 // Moves the cursor to the |host_location| given in host coordinates.
115 void MoveCursorToHostLocation(const gfx::Point& host_location); 119 void MoveCursorToHostLocation(const gfx::Point& host_location);
116 120
117 gfx::NativeCursor last_cursor() const { return last_cursor_; } 121 gfx::NativeCursor last_cursor() const { return last_cursor_; }
118 122
123 ui::InputMethod* GetInputMethod();
124
125 void SetInputMethod(ui::InputMethod* input_method);
James Cook 2015/06/01 22:21:00 Document how this behaves with respect to ownershi
Shu Chen 2015/06/02 04:11:16 Done.
126
119 // Returns the EventSource responsible for dispatching events to the window 127 // Returns the EventSource responsible for dispatching events to the window
120 // tree. 128 // tree.
121 virtual ui::EventSource* GetEventSource() = 0; 129 virtual ui::EventSource* GetEventSource() = 0;
122 130
123 // Returns the accelerated widget. 131 // Returns the accelerated widget.
124 virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; 132 virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0;
125 133
126 // Shows the WindowTreeHost. 134 // Shows the WindowTreeHost.
127 virtual void Show() = 0; 135 virtual void Show() = 0;
128 136
(...skipping 30 matching lines...) Expand all
159 167
160 // Sets the currently displayed cursor. 168 // Sets the currently displayed cursor.
161 virtual void SetCursorNative(gfx::NativeCursor cursor) = 0; 169 virtual void SetCursorNative(gfx::NativeCursor cursor) = 0;
162 170
163 // Moves the cursor to the specified location relative to the root window. 171 // Moves the cursor to the specified location relative to the root window.
164 virtual void MoveCursorToNative(const gfx::Point& location) = 0; 172 virtual void MoveCursorToNative(const gfx::Point& location) = 0;
165 173
166 // kCalled when the cursor visibility has changed. 174 // kCalled when the cursor visibility has changed.
167 virtual void OnCursorVisibilityChangedNative(bool show) = 0; 175 virtual void OnCursorVisibilityChangedNative(bool show) = 0;
168 176
177 // Overridden from ui::internal::InputMethodDelegate:
178 bool DispatchKeyEventPostIME(const ui::KeyEvent& event) override;
179
180 // Overridden from ui::EventSource:
181 ui::EventProcessor* GetEventProcessor() override;
182 ui::EventDispatchDetails DeliverEventToProcessor(ui::Event* event) override;
183
169 private: 184 private:
170 friend class test::WindowTreeHostTestApi; 185 friend class test::WindowTreeHostTestApi;
171 186
172 // Moves the cursor to the specified location. This method is internally used 187 // Moves the cursor to the specified location. This method is internally used
173 // by MoveCursorTo() and MoveCursorToHostLocation(). 188 // by MoveCursorTo() and MoveCursorToHostLocation().
174 void MoveCursorToInternal(const gfx::Point& root_location, 189 void MoveCursorToInternal(const gfx::Point& root_location,
175 const gfx::Point& host_location); 190 const gfx::Point& host_location);
176 191
177 // We don't use a scoped_ptr for |window_| since we need this ptr to be valid 192 // We don't use a scoped_ptr for |window_| since we need this ptr to be valid
178 // during its deletion. (Window's dtor notifies observers that may attempt to 193 // during its deletion. (Window's dtor notifies observers that may attempt to
179 // reach back up to access this object which will be valid until the end of 194 // reach back up to access this object which will be valid until the end of
180 // the dtor). 195 // the dtor).
181 Window* window_; // Owning. 196 Window* window_; // Owning.
182 197
183 ObserverList<WindowTreeHostObserver> observers_; 198 ObserverList<WindowTreeHostObserver> observers_;
184 199
185 scoped_ptr<WindowEventDispatcher> dispatcher_; 200 scoped_ptr<WindowEventDispatcher> dispatcher_;
186 201
187 scoped_ptr<ui::Compositor> compositor_; 202 scoped_ptr<ui::Compositor> compositor_;
188 203
189 // Last cursor set. Used for testing. 204 // Last cursor set. Used for testing.
190 gfx::NativeCursor last_cursor_; 205 gfx::NativeCursor last_cursor_;
191 gfx::Point last_cursor_request_position_in_host_; 206 gfx::Point last_cursor_request_position_in_host_;
192 207
193 scoped_ptr<ui::ViewProp> prop_; 208 scoped_ptr<ui::ViewProp> prop_;
194 209
210 ui::InputMethod* input_method_;
James Cook 2015/06/01 22:21:00 Document how ownership works for this member.
Shu Chen 2015/06/02 04:11:16 Done.
211 bool owned_input_method_;
212
195 DISALLOW_COPY_AND_ASSIGN(WindowTreeHost); 213 DISALLOW_COPY_AND_ASSIGN(WindowTreeHost);
196 }; 214 };
197 215
198 } // namespace aura 216 } // namespace aura
199 217
200 #endif // UI_AURA_WINDOW_TREE_HOST_H_ 218 #endif // UI_AURA_WINDOW_TREE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698