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

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

Issue 71653003: ash: Rename LauncherModel to ShelfModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chrome changes Created 7 years, 1 month 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_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/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
9 #include "ash/launcher/launcher_item_delegate_manager.h" 9 #include "ash/launcher/launcher_item_delegate_manager.h"
10 #include "ash/launcher/launcher_model.h" 10 #include "ash/shelf/shelf_model.h"
11 #include "ash/shelf/shelf_widget.h" 11 #include "ash/shelf/shelf_widget.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/shell/window_watcher_launcher_item_delegate.h" 13 #include "ash/shell/window_watcher_launcher_item_delegate.h"
14 #include "ash/shell_window_ids.h" 14 #include "ash/shell_window_ids.h"
15 #include "ui/aura/root_window.h" 15 #include "ui/aura/root_window.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/gfx/display.h" 17 #include "ui/gfx/display.h"
18 18
19 namespace ash { 19 namespace ash {
20 namespace shell { 20 namespace shell {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return 0; // TODO: add a constant for this. 99 return 0; // TODO: add a constant for this.
100 } 100 }
101 101
102 // aura::WindowObserver overrides: 102 // aura::WindowObserver overrides:
103 void WindowWatcher::OnWindowAdded(aura::Window* new_window) { 103 void WindowWatcher::OnWindowAdded(aura::Window* new_window) {
104 if (new_window->type() != aura::client::WINDOW_TYPE_NORMAL && 104 if (new_window->type() != aura::client::WINDOW_TYPE_NORMAL &&
105 new_window->type() != aura::client::WINDOW_TYPE_PANEL) 105 new_window->type() != aura::client::WINDOW_TYPE_PANEL)
106 return; 106 return;
107 107
108 static int image_count = 0; 108 static int image_count = 0;
109 ash::LauncherModel* model = Shell::GetInstance()->launcher_model(); 109 ShelfModel* model = Shell::GetInstance()->shelf_model();
110 ash::LauncherItem item; 110 LauncherItem item;
111 item.type = new_window->type() == aura::client::WINDOW_TYPE_PANEL ? 111 item.type = new_window->type() == aura::client::WINDOW_TYPE_PANEL ?
112 ash::TYPE_APP_PANEL : ash::TYPE_PLATFORM_APP; 112 ash::TYPE_APP_PANEL : ash::TYPE_PLATFORM_APP;
113 ash::LauncherID id = model->next_id(); 113 ash::LauncherID id = model->next_id();
114 id_to_window_[id] = new_window; 114 id_to_window_[id] = new_window;
115 115
116 SkBitmap icon_bitmap; 116 SkBitmap icon_bitmap;
117 icon_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); 117 icon_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
118 icon_bitmap.allocPixels(); 118 icon_bitmap.allocPixels();
119 icon_bitmap.eraseARGB(255, 119 icon_bitmap.eraseARGB(255,
120 image_count == 0 ? 255 : 0, 120 image_count == 0 ? 255 : 0,
121 image_count == 1 ? 255 : 0, 121 image_count == 1 ? 255 : 0,
122 image_count == 2 ? 255 : 0); 122 image_count == 2 ? 255 : 0);
123 image_count = (image_count + 1) % 3; 123 image_count = (image_count + 1) % 3;
124 item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, 1.0f)); 124 item.image = gfx::ImageSkia(gfx::ImageSkiaRep(icon_bitmap, 1.0f));
125 125
126 model->Add(item); 126 model->Add(item);
127 127
128 ash::LauncherItemDelegateManager* manager = 128 ash::LauncherItemDelegateManager* manager =
129 ash::Shell::GetInstance()->launcher_item_delegate_manager(); 129 ash::Shell::GetInstance()->launcher_item_delegate_manager();
130 scoped_ptr<LauncherItemDelegate> delegate( 130 scoped_ptr<LauncherItemDelegate> delegate(
131 new WindowWatcherLauncherItemDelegate(id, this)); 131 new WindowWatcherLauncherItemDelegate(id, this));
132 manager->SetLauncherItemDelegate(id, delegate.Pass()); 132 manager->SetLauncherItemDelegate(id, delegate.Pass());
133 } 133 }
134 134
135 void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { 135 void WindowWatcher::OnWillRemoveWindow(aura::Window* window) {
136 for (IDToWindow::iterator i = id_to_window_.begin(); 136 for (IDToWindow::iterator i = id_to_window_.begin();
137 i != id_to_window_.end(); ++i) { 137 i != id_to_window_.end(); ++i) {
138 if (i->second == window) { 138 if (i->second == window) {
139 ash::LauncherModel* model = Shell::GetInstance()->launcher_model(); 139 ShelfModel* model = Shell::GetInstance()->shelf_model();
140 int index = model->ItemIndexByID(i->first); 140 int index = model->ItemIndexByID(i->first);
141 DCHECK_NE(-1, index); 141 DCHECK_NE(-1, index);
142 model->RemoveItemAt(index); 142 model->RemoveItemAt(index);
143 id_to_window_.erase(i); 143 id_to_window_.erase(i);
144 break; 144 break;
145 } 145 }
146 } 146 }
147 } 147 }
148 148
149 void WindowWatcher::OnDisplayBoundsChanged(const gfx::Display& display) { 149 void WindowWatcher::OnDisplayBoundsChanged(const gfx::Display& display) {
150 } 150 }
151 151
152 void WindowWatcher::OnDisplayAdded(const gfx::Display& new_display) { 152 void WindowWatcher::OnDisplayAdded(const gfx::Display& new_display) {
153 aura::Window* root = Shell::GetInstance()->display_controller()-> 153 aura::Window* root = Shell::GetInstance()->display_controller()->
154 GetRootWindowForDisplayId(new_display.id()); 154 GetRootWindowForDisplayId(new_display.id());
155 workspace_window_watcher_->RootWindowAdded(root); 155 workspace_window_watcher_->RootWindowAdded(root);
156 } 156 }
157 157
158 void WindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) { 158 void WindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) {
159 // All windows in the display has already been removed, so no need to 159 // All windows in the display has already been removed, so no need to
160 // remove observers. 160 // remove observers.
161 } 161 }
162 162
163 } // namespace shell 163 } // namespace shell
164 } // namespace ash 164 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell/window_watcher.h ('k') | ash/shell_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698