OLD | NEW |
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_SHELF_SHELF_WINDOW_WATCHER_H_ | 5 #ifndef ASH_SHELF_SHELF_WINDOW_WATCHER_H_ |
6 #define ASH_SHELF_SHELF_WINDOW_WATCHER_H_ | 6 #define ASH_SHELF_SHELF_WINDOW_WATCHER_H_ |
7 | 7 |
8 #include "ash/shelf/scoped_observer_with_duplicated_sources.h" | 8 #include "ash/shelf/scoped_observer_with_duplicated_sources.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 private: | 49 private: |
50 // aura::WindowObserver overrides: | 50 // aura::WindowObserver overrides: |
51 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 51 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
52 | 52 |
53 // Owned by Shell. | 53 // Owned by Shell. |
54 ShelfWindowWatcher* window_watcher_; | 54 ShelfWindowWatcher* window_watcher_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(RootWindowObserver); | 56 DISALLOW_COPY_AND_ASSIGN(RootWindowObserver); |
57 }; | 57 }; |
58 | 58 |
| 59 // Used to track windows that are removed. See description of |
| 60 // ShelfWindowWatcher::StartObservingRemovedWindow() for more details. |
| 61 class RemovedWindowObserver : public aura::WindowObserver { |
| 62 public: |
| 63 explicit RemovedWindowObserver(ShelfWindowWatcher* window_watcher); |
| 64 virtual ~RemovedWindowObserver(); |
| 65 |
| 66 private: |
| 67 // aura::WindowObserver overrides: |
| 68 virtual void OnWindowParentChanged(aura::Window* window, |
| 69 aura::Window* parent) OVERRIDE; |
| 70 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
| 71 |
| 72 // Owned by Shell. |
| 73 ShelfWindowWatcher* window_watcher_; |
| 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(RemovedWindowObserver); |
| 76 }; |
| 77 |
59 // Creates a LauncherItem for |window| that has LauncherItemDetails. | 78 // Creates a LauncherItem for |window| that has LauncherItemDetails. |
60 void AddLauncherItem(aura::Window* window); | 79 void AddLauncherItem(aura::Window* window); |
61 | 80 |
62 // Removes a LauncherItem for |window|. | 81 // Removes a LauncherItem for |window|. |
63 void RemoveLauncherItem(aura::Window* window); | 82 void RemoveLauncherItem(aura::Window* window); |
64 | 83 |
65 // Adds observer to default container and ActivationClient of |root_window|. | 84 // Adds observer to default container and ActivationClient of |root_window|. |
66 void OnRootWindowAdded(aura::Window* root_window); | 85 void OnRootWindowAdded(aura::Window* root_window); |
67 | 86 |
68 // Removes observer from ActivationClient of |root_window|. | 87 // Removes observer from ActivationClient of |root_window|. |
69 void OnRootWindowRemoved(aura::Window* root_window); | 88 void OnRootWindowRemoved(aura::Window* root_window); |
70 | 89 |
71 // Updates the status of LauncherItem for |window|. | 90 // Updates the status of LauncherItem for |window|. |
72 void UpdateLauncherItemStatus(aura::Window* window, bool is_active); | 91 void UpdateLauncherItemStatus(aura::Window* window, bool is_active); |
73 | 92 |
74 // Returns the index of LauncherItem associated with |window|. | 93 // Returns the index of LauncherItem associated with |window|. |
75 int GetLauncherItemIndexForWindow(aura::Window* window) const; | 94 int GetLauncherItemIndexForWindow(aura::Window* window) const; |
76 | 95 |
| 96 // Used when a window is removed. During the dragging a window may be removed |
| 97 // and when the drag completes added back. When this happens we don't want to |
| 98 // remove the shelf item. StartObservingRemovedWindow, if necessary, attaches |
| 99 // an observer. When done, FinishObservingRemovedWindow() is invoked. |
| 100 void StartObservingRemovedWindow(aura::Window* window); |
| 101 |
| 102 // Stop observing |window| by RemovedWindowObserver and remove an item |
| 103 // associated with |window|. |
| 104 void FinishObservingRemovedWindow(aura::Window* window); |
| 105 |
77 // aura::client::ActivationChangeObserver overrides: | 106 // aura::client::ActivationChangeObserver overrides: |
78 virtual void OnWindowActivated(aura::Window* gained_active, | 107 virtual void OnWindowActivated(aura::Window* gained_active, |
79 aura::Window* lost_active) OVERRIDE; | 108 aura::Window* lost_active) OVERRIDE; |
80 | 109 |
81 // aura::WindowObserver overrides: | 110 // aura::WindowObserver overrides: |
82 virtual void OnWindowAdded(aura::Window* window) OVERRIDE; | 111 virtual void OnWindowAdded(aura::Window* window) OVERRIDE; |
83 virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE; | 112 virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE; |
84 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 113 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
85 virtual void OnWindowPropertyChanged(aura::Window* window, | 114 virtual void OnWindowPropertyChanged(aura::Window* window, |
86 const void* key, | 115 const void* key, |
87 intptr_t old) OVERRIDE; | 116 intptr_t old) OVERRIDE; |
88 | 117 |
89 // gfx::DisplayObserver overrides: | 118 // gfx::DisplayObserver overrides: |
90 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; | 119 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; |
91 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; | 120 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; |
92 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; | 121 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; |
93 | 122 |
94 // Owned by Shell. | 123 // Owned by Shell. |
95 ShelfModel* model_; | 124 ShelfModel* model_; |
96 ShelfItemDelegateManager* item_delegate_manager_; | 125 ShelfItemDelegateManager* item_delegate_manager_; |
97 | 126 |
98 RootWindowObserver root_window_observer_; | 127 RootWindowObserver root_window_observer_; |
99 | 128 |
| 129 RemovedWindowObserver removed_window_observer_; |
| 130 |
100 // Holds all observed windows. | 131 // Holds all observed windows. |
101 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; | 132 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_; |
102 | 133 |
103 // Holds all observed root windows. | 134 // Holds all observed root windows. |
104 ScopedObserver<aura::Window, aura::WindowObserver> observed_root_windows_; | 135 ScopedObserver<aura::Window, aura::WindowObserver> observed_root_windows_; |
105 | 136 |
| 137 // Holds removed windows that has an item from default container. |
| 138 ScopedObserver<aura::Window, aura::WindowObserver> observed_removed_windows_; |
| 139 |
106 // Holds all observed activation clients. | 140 // Holds all observed activation clients. |
107 ScopedObserverWithDuplicatedSources<aura::client::ActivationClient, | 141 ScopedObserverWithDuplicatedSources<aura::client::ActivationClient, |
108 aura::client::ActivationChangeObserver> observed_activation_clients_; | 142 aura::client::ActivationChangeObserver> observed_activation_clients_; |
109 | 143 |
110 DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcher); | 144 DISALLOW_COPY_AND_ASSIGN(ShelfWindowWatcher); |
111 }; | 145 }; |
112 | 146 |
113 } // namespace internal | 147 } // namespace internal |
114 } // namespace ash | 148 } // namespace ash |
115 | 149 |
116 #endif // ASH_SHELF_SHELF_WINDOW_WATCHER_H_ | 150 #endif // ASH_SHELF_SHELF_WINDOW_WATCHER_H_ |
OLD | NEW |