Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: ash/shell/window_watcher.cc

Issue 152223002: Renames LauncherID, LauncherItem and LauncherItems... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: OWNERS Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/shell/window_watcher.h ('k') | ash/shell/window_watcher_shelf_item_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 WindowWatcher::~WindowWatcher() { 81 WindowWatcher::~WindowWatcher() {
82 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 82 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
83 for (aura::Window::Windows::iterator iter = root_windows.begin(); 83 for (aura::Window::Windows::iterator iter = root_windows.begin();
84 iter != root_windows.end(); ++ iter) { 84 iter != root_windows.end(); ++ iter) {
85 workspace_window_watcher_->RootWindowRemoved(*iter); 85 workspace_window_watcher_->RootWindowRemoved(*iter);
86 } 86 }
87 } 87 }
88 88
89 aura::Window* WindowWatcher::GetWindowByID(ash::LauncherID id) { 89 aura::Window* WindowWatcher::GetWindowByID(ash::ShelfID id) {
90 IDToWindow::const_iterator i = id_to_window_.find(id); 90 IDToWindow::const_iterator i = id_to_window_.find(id);
91 return i != id_to_window_.end() ? i->second : NULL; 91 return i != id_to_window_.end() ? i->second : NULL;
92 } 92 }
93 93
94 // aura::WindowObserver overrides: 94 // aura::WindowObserver overrides:
95 void WindowWatcher::OnWindowAdded(aura::Window* new_window) { 95 void WindowWatcher::OnWindowAdded(aura::Window* new_window) {
96 if (new_window->type() != ui::wm::WINDOW_TYPE_NORMAL && 96 if (new_window->type() != ui::wm::WINDOW_TYPE_NORMAL &&
97 new_window->type() != ui::wm::WINDOW_TYPE_PANEL) 97 new_window->type() != ui::wm::WINDOW_TYPE_PANEL)
98 return; 98 return;
99 99
100 static int image_count = 0; 100 static int image_count = 0;
101 ShelfModel* model = Shell::GetInstance()->shelf_model(); 101 ShelfModel* model = Shell::GetInstance()->shelf_model();
102 LauncherItem item; 102 ShelfItem item;
103 item.type = new_window->type() == ui::wm::WINDOW_TYPE_PANEL 103 item.type = new_window->type() == ui::wm::WINDOW_TYPE_PANEL
104 ? ash::TYPE_APP_PANEL 104 ? ash::TYPE_APP_PANEL
105 : ash::TYPE_PLATFORM_APP; 105 : ash::TYPE_PLATFORM_APP;
106 ash::LauncherID id = model->next_id(); 106 ash::ShelfID id = model->next_id();
107 id_to_window_[id] = new_window; 107 id_to_window_[id] = new_window;
108 108
109 SkBitmap icon_bitmap; 109 SkBitmap icon_bitmap;
110 icon_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); 110 icon_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
111 icon_bitmap.allocPixels(); 111 icon_bitmap.allocPixels();
112 icon_bitmap.eraseARGB(255, 112 icon_bitmap.eraseARGB(255,
113 image_count == 0 ? 255 : 0, 113 image_count == 0 ? 255 : 0,
114 image_count == 1 ? 255 : 0, 114 image_count == 1 ? 255 : 0,
115 image_count == 2 ? 255 : 0); 115 image_count == 2 ? 255 : 0);
116 image_count = (image_count + 1) % 3; 116 image_count = (image_count + 1) % 3;
117 item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, 1.0f)); 117 item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, 1.0f));
118 118
119 model->Add(item); 119 model->Add(item);
120 120
121 ShelfItemDelegateManager* manager = 121 ShelfItemDelegateManager* manager =
122 Shell::GetInstance()->shelf_item_delegate_manager(); 122 Shell::GetInstance()->shelf_item_delegate_manager();
123 scoped_ptr<ShelfItemDelegate> delegate( 123 scoped_ptr<ShelfItemDelegate> delegate(
124 new WindowWatcherShelfItemDelegate(id, this)); 124 new WindowWatcherShelfItemDelegate(id, this));
125 manager->SetShelfItemDelegate(id, delegate.Pass()); 125 manager->SetShelfItemDelegate(id, delegate.Pass());
126 SetLauncherIDForWindow(id, new_window); 126 SetShelfIDForWindow(id, new_window);
127 } 127 }
128 128
129 void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { 129 void WindowWatcher::OnWillRemoveWindow(aura::Window* window) {
130 for (IDToWindow::iterator i = id_to_window_.begin(); 130 for (IDToWindow::iterator i = id_to_window_.begin();
131 i != id_to_window_.end(); ++i) { 131 i != id_to_window_.end(); ++i) {
132 if (i->second == window) { 132 if (i->second == window) {
133 ShelfModel* model = Shell::GetInstance()->shelf_model(); 133 ShelfModel* model = Shell::GetInstance()->shelf_model();
134 int index = model->ItemIndexByID(i->first); 134 int index = model->ItemIndexByID(i->first);
135 DCHECK_NE(-1, index); 135 DCHECK_NE(-1, index);
136 model->RemoveItemAt(index); 136 model->RemoveItemAt(index);
(...skipping 12 matching lines...) Expand all
149 workspace_window_watcher_->RootWindowAdded(root); 149 workspace_window_watcher_->RootWindowAdded(root);
150 } 150 }
151 151
152 void WindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) { 152 void WindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) {
153 // All windows in the display has already been removed, so no need to 153 // All windows in the display has already been removed, so no need to
154 // remove observers. 154 // remove observers.
155 } 155 }
156 156
157 } // namespace shell 157 } // namespace shell
158 } // namespace ash 158 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell/window_watcher.h ('k') | ash/shell/window_watcher_shelf_item_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698