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 ASH_AURA_WM_WINDOW_AURA_H_ | 5 #ifndef ASH_AURA_WM_WINDOW_AURA_H_ |
6 #define ASH_AURA_WM_WINDOW_AURA_H_ | 6 #define ASH_AURA_WM_WINDOW_AURA_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
13 #include "ui/wm/core/transient_window_observer.h" | 13 #include "ui/wm/core/transient_window_observer.h" |
14 | 14 |
15 namespace ash { | 15 namespace ash { |
16 | 16 |
17 // WmWindowAura is tied to the life of the underlying aura::Window. | 17 // WmWindowAura is tied to the life of the underlying aura::Window. Use the |
| 18 // static Get() function to obtain a WmWindowAura from an aura::Window. |
18 class ASH_EXPORT WmWindowAura : public WmWindow, | 19 class ASH_EXPORT WmWindowAura : public WmWindow, |
19 public aura::WindowObserver, | 20 public aura::WindowObserver, |
20 public ::wm::TransientWindowObserver { | 21 public ::wm::TransientWindowObserver { |
21 public: | 22 public: |
22 explicit WmWindowAura(aura::Window* window); | |
23 // NOTE: this class is owned by the corresponding window. You shouldn't delete | 23 // NOTE: this class is owned by the corresponding window. You shouldn't delete |
24 // TODO(sky): friend deleter and make private. | 24 // TODO(sky): friend deleter and make private. |
25 ~WmWindowAura() override; | 25 ~WmWindowAura() override; |
26 | 26 |
27 // Returns a WmWindow for an aura::Window, creating if necessary. |window| may | 27 // Returns a WmWindow for an aura::Window, creating if necessary. |window| may |
28 // be null, in which case null is returned. | 28 // be null, in which case null is returned. |
29 static WmWindow* Get(aura::Window* window) { | 29 static WmWindow* Get(aura::Window* window) { |
30 return const_cast<WmWindow*>(Get(const_cast<const aura::Window*>(window))); | 30 return const_cast<WmWindow*>(Get(const_cast<const aura::Window*>(window))); |
31 } | 31 } |
32 static const WmWindow* Get(const aura::Window* window); | 32 static const WmWindow* Get(const aura::Window* window); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 std::unique_ptr<views::View> CreateViewWithRecreatedLayers() override; | 181 std::unique_ptr<views::View> CreateViewWithRecreatedLayers() override; |
182 void AddObserver(WmWindowObserver* observer) override; | 182 void AddObserver(WmWindowObserver* observer) override; |
183 void RemoveObserver(WmWindowObserver* observer) override; | 183 void RemoveObserver(WmWindowObserver* observer) override; |
184 bool HasObserver(const WmWindowObserver* observer) const override; | 184 bool HasObserver(const WmWindowObserver* observer) const override; |
185 void AddTransientWindowObserver(WmTransientWindowObserver* observer) override; | 185 void AddTransientWindowObserver(WmTransientWindowObserver* observer) override; |
186 void RemoveTransientWindowObserver( | 186 void RemoveTransientWindowObserver( |
187 WmTransientWindowObserver* observer) override; | 187 WmTransientWindowObserver* observer) override; |
188 void AddLimitedPreTargetHandler(ui::EventHandler* handler) override; | 188 void AddLimitedPreTargetHandler(ui::EventHandler* handler) override; |
189 void RemoveLimitedPreTargetHandler(ui::EventHandler* handler) override; | 189 void RemoveLimitedPreTargetHandler(ui::EventHandler* handler) override; |
190 | 190 |
191 private: | 191 protected: |
| 192 explicit WmWindowAura(aura::Window* window); |
| 193 |
| 194 // Returns true if a WmWindowAura has been created for |window|. |
| 195 static bool HasInstance(const aura::Window* window); |
| 196 |
| 197 base::ObserverList<WmWindowObserver>& observers() { return observers_; } |
| 198 |
192 // aura::WindowObserver: | 199 // aura::WindowObserver: |
193 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override; | 200 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override; |
194 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; | 201 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; |
195 void OnWindowStackingChanged(aura::Window* window) override; | 202 void OnWindowStackingChanged(aura::Window* window) override; |
196 void OnWindowPropertyChanged(aura::Window* window, | 203 void OnWindowPropertyChanged(aura::Window* window, |
197 const void* key, | 204 const void* key, |
198 intptr_t old) override; | 205 intptr_t old) override; |
199 void OnWindowBoundsChanged(aura::Window* window, | 206 void OnWindowBoundsChanged(aura::Window* window, |
200 const gfx::Rect& old_bounds, | 207 const gfx::Rect& old_bounds, |
201 const gfx::Rect& new_bounds) override; | 208 const gfx::Rect& new_bounds) override; |
202 void OnWindowDestroying(aura::Window* window) override; | 209 void OnWindowDestroying(aura::Window* window) override; |
203 void OnWindowDestroyed(aura::Window* window) override; | 210 void OnWindowDestroyed(aura::Window* window) override; |
204 void OnWindowVisibilityChanging(aura::Window* window, bool visible) override; | 211 void OnWindowVisibilityChanging(aura::Window* window, bool visible) override; |
205 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; | 212 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; |
206 void OnWindowTitleChanged(aura::Window* window) override; | 213 void OnWindowTitleChanged(aura::Window* window) override; |
207 | 214 |
208 // ::wm::TransientWindowObserver overrides: | 215 // ::wm::TransientWindowObserver overrides: |
209 void OnTransientChildAdded(aura::Window* window, | 216 void OnTransientChildAdded(aura::Window* window, |
210 aura::Window* transient) override; | 217 aura::Window* transient) override; |
211 void OnTransientChildRemoved(aura::Window* window, | 218 void OnTransientChildRemoved(aura::Window* window, |
212 aura::Window* transient) override; | 219 aura::Window* transient) override; |
213 | 220 |
| 221 private: |
214 aura::Window* window_; | 222 aura::Window* window_; |
215 | 223 |
216 base::ObserverList<WmWindowObserver> observers_; | 224 base::ObserverList<WmWindowObserver> observers_; |
217 | 225 |
218 bool added_transient_observer_ = false; | 226 bool added_transient_observer_ = false; |
219 base::ObserverList<WmTransientWindowObserver> transient_observers_; | 227 base::ObserverList<WmTransientWindowObserver> transient_observers_; |
220 | 228 |
221 DISALLOW_COPY_AND_ASSIGN(WmWindowAura); | 229 DISALLOW_COPY_AND_ASSIGN(WmWindowAura); |
222 }; | 230 }; |
223 | 231 |
224 } // namespace ash | 232 } // namespace ash |
225 | 233 |
226 #endif // ASH_AURA_WM_WINDOW_AURA_H_ | 234 #endif // ASH_AURA_WM_WINDOW_AURA_H_ |
OLD | NEW |