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

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

Issue 10824359: Remove ImageSkia::empty and ImageSkia::extractSubset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 ash::LauncherItem item = launcher_model()->items()[item_index]; 246 ash::LauncherItem item = launcher_model()->items()[item_index];
247 if (type() == TYPE_EXTENSION_PANEL) { 247 if (type() == TYPE_EXTENSION_PANEL) {
248 if (!favicon_loader_.get() || 248 if (!favicon_loader_.get() ||
249 favicon_loader_->web_contents() != tab->web_contents()) { 249 favicon_loader_->web_contents() != tab->web_contents()) {
250 favicon_loader_.reset( 250 favicon_loader_.reset(
251 new LauncherFaviconLoader(this, tab->web_contents())); 251 new LauncherFaviconLoader(this, tab->web_contents()));
252 } 252 }
253 // Update the icon for extension panels. 253 // Update the icon for extension panels.
254 SkBitmap new_image = favicon_loader_->GetFavicon(); 254 SkBitmap new_image = favicon_loader_->GetFavicon();
255 if (new_image.empty() && tab->extension_tab_helper()->GetExtensionAppIcon()) 255 if (new_image.isNull() &&
256 tab->extension_tab_helper()->GetExtensionAppIcon()) {
256 new_image = *tab->extension_tab_helper()->GetExtensionAppIcon(); 257 new_image = *tab->extension_tab_helper()->GetExtensionAppIcon();
258 }
257 // Only update the icon if we have a new image, or none has been set yet. 259 // Only update the icon if we have a new image, or none has been set yet.
258 // This avoids flickering to an empty image when a pinned app is opened. 260 // This avoids flickering to an empty image when a pinned app is opened.
259 if (!new_image.empty()) 261 if (!new_image.isNull())
260 item.image = new_image; 262 item.image = new_image;
261 else if (item.image.empty()) 263 else if (item.image.isNull())
262 item.image = extensions::Extension::GetDefaultIcon(true); 264 item.image = extensions::Extension::GetDefaultIcon(true);
263 } else { 265 } else {
264 DCHECK_EQ(TYPE_TABBED, type()); 266 DCHECK_EQ(TYPE_TABBED, type());
265 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 267 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
266 if (tab->favicon_tab_helper()->ShouldDisplayFavicon()) { 268 if (tab->favicon_tab_helper()->ShouldDisplayFavicon()) {
267 item.image = tab->favicon_tab_helper()->GetFavicon().AsBitmap(); 269 item.image = tab->favicon_tab_helper()->GetFavicon().AsBitmap();
268 if (item.image.empty()) { 270 if (item.image.isNull()) {
269 item.image = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); 271 item.image = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
270 } 272 }
271 } else { 273 } else {
272 item.image = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); 274 item.image = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
273 } 275 }
274 } 276 }
275 launcher_model()->Set(item_index, item); 277 launcher_model()->Set(item_index, item);
276 } 278 }
277 279
278 void BrowserLauncherItemController::UpdateAppState(TabContents* tab) { 280 void BrowserLauncherItemController::UpdateAppState(TabContents* tab) {
279 ChromeLauncherController::AppState app_state; 281 ChromeLauncherController::AppState app_state;
280 282
281 if (tab_model_->GetIndexOfTabContents(tab) == TabStripModel::kNoTab) { 283 if (tab_model_->GetIndexOfTabContents(tab) == TabStripModel::kNoTab) {
282 app_state = ChromeLauncherController::APP_STATE_REMOVED; 284 app_state = ChromeLauncherController::APP_STATE_REMOVED;
283 } else if (tab_model_->GetActiveTabContents() == tab) { 285 } else if (tab_model_->GetActiveTabContents() == tab) {
284 if (ash::wm::IsActiveWindow(window_)) 286 if (ash::wm::IsActiveWindow(window_))
285 app_state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE; 287 app_state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE;
286 else 288 else
287 app_state = ChromeLauncherController::APP_STATE_ACTIVE; 289 app_state = ChromeLauncherController::APP_STATE_ACTIVE;
288 } else { 290 } else {
289 app_state = ChromeLauncherController::APP_STATE_INACTIVE; 291 app_state = ChromeLauncherController::APP_STATE_INACTIVE;
290 } 292 }
291 launcher_controller()->UpdateAppState(tab, app_state); 293 launcher_controller()->UpdateAppState(tab, app_state);
292 } 294 }
293 295
294 ash::LauncherModel* BrowserLauncherItemController::launcher_model() { 296 ash::LauncherModel* BrowserLauncherItemController::launcher_model() {
295 return launcher_controller()->model(); 297 return launcher_controller()->model();
296 } 298 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.cc ('k') | chrome/browser/ui/views/ash/balloon_view_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698