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

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

Issue 2462753002: Use Ash's ShelfWindowWatcher for app panel windows. (Closed)
Patch Set: Address comments. 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 | « ash/common/shelf/shelf_model.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 <set>
9
8 #include "ash/common/wm_activation_observer.h" 10 #include "ash/common/wm_activation_observer.h"
9 #include "ash/common/wm_window_observer.h" 11 #include "ash/common/wm_window_observer.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
12 #include "ui/display/display_observer.h" 14 #include "ui/display/display_observer.h"
13 15
14 namespace ash { 16 namespace ash {
15 17
16 class ShelfModel; 18 class ShelfModel;
17 class WmWindow; 19 class WmWindow;
18 20
19 // ShelfWindowWatcher creates and handles a ShelfItem for windows in the default 21 // ShelfWindowWatcher creates and handles a ShelfItem for windows in the default
20 // container that have a valid ShelfItemType property (e.g. the task manager 22 // container and panels in the panel container that have a valid ShelfItemType
21 // dialog or the OS settings window). It adds the ShelfItem when the window is 23 // property (e.g. the task manager dialog or the OS settings window). It adds
22 // added to the default container and maintains it until the window is closed, 24 // the ShelfItem when the window is added to the default container and maintains
23 // even if the window is transiently reparented (e.g. during a drag). 25 // it until the window is closed, even if the window is transiently reparented
26 // (e.g. during a drag).
24 class ShelfWindowWatcher : public WmActivationObserver, 27 class ShelfWindowWatcher : public WmActivationObserver,
25 public display::DisplayObserver { 28 public display::DisplayObserver {
26 public: 29 public:
27 explicit ShelfWindowWatcher(ShelfModel* model); 30 explicit ShelfWindowWatcher(ShelfModel* model);
28 ~ShelfWindowWatcher() override; 31 ~ShelfWindowWatcher() override;
29 32
30 private: 33 private:
31 // Observes for windows being added to a root window's default container. 34 // Observes for windows being added to a root window's default container.
32 class ContainerWindowObserver : public WmWindowObserver { 35 class ContainerWindowObserver : public WmWindowObserver {
33 public: 36 public:
(...skipping 28 matching lines...) Expand all
62 65
63 DISALLOW_COPY_AND_ASSIGN(UserWindowObserver); 66 DISALLOW_COPY_AND_ASSIGN(UserWindowObserver);
64 }; 67 };
65 68
66 // Creates a ShelfItem for |window|. 69 // Creates a ShelfItem for |window|.
67 void AddShelfItem(WmWindow* window); 70 void AddShelfItem(WmWindow* window);
68 71
69 // Removes a ShelfItem for |window|. 72 // Removes a ShelfItem for |window|.
70 void RemoveShelfItem(WmWindow* window); 73 void RemoveShelfItem(WmWindow* window);
71 74
72 // Updates the status of ShelfItem for |window|. 75 // Returns the index of ShelfItem associated with |window|, or -1 if none.
73 void UpdateShelfItemStatus(WmWindow* window, bool is_active);
74
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 valid ShelfItemType property value. 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.
(...skipping 13 matching lines...) Expand all
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 // The set of windows with shelf items managed by this ShelfWindowWatcher.
110 std::set<WmWindow*> user_windows_with_items_;
111
109 DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcher); 112 DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcher);
110 }; 113 };
111 114
112 } // namespace ash 115 } // namespace ash
113 116
114 #endif // ASH_COMMON_SHELF_SHELF_WINDOW_WATCHER_H_ 117 #endif // ASH_COMMON_SHELF_SHELF_WINDOW_WATCHER_H_
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_model.cc ('k') | ash/common/shelf/shelf_window_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698