OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "athena/wm/public/window_manager.h" | 5 #include "athena/wm/public/window_manager.h" |
6 | 6 |
7 #include "athena/screen/public/screen_manager.h" | 7 #include "athena/screen/public/screen_manager.h" |
| 8 #include "athena/wm/public/window_manager_observer.h" |
8 #include "athena/wm/window_overview_mode.h" | 9 #include "athena/wm/window_overview_mode.h" |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/observer_list.h" |
10 #include "ui/aura/layout_manager.h" | 12 #include "ui/aura/layout_manager.h" |
11 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
12 #include "ui/wm/public/window_types.h" | 14 #include "ui/wm/public/window_types.h" |
13 | 15 |
14 namespace athena { | 16 namespace athena { |
15 namespace { | 17 namespace { |
16 | 18 |
17 class WindowManagerImpl : public WindowManager, | 19 class WindowManagerImpl : public WindowManager, |
18 public WindowOverviewModeDelegate, | 20 public WindowOverviewModeDelegate, |
19 public aura::WindowObserver { | 21 public aura::WindowObserver { |
20 public: | 22 public: |
21 WindowManagerImpl(); | 23 WindowManagerImpl(); |
22 virtual ~WindowManagerImpl(); | 24 virtual ~WindowManagerImpl(); |
23 | 25 |
24 void Layout(); | 26 void Layout(); |
25 | 27 |
26 // WindowManager: | 28 // WindowManager: |
27 virtual void ToggleOverview() OVERRIDE { | 29 virtual void ToggleOverview() OVERRIDE { |
28 if (overview_) | 30 if (overview_) { |
29 overview_.reset(); | 31 overview_.reset(); |
30 else | 32 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, |
| 33 OnOverviewModeExit()); |
| 34 } else { |
31 overview_ = WindowOverviewMode::Create(container_.get(), this); | 35 overview_ = WindowOverviewMode::Create(container_.get(), this); |
| 36 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, |
| 37 OnOverviewModeEnter()); |
| 38 } |
32 } | 39 } |
33 | 40 |
34 private: | 41 private: |
| 42 // WindowManager: |
| 43 virtual void AddObserver(WindowManagerObserver* observer) OVERRIDE { |
| 44 observers_.AddObserver(observer); |
| 45 } |
| 46 |
| 47 virtual void RemoveObserver(WindowManagerObserver* observer) OVERRIDE { |
| 48 observers_.RemoveObserver(observer); |
| 49 } |
| 50 |
35 // WindowOverviewModeDelegate: | 51 // WindowOverviewModeDelegate: |
36 virtual void OnSelectWindow(aura::Window* window) OVERRIDE { | 52 virtual void OnSelectWindow(aura::Window* window) OVERRIDE { |
37 CHECK_EQ(container_.get(), window->parent()); | 53 CHECK_EQ(container_.get(), window->parent()); |
38 container_->StackChildAtTop(window); | 54 container_->StackChildAtTop(window); |
39 overview_.reset(); | 55 overview_.reset(); |
| 56 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, |
| 57 OnOverviewModeExit()); |
40 } | 58 } |
41 | 59 |
42 // aura::WindowObserver | 60 // aura::WindowObserver |
43 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { | 61 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { |
44 if (window == container_) | 62 if (window == container_) |
45 container_.reset(); | 63 container_.reset(); |
46 } | 64 } |
47 | 65 |
48 scoped_ptr<aura::Window> container_; | 66 scoped_ptr<aura::Window> container_; |
49 scoped_ptr<ui::EventHandler> temp_handler_; | 67 scoped_ptr<ui::EventHandler> temp_handler_; |
50 scoped_ptr<WindowOverviewMode> overview_; | 68 scoped_ptr<WindowOverviewMode> overview_; |
| 69 ObserverList<WindowManagerObserver> observers_; |
51 | 70 |
52 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); | 71 DISALLOW_COPY_AND_ASSIGN(WindowManagerImpl); |
53 }; | 72 }; |
54 | 73 |
55 class WindowManagerImpl* instance = NULL; | 74 class WindowManagerImpl* instance = NULL; |
56 | 75 |
57 class AthenaContainerLayoutManager : public aura::LayoutManager { | 76 class AthenaContainerLayoutManager : public aura::LayoutManager { |
58 public: | 77 public: |
59 AthenaContainerLayoutManager() {} | 78 AthenaContainerLayoutManager() {} |
60 virtual ~AthenaContainerLayoutManager() {} | 79 virtual ~AthenaContainerLayoutManager() {} |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return instance; | 160 return instance; |
142 } | 161 } |
143 | 162 |
144 // static | 163 // static |
145 void WindowManager::Shutdown() { | 164 void WindowManager::Shutdown() { |
146 DCHECK(instance); | 165 DCHECK(instance); |
147 delete instance; | 166 delete instance; |
148 DCHECK(!instance); | 167 DCHECK(!instance); |
149 } | 168 } |
150 | 169 |
| 170 // static |
| 171 WindowManager* WindowManager::GetInstance() { |
| 172 DCHECK(instance); |
| 173 return instance; |
| 174 } |
| 175 |
151 } // namespace athena | 176 } // namespace athena |
OLD | NEW |