| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/shelf/shelf_item_delegate_manager.h" | |
| 10 #include "ash/common/shelf/shelf_model.h" | 9 #include "ash/common/shelf/shelf_model.h" |
| 11 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| 12 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 13 #include "ash/display/window_tree_host_manager.h" | 12 #include "ash/display/window_tree_host_manager.h" |
| 14 #include "ash/shelf/shelf.h" | 13 #include "ash/shelf/shelf.h" |
| 15 #include "ash/shelf/shelf_util.h" | 14 #include "ash/shelf/shelf_util.h" |
| 16 #include "ash/shelf/shelf_widget.h" | 15 #include "ash/shelf/shelf_widget.h" |
| 17 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 18 #include "ash/shell/window_watcher_shelf_item_delegate.h" | 17 #include "ash/shell/window_watcher_shelf_item_delegate.h" |
| 19 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 106 |
| 108 SkBitmap icon_bitmap; | 107 SkBitmap icon_bitmap; |
| 109 icon_bitmap.allocN32Pixels(16, 16); | 108 icon_bitmap.allocN32Pixels(16, 16); |
| 110 icon_bitmap.eraseARGB(255, image_count == 0 ? 255 : 0, | 109 icon_bitmap.eraseARGB(255, image_count == 0 ? 255 : 0, |
| 111 image_count == 1 ? 255 : 0, image_count == 2 ? 255 : 0); | 110 image_count == 1 ? 255 : 0, image_count == 2 ? 255 : 0); |
| 112 image_count = (image_count + 1) % 3; | 111 image_count = (image_count + 1) % 3; |
| 113 item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, 1.0f)); | 112 item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, 1.0f)); |
| 114 | 113 |
| 115 model->Add(item); | 114 model->Add(item); |
| 116 | 115 |
| 117 ShelfItemDelegateManager* manager = | |
| 118 Shell::GetInstance()->shelf_item_delegate_manager(); | |
| 119 std::unique_ptr<ShelfItemDelegate> delegate( | 116 std::unique_ptr<ShelfItemDelegate> delegate( |
| 120 new WindowWatcherShelfItemDelegate(id, this)); | 117 new WindowWatcherShelfItemDelegate(id, this)); |
| 121 manager->SetShelfItemDelegate(id, std::move(delegate)); | 118 model->SetShelfItemDelegate(id, std::move(delegate)); |
| 122 SetShelfIDForWindow(id, new_window); | 119 SetShelfIDForWindow(id, new_window); |
| 123 } | 120 } |
| 124 | 121 |
| 125 void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { | 122 void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { |
| 126 for (IDToWindow::iterator i = id_to_window_.begin(); i != id_to_window_.end(); | 123 for (IDToWindow::iterator i = id_to_window_.begin(); i != id_to_window_.end(); |
| 127 ++i) { | 124 ++i) { |
| 128 if (i->second == window) { | 125 if (i->second == window) { |
| 129 ShelfModel* model = WmShell::Get()->shelf_model(); | 126 ShelfModel* model = WmShell::Get()->shelf_model(); |
| 130 int index = model->ItemIndexByID(i->first); | 127 int index = model->ItemIndexByID(i->first); |
| 131 DCHECK_NE(-1, index); | 128 DCHECK_NE(-1, index); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 146 void WindowWatcher::OnDisplayRemoved(const display::Display& old_display) { | 143 void WindowWatcher::OnDisplayRemoved(const display::Display& old_display) { |
| 147 // All windows in the display has already been removed, so no need to | 144 // All windows in the display has already been removed, so no need to |
| 148 // remove observers. | 145 // remove observers. |
| 149 } | 146 } |
| 150 | 147 |
| 151 void WindowWatcher::OnDisplayMetricsChanged(const display::Display&, uint32_t) { | 148 void WindowWatcher::OnDisplayMetricsChanged(const display::Display&, uint32_t) { |
| 152 } | 149 } |
| 153 | 150 |
| 154 } // namespace shell | 151 } // namespace shell |
| 155 } // namespace ash | 152 } // namespace ash |
| OLD | NEW |