| OLD | NEW |
| 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_VIEWS_COREWM_CAPTURE_CONTROLLER_H_ | 5 #ifndef UI_VIEWS_COREWM_CAPTURE_CONTROLLER_H_ |
| 6 #define UI_VIEWS_COREWM_CAPTURE_CONTROLLER_H_ | 6 #define UI_VIEWS_COREWM_CAPTURE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "ui/aura/client/capture_client.h" | 12 #include "ui/aura/client/capture_client.h" |
| 13 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
| 14 #include "ui/views/views_export.h" | 14 #include "ui/views/views_export.h" |
| 15 | 15 |
| 16 namespace aura { | |
| 17 class RootWindow; | |
| 18 } | |
| 19 | |
| 20 namespace views { | 16 namespace views { |
| 21 namespace corewm { | 17 namespace corewm { |
| 22 | 18 |
| 23 // Internal CaptureClient implementation. See ScopedCaptureClient for details. | 19 // Internal CaptureClient implementation. See ScopedCaptureClient for details. |
| 24 class VIEWS_EXPORT CaptureController : public aura::client::CaptureClient { | 20 class VIEWS_EXPORT CaptureController : public aura::client::CaptureClient { |
| 25 public: | 21 public: |
| 26 // Adds |root| to the list of RootWindows notified when capture changes. | 22 // Adds |root| to the list of RootWindows notified when capture changes. |
| 27 void Attach(aura::RootWindow* root); | 23 void Attach(aura::Window* root); |
| 28 | 24 |
| 29 // Removes |root| from the list of RootWindows notified when capture changes. | 25 // Removes |root| from the list of RootWindows notified when capture changes. |
| 30 void Detach(aura::RootWindow* root); | 26 void Detach(aura::Window* root); |
| 31 | 27 |
| 32 // Returns true if this CaptureController is installed on at least one | 28 // Returns true if this CaptureController is installed on at least one |
| 33 // RootWindow. | 29 // RootWindow. |
| 34 bool is_active() const { return !root_windows_.empty(); } | 30 bool is_active() const { return !root_windows_.empty(); } |
| 35 | 31 |
| 36 // Overridden from aura::client::CaptureClient: | 32 // Overridden from aura::client::CaptureClient: |
| 37 virtual void SetCapture(aura::Window* window) OVERRIDE; | 33 virtual void SetCapture(aura::Window* window) OVERRIDE; |
| 38 virtual void ReleaseCapture(aura::Window* window) OVERRIDE; | 34 virtual void ReleaseCapture(aura::Window* window) OVERRIDE; |
| 39 virtual aura::Window* GetCaptureWindow() OVERRIDE; | 35 virtual aura::Window* GetCaptureWindow() OVERRIDE; |
| 40 | 36 |
| 41 private: | 37 private: |
| 42 friend class ScopedCaptureClient; | 38 friend class ScopedCaptureClient; |
| 43 typedef std::set<aura::RootWindow*> RootWindows; | 39 typedef std::set<aura::Window*> RootWindows; |
| 44 | 40 |
| 45 CaptureController(); | 41 CaptureController(); |
| 46 virtual ~CaptureController(); | 42 virtual ~CaptureController(); |
| 47 | 43 |
| 48 // The current capture window. NULL if there is no capture window. | 44 // The current capture window. NULL if there is no capture window. |
| 49 aura::Window* capture_window_; | 45 aura::Window* capture_window_; |
| 50 | 46 |
| 51 // Set of RootWindows notified when capture changes. | 47 // Set of RootWindows notified when capture changes. |
| 52 RootWindows root_windows_; | 48 RootWindows root_windows_; |
| 53 | 49 |
| 54 DISALLOW_COPY_AND_ASSIGN(CaptureController); | 50 DISALLOW_COPY_AND_ASSIGN(CaptureController); |
| 55 }; | 51 }; |
| 56 | 52 |
| 57 // ScopedCaptureClient is responsible for creating a CaptureClient for a | 53 // ScopedCaptureClient is responsible for creating a CaptureClient for a |
| 58 // RootWindow. Specifically it creates a single CaptureController that is shared | 54 // RootWindow. Specifically it creates a single CaptureController that is shared |
| 59 // among all ScopedCaptureClients and adds the RootWindow to it. | 55 // among all ScopedCaptureClients and adds the RootWindow to it. |
| 60 class VIEWS_EXPORT ScopedCaptureClient : public aura::WindowObserver { | 56 class VIEWS_EXPORT ScopedCaptureClient : public aura::WindowObserver { |
| 61 public: | 57 public: |
| 62 explicit ScopedCaptureClient(aura::RootWindow* root); | 58 explicit ScopedCaptureClient(aura::Window* root); |
| 63 virtual ~ScopedCaptureClient(); | 59 virtual ~ScopedCaptureClient(); |
| 64 | 60 |
| 65 // Returns true if there is a CaptureController with at least one RootWindow. | 61 // Returns true if there is a CaptureController with at least one RootWindow. |
| 66 static bool IsActive(); | 62 static bool IsActive(); |
| 67 | 63 |
| 68 aura::client::CaptureClient* capture_client() { | 64 aura::client::CaptureClient* capture_client() { |
| 69 return capture_controller_; | 65 return capture_controller_; |
| 70 } | 66 } |
| 71 | 67 |
| 72 // Overridden from aura::WindowObserver: | 68 // Overridden from aura::WindowObserver: |
| 73 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | 69 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
| 74 | 70 |
| 75 private: | 71 private: |
| 76 // Invoked from destructor and OnWindowDestroyed() to cleanup. | 72 // Invoked from destructor and OnWindowDestroyed() to cleanup. |
| 77 void Shutdown(); | 73 void Shutdown(); |
| 78 | 74 |
| 79 // The single CaptureController instance. | 75 // The single CaptureController instance. |
| 80 static CaptureController* capture_controller_; | 76 static CaptureController* capture_controller_; |
| 81 | 77 |
| 82 // RootWindow this ScopedCaptureClient was create for. | 78 // RootWindow this ScopedCaptureClient was create for. |
| 83 aura::RootWindow* root_window_; | 79 aura::Window* root_window_; |
| 84 | 80 |
| 85 DISALLOW_COPY_AND_ASSIGN(ScopedCaptureClient); | 81 DISALLOW_COPY_AND_ASSIGN(ScopedCaptureClient); |
| 86 }; | 82 }; |
| 87 | 83 |
| 88 } // namespace corewm | 84 } // namespace corewm |
| 89 } // namespace views | 85 } // namespace views |
| 90 | 86 |
| 91 #endif // UI_VIEWS_COREWM_CAPTURE_CONTROLLER_H_ | 87 #endif // UI_VIEWS_COREWM_CAPTURE_CONTROLLER_H_ |
| OLD | NEW |