Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DESKTOP_H_ | 5 #ifndef UI_AURA_DESKTOP_H_ |
| 6 #define UI_AURA_DESKTOP_H_ | 6 #define UI_AURA_DESKTOP_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 namespace aura { | 25 namespace aura { |
| 26 | 26 |
| 27 class DesktopDelegate; | 27 class DesktopDelegate; |
| 28 class DesktopHost; | 28 class DesktopHost; |
| 29 class MouseEvent; | 29 class MouseEvent; |
| 30 | 30 |
| 31 // Desktop is responsible for hosting a set of windows. | 31 // Desktop is responsible for hosting a set of windows. |
| 32 class AURA_EXPORT Desktop : public ui::CompositorDelegate { | 32 class AURA_EXPORT Desktop : public ui::CompositorDelegate { |
| 33 public: | 33 public: |
| 34 // Observers can listen to various events on the Desktop. | |
| 35 class Observer { | |
| 36 public: | |
| 37 virtual void OnDesktopResized(const gfx::Size& new_size) {} | |
|
sky
2011/10/12 21:11:27
I think we should make these pure virtual. Also, a
sadrul
2011/10/12 21:33:23
Done. I kept the empty implementation for WindowOb
| |
| 38 }; | |
| 39 | |
| 34 Desktop(); | 40 Desktop(); |
| 35 virtual ~Desktop(); | 41 virtual ~Desktop(); |
| 36 | 42 |
| 37 DesktopDelegate* delegate() { return delegate_.get(); } | 43 DesktopDelegate* delegate() { return delegate_.get(); } |
| 38 void SetDelegate(DesktopDelegate* delegate); | 44 void SetDelegate(DesktopDelegate* delegate); |
| 39 | 45 |
| 40 // Initializes the desktop. | 46 // Initializes the desktop. |
| 41 void Init(); | 47 void Init(); |
| 42 | 48 |
| 43 // Shows the desktop host. | 49 // Shows the desktop host. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 | 99 |
| 94 // Invoked from RootWindow when |window| is being destroyed. | 100 // Invoked from RootWindow when |window| is being destroyed. |
| 95 void WindowDestroying(Window* window); | 101 void WindowDestroying(Window* window); |
| 96 | 102 |
| 97 // Returns the desktop's dispatcher. The result should only be passed to | 103 // Returns the desktop's dispatcher. The result should only be passed to |
| 98 // MessageLoopForUI::Run() or MessageLoopForUI::RunAllPendingWithDispatcher(), | 104 // MessageLoopForUI::Run() or MessageLoopForUI::RunAllPendingWithDispatcher(), |
| 99 // or used to dispatch an event by |Dispatch(const NativeEvent&)| on it. | 105 // or used to dispatch an event by |Dispatch(const NativeEvent&)| on it. |
| 100 // It must never be stored. | 106 // It must never be stored. |
| 101 MessageLoop::Dispatcher* GetDispatcher(); | 107 MessageLoop::Dispatcher* GetDispatcher(); |
| 102 | 108 |
| 109 // Add/remove observer. | |
| 110 void AddObserver(Observer* observer); | |
| 111 void RemoveObserver(Observer* observer); | |
| 112 bool HasObserver(Observer* observer); | |
|
sky
2011/10/12 21:11:27
Unless we need HasObserver, don't add it.
sadrul
2011/10/12 21:33:23
It's not needed right now. Removed.
| |
| 113 | |
| 103 static Desktop* GetInstance(); | 114 static Desktop* GetInstance(); |
| 104 | 115 |
| 105 private: | 116 private: |
| 106 // Overridden from ui::CompositorDelegate | 117 // Overridden from ui::CompositorDelegate |
| 107 virtual void ScheduleDraw(); | 118 virtual void ScheduleDraw(); |
| 108 | 119 |
| 109 scoped_ptr<DesktopDelegate> delegate_; | 120 scoped_ptr<DesktopDelegate> delegate_; |
| 110 | 121 |
| 111 scoped_refptr<ui::Compositor> compositor_; | 122 scoped_refptr<ui::Compositor> compositor_; |
| 112 | 123 |
| 113 scoped_ptr<internal::RootWindow> window_; | 124 scoped_ptr<internal::RootWindow> window_; |
| 114 | 125 |
| 115 scoped_ptr<DesktopHost> host_; | 126 scoped_ptr<DesktopHost> host_; |
| 116 | 127 |
| 117 static Desktop* instance_; | 128 static Desktop* instance_; |
| 118 | 129 |
| 119 // Used to schedule painting. | 130 // Used to schedule painting. |
| 120 base::WeakPtrFactory<Desktop> schedule_paint_factory_; | 131 base::WeakPtrFactory<Desktop> schedule_paint_factory_; |
| 121 | 132 |
| 122 // Factory used to create Compositors. Settable by tests. | 133 // Factory used to create Compositors. Settable by tests. |
| 123 static ui::Compositor*(*compositor_factory_)(); | 134 static ui::Compositor*(*compositor_factory_)(); |
| 124 | 135 |
| 125 Window* active_window_; | 136 Window* active_window_; |
| 126 | 137 |
| 127 // Are we in the process of being destroyed? Used to avoid processing during | 138 // Are we in the process of being destroyed? Used to avoid processing during |
| 128 // destruction. | 139 // destruction. |
| 129 bool in_destructor_; | 140 bool in_destructor_; |
| 130 | 141 |
| 142 ObserverList<Observer> observers_; | |
| 143 | |
| 131 DISALLOW_COPY_AND_ASSIGN(Desktop); | 144 DISALLOW_COPY_AND_ASSIGN(Desktop); |
| 132 }; | 145 }; |
| 133 | 146 |
| 134 } // namespace aura | 147 } // namespace aura |
| 135 | 148 |
| 136 #endif // UI_AURA_DESKTOP_H_ | 149 #endif // UI_AURA_DESKTOP_H_ |
| OLD | NEW |