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