OLD | NEW |
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 #include "ash/shell/window_watcher.h" | 5 #include "ash/shell/window_watcher.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
9 #include "ash/shelf/shelf_item_delegate_manager.h" | 9 #include "ash/shelf/shelf_item_delegate_manager.h" |
10 #include "ash/shelf/shelf_model.h" | 10 #include "ash/shelf/shelf_model.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE { | 31 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE { |
32 new_window->AddObserver(watcher_); | 32 new_window->AddObserver(watcher_); |
33 } | 33 } |
34 | 34 |
35 virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE { | 35 virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE { |
36 DCHECK(window->children().empty()); | 36 DCHECK(window->children().empty()); |
37 window->RemoveObserver(watcher_); | 37 window->RemoveObserver(watcher_); |
38 } | 38 } |
39 | 39 |
40 void RootWindowAdded(aura::Window* root) { | 40 void RootWindowAdded(aura::Window* root) { |
41 aura::Window* panel_container = ash::Shell::GetContainer( | 41 aura::Window* panel_container = |
42 root, | 42 ash::Shell::GetContainer(root, kShellWindowId_PanelContainer); |
43 internal::kShellWindowId_PanelContainer); | |
44 panel_container->AddObserver(watcher_); | 43 panel_container->AddObserver(watcher_); |
45 | 44 |
46 aura::Window* container = | 45 aura::Window* container = |
47 Shelf::ForWindow(root)->shelf_widget()->window_container(); | 46 Shelf::ForWindow(root)->shelf_widget()->window_container(); |
48 container->AddObserver(this); | 47 container->AddObserver(this); |
49 for (size_t i = 0; i < container->children().size(); ++i) | 48 for (size_t i = 0; i < container->children().size(); ++i) |
50 container->children()[i]->AddObserver(watcher_); | 49 container->children()[i]->AddObserver(watcher_); |
51 } | 50 } |
52 | 51 |
53 void RootWindowRemoved(aura::Window* root) { | 52 void RootWindowRemoved(aura::Window* root) { |
54 aura::Window* panel_container = ash::Shell::GetContainer( | 53 aura::Window* panel_container = |
55 root, | 54 ash::Shell::GetContainer(root, kShellWindowId_PanelContainer); |
56 internal::kShellWindowId_PanelContainer); | |
57 panel_container->RemoveObserver(watcher_); | 55 panel_container->RemoveObserver(watcher_); |
58 | 56 |
59 aura::Window* container = | 57 aura::Window* container = |
60 Shelf::ForWindow(root)->shelf_widget()->window_container(); | 58 Shelf::ForWindow(root)->shelf_widget()->window_container(); |
61 container->RemoveObserver(this); | 59 container->RemoveObserver(this); |
62 for (size_t i = 0; i < container->children().size(); ++i) | 60 for (size_t i = 0; i < container->children().size(); ++i) |
63 container->children()[i]->RemoveObserver(watcher_); | 61 container->children()[i]->RemoveObserver(watcher_); |
64 } | 62 } |
65 | 63 |
66 private: | 64 private: |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 workspace_window_watcher_->RootWindowAdded(root); | 147 workspace_window_watcher_->RootWindowAdded(root); |
150 } | 148 } |
151 | 149 |
152 void WindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) { | 150 void WindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) { |
153 // All windows in the display has already been removed, so no need to | 151 // All windows in the display has already been removed, so no need to |
154 // remove observers. | 152 // remove observers. |
155 } | 153 } |
156 | 154 |
157 } // namespace shell | 155 } // namespace shell |
158 } // namespace ash | 156 } // namespace ash |
OLD | NEW |