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

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

Issue 10837215: exhibit 1: explicit null checks Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Only update the icon if we have a new image, or none has been set yet. 220 // Only update the icon if we have a new image, or none has been set yet.
221 // This avoids flickering to an empty image when a pinned app is opened. 221 // This avoids flickering to an empty image when a pinned app is opened.
222 if (!new_image.empty()) 222 if (!new_image.empty())
223 item.image = new_image; 223 item.image = new_image;
224 else if (item.image.empty()) 224 else if (item.image.empty())
225 item.image = extensions::Extension::GetDefaultIcon(true); 225 item.image = extensions::Extension::GetDefaultIcon(true);
226 } else { 226 } else {
227 DCHECK_EQ(TYPE_TABBED, type_); 227 DCHECK_EQ(TYPE_TABBED, type_);
228 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 228 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
229 if (tab->favicon_tab_helper()->ShouldDisplayFavicon()) { 229 if (tab->favicon_tab_helper()->ShouldDisplayFavicon()) {
230 item.image = tab->favicon_tab_helper()->GetFavicon().AsBitmap(); 230 const gfx::Image& icon = tab->favicon_tab_helper()->GetFavicon();
231 if (item.image.empty()) { 231 item.image = icon.IsEmpty() ? *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON) :
232 item.image = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); 232 *icon.ToSkBitmap();
233 }
234 } else { 233 } else {
235 item.image = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); 234 item.image = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
236 } 235 }
237 } 236 }
238 launcher_model()->Set(item_index, item); 237 launcher_model()->Set(item_index, item);
239 } 238 }
240 239
241 void BrowserLauncherItemController::UpdateAppState(TabContents* tab) { 240 void BrowserLauncherItemController::UpdateAppState(TabContents* tab) {
242 ChromeLauncherController::AppState app_state; 241 ChromeLauncherController::AppState app_state;
243 242
244 if (tab_model_->GetIndexOfTabContents(tab) == TabStripModel::kNoTab) { 243 if (tab_model_->GetIndexOfTabContents(tab) == TabStripModel::kNoTab) {
245 app_state = ChromeLauncherController::APP_STATE_REMOVED; 244 app_state = ChromeLauncherController::APP_STATE_REMOVED;
246 } else if (tab_model_->GetActiveTabContents() == tab) { 245 } else if (tab_model_->GetActiveTabContents() == tab) {
247 if (ash::wm::IsActiveWindow(window_)) 246 if (ash::wm::IsActiveWindow(window_))
248 app_state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE; 247 app_state = ChromeLauncherController::APP_STATE_WINDOW_ACTIVE;
249 else 248 else
250 app_state = ChromeLauncherController::APP_STATE_ACTIVE; 249 app_state = ChromeLauncherController::APP_STATE_ACTIVE;
251 } else { 250 } else {
252 app_state = ChromeLauncherController::APP_STATE_INACTIVE; 251 app_state = ChromeLauncherController::APP_STATE_INACTIVE;
253 } 252 }
254 launcher_controller_->UpdateAppState(tab, app_state); 253 launcher_controller_->UpdateAppState(tab, app_state);
255 } 254 }
256 255
257 ash::LauncherModel* BrowserLauncherItemController::launcher_model() { 256 ash::LauncherModel* BrowserLauncherItemController::launcher_model() {
258 return launcher_controller_->model(); 257 return launcher_controller_->model();
259 } 258 }
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