| Index: chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm
|
| diff --git a/chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm b/chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm
|
| index 689687d51d10cfd396ecf4932d4b885c25c51582..6cbd0ee21d1a6f65ec4aa7f4e6f416896ff245b5 100644
|
| --- a/chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm
|
| +++ b/chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm
|
| @@ -49,7 +49,6 @@ PageActionDecoration::PageActionDecoration(
|
| : owner_(NULL),
|
| browser_(browser),
|
| page_action_(page_action),
|
| - tracker_(this),
|
| current_tab_id_(-1),
|
| preview_enabled_(false),
|
| ALLOW_THIS_IN_INITIALIZER_LIST(scoped_icon_animation_observer_(
|
| @@ -60,19 +59,7 @@ PageActionDecoration::PageActionDecoration(
|
| GetExtensionById(page_action->extension_id(), false);
|
| DCHECK(extension);
|
|
|
| - // Load all the icons declared in the manifest. This is the contents of the
|
| - // icons array, plus the default_icon property, if any.
|
| - std::vector<std::string> icon_paths(*page_action->icon_paths());
|
| - if (!page_action_->default_icon_path().empty())
|
| - icon_paths.push_back(page_action_->default_icon_path());
|
| -
|
| - for (std::vector<std::string>::iterator iter = icon_paths.begin();
|
| - iter != icon_paths.end(); ++iter) {
|
| - tracker_.LoadImage(extension, extension->GetResource(*iter),
|
| - gfx::Size(Extension::kPageActionIconMaxSize,
|
| - Extension::kPageActionIconMaxSize),
|
| - ImageLoadingTracker::DONT_CACHE);
|
| - }
|
| + icon_factory_.reset(new ExtensionActionIconFactory(extension, this));
|
|
|
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
|
| content::Source<Profile>(browser_->profile()));
|
| @@ -140,23 +127,7 @@ bool PageActionDecoration::ActivatePageAction(NSRect frame) {
|
| return true;
|
| }
|
|
|
| -void PageActionDecoration::OnImageLoaded(const gfx::Image& image,
|
| - const std::string& extension_id,
|
| - int index) {
|
| - // We loaded icons()->size() icons, plus one extra if the Page Action had
|
| - // a default icon.
|
| - int total_icons = static_cast<int>(page_action_->icon_paths()->size());
|
| - if (!page_action_->default_icon_path().empty())
|
| - total_icons++;
|
| - DCHECK(index < total_icons);
|
| -
|
| - // Map the index of the loaded image back to its name. If we ever get an
|
| - // index greater than the number of icons, it must be the default icon.
|
| - if (index < static_cast<int>(page_action_->icon_paths()->size()))
|
| - page_action_->CacheIcon(page_action_->icon_paths()->at(index), image);
|
| - else
|
| - page_action_->CacheIcon(page_action_->default_icon_path(), image);
|
| -
|
| +void PageActionDecoration::OnIconUpdated() {
|
| // If we have no owner, that means this class is still being constructed.
|
| TabContents* tab_contents = owner_ ? owner_->GetTabContents() : NULL;
|
| if (tab_contents) {
|
| @@ -178,7 +149,8 @@ void PageActionDecoration::UpdateVisibility(WebContents* contents,
|
| SetToolTip(page_action_->GetTitle(current_tab_id_));
|
|
|
| // Set the image.
|
| - gfx::Image icon = page_action_->GetIcon(current_tab_id_);
|
| + gfx::Image icon =
|
| + page_action_->GetIcon(current_tab_id_, icon_factory_.get());
|
| if (!icon.IsEmpty()) {
|
| SetImage(icon.ToNSImage());
|
| } else if (!GetImage()) {
|
|
|