| 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/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
| 9 #include "ash/launcher/launcher_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" |
| 11 #include "ash/shelf/shelf_util.h" | 11 #include "ash/shelf/shelf_util.h" |
| 12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/shell/window_watcher_launcher_item_delegate.h" | 14 #include "ash/shell/window_watcher_shelf_item_delegate.h" |
| 15 #include "ash/shell_window_ids.h" | 15 #include "ash/shell_window_ids.h" |
| 16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
| 17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/gfx/display.h" | 18 #include "ui/gfx/display.h" |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 namespace shell { | 21 namespace shell { |
| 22 | 22 |
| 23 class WindowWatcher::WorkspaceWindowWatcher : public aura::WindowObserver { | 23 class WindowWatcher::WorkspaceWindowWatcher : public aura::WindowObserver { |
| 24 public: | 24 public: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 icon_bitmap.allocPixels(); | 110 icon_bitmap.allocPixels(); |
| 111 icon_bitmap.eraseARGB(255, | 111 icon_bitmap.eraseARGB(255, |
| 112 image_count == 0 ? 255 : 0, | 112 image_count == 0 ? 255 : 0, |
| 113 image_count == 1 ? 255 : 0, | 113 image_count == 1 ? 255 : 0, |
| 114 image_count == 2 ? 255 : 0); | 114 image_count == 2 ? 255 : 0); |
| 115 image_count = (image_count + 1) % 3; | 115 image_count = (image_count + 1) % 3; |
| 116 item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, 1.0f)); | 116 item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, 1.0f)); |
| 117 | 117 |
| 118 model->Add(item); | 118 model->Add(item); |
| 119 | 119 |
| 120 ash::LauncherItemDelegateManager* manager = | 120 ShelfItemDelegateManager* manager = |
| 121 ash::Shell::GetInstance()->launcher_item_delegate_manager(); | 121 Shell::GetInstance()->shelf_item_delegate_manager(); |
| 122 scoped_ptr<LauncherItemDelegate> delegate( | 122 scoped_ptr<ShelfItemDelegate> delegate( |
| 123 new WindowWatcherLauncherItemDelegate(id, this)); | 123 new WindowWatcherShelfItemDelegate(id, this)); |
| 124 manager->SetLauncherItemDelegate(id, delegate.Pass()); | 124 manager->SetShelfItemDelegate(id, delegate.Pass()); |
| 125 SetLauncherIDForWindow(id, new_window); | 125 SetLauncherIDForWindow(id, new_window); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { | 128 void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { |
| 129 for (IDToWindow::iterator i = id_to_window_.begin(); | 129 for (IDToWindow::iterator i = id_to_window_.begin(); |
| 130 i != id_to_window_.end(); ++i) { | 130 i != id_to_window_.end(); ++i) { |
| 131 if (i->second == window) { | 131 if (i->second == window) { |
| 132 ShelfModel* model = Shell::GetInstance()->shelf_model(); | 132 ShelfModel* model = Shell::GetInstance()->shelf_model(); |
| 133 int index = model->ItemIndexByID(i->first); | 133 int index = model->ItemIndexByID(i->first); |
| 134 DCHECK_NE(-1, index); | 134 DCHECK_NE(-1, index); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 148 workspace_window_watcher_->RootWindowAdded(root); | 148 workspace_window_watcher_->RootWindowAdded(root); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void WindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) { | 151 void WindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) { |
| 152 // All windows in the display has already been removed, so no need to | 152 // All windows in the display has already been removed, so no need to |
| 153 // remove observers. | 153 // remove observers. |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace shell | 156 } // namespace shell |
| 157 } // namespace ash | 157 } // namespace ash |
| OLD | NEW |