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

Side by Side Diff: ash/common/shelf/shelf_window_watcher.h

Issue 2357143004: mash: Support ShelfWindowWatcher via ShelfItem properties. (Closed)
Patch Set: Address comments. Created 4 years, 2 months 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 | « ash/common/shelf/shelf_item_types.cc ('k') | ash/common/shelf/shelf_window_watcher.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 ASH_COMMON_SHELF_SHELF_WINDOW_WATCHER_H_ 5 #ifndef ASH_COMMON_SHELF_SHELF_WINDOW_WATCHER_H_
6 #define ASH_COMMON_SHELF_SHELF_WINDOW_WATCHER_H_ 6 #define ASH_COMMON_SHELF_SHELF_WINDOW_WATCHER_H_
7 7
8 #include "ash/common/wm_activation_observer.h" 8 #include "ash/common/wm_activation_observer.h"
9 #include "ash/common/wm_window_observer.h" 9 #include "ash/common/wm_window_observer.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/scoped_observer.h" 11 #include "base/scoped_observer.h"
12 #include "ui/display/display_observer.h" 12 #include "ui/display/display_observer.h"
13 13
14 namespace ash { 14 namespace ash {
15 15
16 class ShelfModel; 16 class ShelfModel;
17 class WmWindow; 17 class WmWindow;
18 18
19 // ShelfWindowWatcher creates and handles a ShelfItem for windows in the default 19 // ShelfWindowWatcher creates and handles a ShelfItem for windows in the default
20 // container that have a ShelfItemDetails property (e.g. the task manager 20 // container that have a valid ShelfItemType property (e.g. the task manager
21 // dialog or the OS settings window). It adds the ShelfItem when the window is 21 // dialog or the OS settings window). It adds the ShelfItem when the window is
22 // added to the default container and maintains it until the window is closed, 22 // added to the default container and maintains it until the window is closed,
23 // even if the window is transiently reparented (e.g. during a drag). 23 // even if the window is transiently reparented (e.g. during a drag).
24 class ShelfWindowWatcher : public WmActivationObserver, 24 class ShelfWindowWatcher : public WmActivationObserver,
25 public display::DisplayObserver { 25 public display::DisplayObserver {
26 public: 26 public:
27 explicit ShelfWindowWatcher(ShelfModel* model); 27 explicit ShelfWindowWatcher(ShelfModel* model);
28 ~ShelfWindowWatcher() override; 28 ~ShelfWindowWatcher() override;
29 29
30 private: 30 private:
31 // Observes for windows being added to a root window's default container. 31 // Observes for windows being added to a root window's default container.
32 class ContainerWindowObserver : public WmWindowObserver { 32 class ContainerWindowObserver : public WmWindowObserver {
33 public: 33 public:
34 explicit ContainerWindowObserver(ShelfWindowWatcher* window_watcher); 34 explicit ContainerWindowObserver(ShelfWindowWatcher* window_watcher);
35 ~ContainerWindowObserver() override; 35 ~ContainerWindowObserver() override;
36 36
37 private: 37 private:
38 // WmWindowObserver: 38 // WmWindowObserver:
39 void OnWindowTreeChanged(WmWindow* window, 39 void OnWindowTreeChanged(WmWindow* window,
40 const TreeChangeParams& params) override; 40 const TreeChangeParams& params) override;
41 void OnWindowDestroying(WmWindow* window) override; 41 void OnWindowDestroying(WmWindow* window) override;
42 42
43 ShelfWindowWatcher* window_watcher_; 43 ShelfWindowWatcher* window_watcher_;
44 44
45 DISALLOW_COPY_AND_ASSIGN(ContainerWindowObserver); 45 DISALLOW_COPY_AND_ASSIGN(ContainerWindowObserver);
46 }; 46 };
47 47
48 // Observes individual user windows to detect when they are closed or when 48 // Observes individual user windows to detect when they are closed or when
49 // they have ShelfItemDetails changed. 49 // their shelf item properties have changed.
50 class UserWindowObserver : public WmWindowObserver { 50 class UserWindowObserver : public WmWindowObserver {
51 public: 51 public:
52 explicit UserWindowObserver(ShelfWindowWatcher* window_watcher); 52 explicit UserWindowObserver(ShelfWindowWatcher* window_watcher);
53 ~UserWindowObserver() override; 53 ~UserWindowObserver() override;
54 54
55 private: 55 private:
56 // WmWindowObserver: 56 // WmWindowObserver:
57 void OnWindowPropertyChanged(WmWindow* window, 57 void OnWindowPropertyChanged(WmWindow* window,
58 WmWindowProperty property) override; 58 WmWindowProperty property) override;
59 void OnWindowDestroying(WmWindow* window) override; 59 void OnWindowDestroying(WmWindow* window) override;
60 60
61 ShelfWindowWatcher* window_watcher_; 61 ShelfWindowWatcher* window_watcher_;
62 62
63 DISALLOW_COPY_AND_ASSIGN(UserWindowObserver); 63 DISALLOW_COPY_AND_ASSIGN(UserWindowObserver);
64 }; 64 };
65 65
66 // Creates a ShelfItem for |window| that has ShelfItemDetails. 66 // Creates a ShelfItem for |window|.
67 void AddShelfItem(WmWindow* window); 67 void AddShelfItem(WmWindow* window);
68 68
69 // Removes a ShelfItem for |window|. 69 // Removes a ShelfItem for |window|.
70 void RemoveShelfItem(WmWindow* window); 70 void RemoveShelfItem(WmWindow* window);
71 71
72 // Updates the status of ShelfItem for |window|. 72 // Updates the status of ShelfItem for |window|.
73 void UpdateShelfItemStatus(WmWindow* window, bool is_active); 73 void UpdateShelfItemStatus(WmWindow* window, bool is_active);
74 74
75 // Returns the index of ShelfItem associated with |window|. 75 // Returns the index of ShelfItem associated with |window|.
76 int GetShelfItemIndexForWindow(WmWindow* window) const; 76 int GetShelfItemIndexForWindow(WmWindow* window) const;
77 77
78 // Cleans up observers on |container|. 78 // Cleans up observers on |container|.
79 void OnContainerWindowDestroying(WmWindow* container); 79 void OnContainerWindowDestroying(WmWindow* container);
80 80
81 // Adds a shelf item for new windows added to the default container that have 81 // Adds a shelf item for new windows added to the default container that have
82 // a ShelfItemDetails property. 82 // a valid ShelfItemType property value.
83 void OnUserWindowAdded(WmWindow* window); 83 void OnUserWindowAdded(WmWindow* window);
84 84
85 // Adds, updates or removes the shelf item based on a property change. 85 // Adds, updates or removes the shelf item based on a property change.
86 void OnUserWindowShelfItemDetailsChanged(WmWindow* window); 86 void OnUserWindowPropertyChanged(WmWindow* window);
87 87
88 // Removes the shelf item when a window closes. 88 // Removes the shelf item when a window closes.
89 void OnUserWindowDestroying(WmWindow* window); 89 void OnUserWindowDestroying(WmWindow* window);
90 90
91 // WmActivationObserver: 91 // WmActivationObserver:
92 void OnWindowActivated(WmWindow* gained_active, 92 void OnWindowActivated(WmWindow* gained_active,
93 WmWindow* lost_active) override; 93 WmWindow* lost_active) override;
94 94
95 // display::DisplayObserver overrides: 95 // display::DisplayObserver overrides:
96 void OnDisplayAdded(const display::Display& display) override; 96 void OnDisplayAdded(const display::Display& display) override;
97 void OnDisplayRemoved(const display::Display& old_display) override; 97 void OnDisplayRemoved(const display::Display& old_display) override;
98 void OnDisplayMetricsChanged(const display::Display& display, 98 void OnDisplayMetricsChanged(const display::Display& display,
99 uint32_t metrics) override; 99 uint32_t metrics) override;
100 100
101 ShelfModel* model_; 101 ShelfModel* model_;
102 102
103 ContainerWindowObserver container_window_observer_; 103 ContainerWindowObserver container_window_observer_;
104 UserWindowObserver user_window_observer_; 104 UserWindowObserver user_window_observer_;
105 105
106 ScopedObserver<WmWindow, ContainerWindowObserver> observed_container_windows_; 106 ScopedObserver<WmWindow, ContainerWindowObserver> observed_container_windows_;
107 ScopedObserver<WmWindow, UserWindowObserver> observed_user_windows_; 107 ScopedObserver<WmWindow, UserWindowObserver> observed_user_windows_;
108 108
109 DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcher); 109 DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcher);
110 }; 110 };
111 111
112 } // namespace ash 112 } // namespace ash
113 113
114 #endif // ASH_COMMON_SHELF_SHELF_WINDOW_WATCHER_H_ 114 #endif // ASH_COMMON_SHELF_SHELF_WINDOW_WATCHER_H_
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_item_types.cc ('k') | ash/common/shelf/shelf_window_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698