Chromium Code Reviews| 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 94622b9983fe8732372aa1333a0a56860e513219..00b2944793505912dcbbe8260061a89dcd1bd7e8 100644 |
| --- a/chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm |
| +++ b/chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm |
| @@ -69,6 +69,11 @@ PageActionDecoration::PageActionDecoration( |
| ImageLoadingTracker::DONT_CACHE); |
| } |
| + icon_animation_ = page_action->GetIconAnimation( |
| + owner->GetTabContents()->extension_tab_helper()->tab_id()); |
| + if (icon_animation_.get()) |
| + icon_animation_->AddObserver(this); |
| + |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
| content::Source<Profile>(profile_)); |
| @@ -77,7 +82,10 @@ PageActionDecoration::PageActionDecoration( |
| owner_ = owner; |
| } |
| -PageActionDecoration::~PageActionDecoration() {} |
| +PageActionDecoration::~PageActionDecoration() { |
| + if (icon_animation_.get()) |
| + icon_animation_->RemoveObserver(this); |
|
Nico
2012/06/26 22:59:21
This looks like something that should be done by a
not at google - send to devlin
2012/06/27 06:26:54
Done.
|
| +} |
| // Always |kPageActionIconMaxSize| wide. |ImageDecoration| draws the |
| // image centered. |
| @@ -147,11 +155,12 @@ void PageActionDecoration::OnImageLoaded(const gfx::Image& image, |
| page_action_icons_[page_action_->default_icon_path()] = *bitmap; |
| } |
| - // If we have no owner, that means this class is still being constructed and |
| - // we should not UpdatePageActions, since it leads to the PageActions being |
| - // destroyed again and new ones recreated (causing an infinite loop). |
| - if (owner_) |
| - owner_->UpdatePageActions(); |
| + // If we have no owner, that means this class is still being constructed. |
| + TabContents* tab_contents = owner_ ? owner_->GetTabContents() : NULL; |
| + if (tab_contents) { |
| + UpdateVisibility(tab_contents->web_contents(), current_url_); |
| + owner_->RedrawDecoration(this); |
| + } |
| } |
| void PageActionDecoration::UpdateVisibility(WebContents* contents, |
| @@ -189,6 +198,8 @@ void PageActionDecoration::UpdateVisibility(WebContents* contents, |
| } |
| } |
| if (!skia_icon.isNull()) { |
| + if (icon_animation_.get()) |
| + skia_icon = icon_animation_->Apply(skia_icon); |
| SetImage(gfx::SkBitmapToNSImage(skia_icon)); |
| } else if (!GetImage()) { |
| // During install the action can be displayed before the icons |
| @@ -271,6 +282,12 @@ void PageActionDecoration::ShowPopup(const NSRect& frame, |
| devMode:NO]; |
| } |
| +void PageActionDecoration::OnIconChanged( |
| + const ExtensionAction::IconAnimation& animation) { |
| + UpdateVisibility(owner_->GetWebContents(), current_url_); |
| + owner_->RedrawDecoration(this); |
| +} |
| + |
| void PageActionDecoration::Observe( |
| int type, |
| const content::NotificationSource& source, |