Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: ui/wm/core/capture_controller.h

Issue 2466023003: Makes CaptureController be created and owned by WMState (Closed)
Patch Set: moar Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/test/views_test_helper_aura.cc ('k') | ui/wm/core/capture_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_WM_CORE_CAPTURE_CONTROLLER_H_ 5 #ifndef UI_WM_CORE_CAPTURE_CONTROLLER_H_
6 #define UI_WM_CORE_CAPTURE_CONTROLLER_H_ 6 #define UI_WM_CORE_CAPTURE_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 9
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/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/wm/wm_export.h" 14 #include "ui/wm/wm_export.h"
15 15
16 namespace aura { 16 namespace aura {
17 namespace client { 17 namespace client {
18 class CaptureDelegate; 18 class CaptureDelegate;
19 } 19 }
20 } 20 }
21 21
22 namespace wm { 22 namespace wm {
23 23
24 // Internal CaptureClient implementation. See ScopedCaptureClient for details. 24 // Internal CaptureClient implementation. See ScopedCaptureClient for details.
25 class WM_EXPORT CaptureController : public aura::client::CaptureClient { 25 class WM_EXPORT CaptureController : public aura::client::CaptureClient {
26 public: 26 public:
27 CaptureController();
28 ~CaptureController() override;
29
30 static CaptureController* Get() { return instance_; }
31
27 // Adds |root| to the list of root windows notified when capture changes. 32 // Adds |root| to the list of root windows notified when capture changes.
28 void Attach(aura::Window* root); 33 void Attach(aura::Window* root);
29 34
30 // Removes |root| from the list of root windows notified when capture changes. 35 // Removes |root| from the list of root windows notified when capture changes.
31 void Detach(aura::Window* root); 36 void Detach(aura::Window* root);
32 37
33 // Returns true if this CaptureController is installed on at least one 38 // Returns true if this CaptureController is installed on at least one
34 // root window. 39 // root window.
35 bool is_active() const { return !delegates_.empty(); } 40 bool is_active() const { return !delegates_.empty(); }
36 41
37 // Overridden from aura::client::CaptureClient: 42 // Overridden from aura::client::CaptureClient:
38 void SetCapture(aura::Window* window) override; 43 void SetCapture(aura::Window* window) override;
39 void ReleaseCapture(aura::Window* window) override; 44 void ReleaseCapture(aura::Window* window) override;
40 aura::Window* GetCaptureWindow() override; 45 aura::Window* GetCaptureWindow() override;
41 aura::Window* GetGlobalCaptureWindow() override; 46 aura::Window* GetGlobalCaptureWindow() override;
42 void AddObserver(aura::client::CaptureClientObserver* observer) override; 47 void AddObserver(aura::client::CaptureClientObserver* observer) override;
43 void RemoveObserver(aura::client::CaptureClientObserver* observer) override; 48 void RemoveObserver(aura::client::CaptureClientObserver* observer) override;
44 49
45 private: 50 private:
46 friend class ScopedCaptureClient; 51 friend class ScopedCaptureClient;
47 52
48 CaptureController(); 53 static CaptureController* instance_;
49 ~CaptureController() override;
50 54
51 // The current capture window. NULL if there is no capture window. 55 // The current capture window. NULL if there is no capture window.
52 aura::Window* capture_window_; 56 aura::Window* capture_window_;
53 57
54 // The capture delegate for the root window with native capture. The root 58 // The capture delegate for the root window with native capture. The root
55 // window with native capture may not contain |capture_window_|. This occurs 59 // window with native capture may not contain |capture_window_|. This occurs
56 // if |capture_window_| is reparented to a different root window while it has 60 // if |capture_window_| is reparented to a different root window while it has
57 // capture. 61 // capture.
58 aura::client::CaptureDelegate* capture_delegate_; 62 aura::client::CaptureDelegate* capture_delegate_;
59 63
(...skipping 21 matching lines...) Expand all
81 private: 85 private:
82 // Not owned. 86 // Not owned.
83 ScopedCaptureClient* client_; 87 ScopedCaptureClient* client_;
84 88
85 DISALLOW_COPY_AND_ASSIGN(TestApi); 89 DISALLOW_COPY_AND_ASSIGN(TestApi);
86 }; 90 };
87 91
88 explicit ScopedCaptureClient(aura::Window* root); 92 explicit ScopedCaptureClient(aura::Window* root);
89 ~ScopedCaptureClient() override; 93 ~ScopedCaptureClient() override;
90 94
91 // Returns true if there is a CaptureController with at least one RootWindow.
92 static bool IsActive();
93
94 aura::client::CaptureClient* capture_client() {
95 return capture_controller_;
96 }
97
98 // Overridden from aura::WindowObserver: 95 // Overridden from aura::WindowObserver:
99 void OnWindowDestroyed(aura::Window* window) override; 96 void OnWindowDestroyed(aura::Window* window) override;
100 97
101 private: 98 private:
102 // Invoked from destructor and OnWindowDestroyed() to cleanup. 99 // Invoked from destructor and OnWindowDestroyed() to cleanup.
103 void Shutdown(); 100 void Shutdown();
104 101
105 // The single CaptureController instance.
106 static CaptureController* capture_controller_;
107
108 // RootWindow this ScopedCaptureClient was create for. 102 // RootWindow this ScopedCaptureClient was create for.
109 aura::Window* root_window_; 103 aura::Window* root_window_;
110 104
111 DISALLOW_COPY_AND_ASSIGN(ScopedCaptureClient); 105 DISALLOW_COPY_AND_ASSIGN(ScopedCaptureClient);
112 }; 106 };
113 107
114 } // namespace wm 108 } // namespace wm
115 109
116 #endif // UI_WM_CORE_CAPTURE_CONTROLLER_H_ 110 #endif // UI_WM_CORE_CAPTURE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ui/views/test/views_test_helper_aura.cc ('k') | ui/wm/core/capture_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698