| OLD | NEW |
| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.AsImageSkia()); | 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.isNull()) { |
| 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); |
| 313 if (icon_index >= 0) { | 313 if (icon_index >= 0) { |
| 314 path = &icon_paths()->at(icon_index); | 314 path = &icon_paths()->at(icon_index); |
| 315 } else { | 315 } else { |
| 316 // Otherwise, use the default icon. | 316 // Otherwise, use the default icon. |
| 317 path = &default_icon_path(); | 317 path = &default_icon_path(); |
| 318 } | 318 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |