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

Side by Side Diff: chrome/common/extensions/extension_action.cc

Issue 10824314: Fix crash in browserAction.setIcon (Closed) 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
« no previous file with comments | « no previous file | no next file » | 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 "chrome/common/extensions/extension_action.h" 5 #include "chrome/common/extensions/extension_action.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/common/badge_util.h" 10 #include "chrome/common/badge_util.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return GetValue(&popup_url_, tab_id); 292 return GetValue(&popup_url_, tab_id);
293 } 293 }
294 294
295 void ExtensionAction::CacheIcon(const std::string& path, 295 void ExtensionAction::CacheIcon(const std::string& path,
296 const gfx::Image& icon) { 296 const gfx::Image& icon) {
297 if (!icon.IsEmpty()) 297 if (!icon.IsEmpty())
298 path_to_icon_cache_.insert(std::make_pair(path, *icon.ToImageSkia())); 298 path_to_icon_cache_.insert(std::make_pair(path, *icon.ToImageSkia()));
299 } 299 }
300 300
301 void ExtensionAction::SetIcon(int tab_id, const gfx::Image& image) { 301 void ExtensionAction::SetIcon(int tab_id, const gfx::Image& image) {
302 SetValue(&icon_, tab_id, *image.ToImageSkia()); 302 SetValue(&icon_, tab_id, image.AsImageSkia());
303 } 303 }
304 304
305 gfx::Image ExtensionAction::GetIcon(int tab_id) const { 305 gfx::Image ExtensionAction::GetIcon(int tab_id) const {
306 // Check if a specific icon is set for this tab. 306 // Check if a specific icon is set for this tab.
307 gfx::ImageSkia icon = GetValue(&icon_, tab_id); 307 gfx::ImageSkia icon = GetValue(&icon_, tab_id);
308 if (icon.empty()) { 308 if (icon.empty()) {
309 // Need to find an icon from a path. 309 // Need to find an icon from a path.
310 const std::string* path = NULL; 310 const std::string* path = NULL;
311 // Check if one of the elements of icon_path() was selected. 311 // Check if one of the elements of icon_path() was selected.
312 int icon_index = GetIconIndex(tab_id); 312 int icon_index = GetIconIndex(tab_id);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 new AnimatedIconImageSource(icon, animation_wrapper->animation()), 521 new AnimatedIconImageSource(icon, animation_wrapper->animation()),
522 icon.size()); 522 icon.size());
523 } 523 }
524 524
525 void ExtensionAction::RunIconAnimation(int tab_id) { 525 void ExtensionAction::RunIconAnimation(int tab_id) {
526 IconAnimationWrapper* icon_animation = 526 IconAnimationWrapper* icon_animation =
527 new IconAnimationWrapper(); 527 new IconAnimationWrapper();
528 icon_animation_[tab_id] = icon_animation->AsWeakPtr(); 528 icon_animation_[tab_id] = icon_animation->AsWeakPtr();
529 icon_animation->animation()->Start(); 529 icon_animation->animation()->Start();
530 } 530 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698