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

Side by Side Diff: chrome/browser/ui/ash/launcher/browser_launcher_item_controller.cc

Issue 11011002: Switch FaviconTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 2 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
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 "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.h" 5 #include "chrome/browser/ui/ash/launcher/browser_launcher_item_controller.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/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 TabContents* tab, 176 TabContents* tab,
177 int index, 177 int index,
178 TabStripModelObserver::TabChangeType change_type) { 178 TabStripModelObserver::TabChangeType change_type) {
179 UpdateAppState(tab); 179 UpdateAppState(tab);
180 if (index != tab_model_->active_index() || 180 if (index != tab_model_->active_index() ||
181 !(change_type != TabStripModelObserver::LOADING_ONLY && 181 !(change_type != TabStripModelObserver::LOADING_ONLY &&
182 change_type != TabStripModelObserver::TITLE_NOT_LOADING)) { 182 change_type != TabStripModelObserver::TITLE_NOT_LOADING)) {
183 return; 183 return;
184 } 184 }
185 185
186 if (tab->favicon_tab_helper()->FaviconIsValid() || 186 FaviconTabHelper* favicon_tab_helper =
187 !tab->favicon_tab_helper()->ShouldDisplayFavicon()) { 187 FaviconTabHelper::FromWebContents(tab->web_contents());
188 if (favicon_tab_helper->FaviconIsValid() ||
189 !favicon_tab_helper->ShouldDisplayFavicon()) {
188 // We have the favicon, update immediately. 190 // We have the favicon, update immediately.
189 UpdateLauncher(tab); 191 UpdateLauncher(tab);
190 } else { 192 } else {
191 int item_index = launcher_model()->ItemIndexByID(launcher_id()); 193 int item_index = launcher_model()->ItemIndexByID(launcher_id());
192 if (item_index == -1) 194 if (item_index == -1)
193 return; 195 return;
194 ash::LauncherItem item = launcher_model()->items()[item_index]; 196 ash::LauncherItem item = launcher_model()->items()[item_index];
195 item.image = SkBitmap(); 197 item.image = SkBitmap();
196 launcher_model()->Set(item_index, item); 198 launcher_model()->Set(item_index, item);
197 } 199 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 new_image = *extensions_tab_helper->GetExtensionAppIcon(); 262 new_image = *extensions_tab_helper->GetExtensionAppIcon();
261 // Only update the icon if we have a new image, or none has been set yet. 263 // Only update the icon if we have a new image, or none has been set yet.
262 // This avoids flickering to an empty image when a pinned app is opened. 264 // This avoids flickering to an empty image when a pinned app is opened.
263 if (!new_image.isNull()) 265 if (!new_image.isNull())
264 item.image = new_image; 266 item.image = new_image;
265 else if (item.image.isNull()) 267 else if (item.image.isNull())
266 item.image = extensions::Extension::GetDefaultIcon(true); 268 item.image = extensions::Extension::GetDefaultIcon(true);
267 } else { 269 } else {
268 DCHECK_EQ(TYPE_TABBED, type()); 270 DCHECK_EQ(TYPE_TABBED, type());
269 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 271 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
270 if (tab->favicon_tab_helper()->ShouldDisplayFavicon()) { 272 FaviconTabHelper* favicon_tab_helper =
271 item.image = tab->favicon_tab_helper()->GetFavicon().AsImageSkia(); 273 FaviconTabHelper::FromWebContents(tab->web_contents());
274 if (favicon_tab_helper->ShouldDisplayFavicon()) {
275 item.image = favicon_tab_helper->GetFavicon().AsImageSkia();
272 if (item.image.isNull()) { 276 if (item.image.isNull()) {
273 item.image = *rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON); 277 item.image = *rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON);
274 } 278 }
275 } else { 279 } else {
276 item.image = *rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON); 280 item.image = *rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON);
277 } 281 }
278 } 282 }
279 launcher_model()->Set(item_index, item); 283 launcher_model()->Set(item_index, item);
280 } 284 }
281 285
282 void BrowserLauncherItemController::UpdateAppState(TabContents* tab) { 286 void BrowserLauncherItemController::UpdateAppState(TabContents* tab) {
283 ChromeLauncherController::AppState app_state; 287 ChromeLauncherController::AppState app_state;
284 288
285 if (tab_model_->GetIndexOfTabContents(tab) == TabStripModel::kNoTab) { 289 if (tab_model_->GetIndexOfTabContents(tab) == TabStripModel::kNoTab) {
286 app_state = ChromeLauncherController::APP_STATE_REMOVED; 290 app_state = ChromeLauncherController::APP_STATE_REMOVED;
287 } else if (tab_model_->GetActiveTabContents() == tab) { 291 } else if (tab_model_->GetActiveTabContents() == tab) {
288 if (ash::wm::IsActiveWindow(window_)) 292 if (ash::wm::IsActiveWindow(window_))
289 app_state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE; 293 app_state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE;
290 else 294 else
291 app_state = ChromeLauncherController::APP_STATE_ACTIVE; 295 app_state = ChromeLauncherController::APP_STATE_ACTIVE;
292 } else { 296 } else {
293 app_state = ChromeLauncherController::APP_STATE_INACTIVE; 297 app_state = ChromeLauncherController::APP_STATE_INACTIVE;
294 } 298 }
295 launcher_controller()->UpdateAppState(tab, app_state); 299 launcher_controller()->UpdateAppState(tab, app_state);
296 } 300 }
297 301
298 ash::LauncherModel* BrowserLauncherItemController::launcher_model() { 302 ash::LauncherModel* BrowserLauncherItemController::launcher_model() {
299 return launcher_controller()->model(); 303 return launcher_controller()->model();
300 } 304 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager_resource_providers.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698