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/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 void WindowWatcher::OnWindowAdded(aura::Window* new_window) { | 45 void WindowWatcher::OnWindowAdded(aura::Window* new_window) { |
46 if (new_window->type() != aura::client::WINDOW_TYPE_NORMAL && | 46 if (new_window->type() != aura::client::WINDOW_TYPE_NORMAL && |
47 new_window->type() != aura::client::WINDOW_TYPE_PANEL) | 47 new_window->type() != aura::client::WINDOW_TYPE_PANEL) |
48 return; | 48 return; |
49 | 49 |
50 static int image_count = 0; | 50 static int image_count = 0; |
51 ash::LauncherModel* model = ash::Shell::GetInstance()->launcher()->model(); | 51 ash::LauncherModel* model = ash::Shell::GetInstance()->launcher()->model(); |
52 ash::LauncherItem item; | 52 ash::LauncherItem item; |
53 item.type = ash::TYPE_TABBED; | 53 item.type = ash::TYPE_TABBED; |
54 id_to_window_[model->next_id()] = new_window; | 54 id_to_window_[model->next_id()] = new_window; |
55 item.image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); | 55 |
56 item.image.allocPixels(); | 56 SkBitmap icon_bitmap; |
57 item.image.eraseARGB(255, | 57 icon_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); |
58 image_count == 0 ? 255 : 0, | 58 icon_bitmap.allocPixels(); |
59 image_count == 1 ? 255 : 0, | 59 icon_bitmap.eraseARGB(255, |
60 image_count == 2 ? 255 : 0); | 60 image_count == 0 ? 255 : 0, |
| 61 image_count == 1 ? 255 : 0, |
| 62 image_count == 2 ? 255 : 0); |
61 image_count = (image_count + 1) % 3; | 63 image_count = (image_count + 1) % 3; |
| 64 item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, |
| 65 ui::SCALE_FACTOR_NONE)); |
| 66 |
62 model->Add(item); | 67 model->Add(item); |
63 } | 68 } |
64 | 69 |
65 void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { | 70 void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { |
66 for (IDToWindow::iterator i = id_to_window_.begin(); | 71 for (IDToWindow::iterator i = id_to_window_.begin(); |
67 i != id_to_window_.end(); ++i) { | 72 i != id_to_window_.end(); ++i) { |
68 if (i->second == window) { | 73 if (i->second == window) { |
69 ash::LauncherModel* model = | 74 ash::LauncherModel* model = |
70 ash::Shell::GetInstance()->launcher()->model(); | 75 ash::Shell::GetInstance()->launcher()->model(); |
71 int index = model->ItemIndexByID(i->first); | 76 int index = model->ItemIndexByID(i->first); |
72 DCHECK_NE(-1, index); | 77 DCHECK_NE(-1, index); |
73 model->RemoveItemAt(index); | 78 model->RemoveItemAt(index); |
74 id_to_window_.erase(i); | 79 id_to_window_.erase(i); |
75 break; | 80 break; |
76 } | 81 } |
77 } | 82 } |
78 } | 83 } |
79 | 84 |
80 } // namespace shell | 85 } // namespace shell |
81 } // namespace ash | 86 } // namespace ash |
OLD | NEW |