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

Unified Diff: chrome/browser/ui/views/location_bar/page_action_image_view.cc

Issue 10699033: Animation the script badges on views. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/location_bar/page_action_image_view.cc
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
index ed37dad6f3a4a12e557c8430ece7083369cd4d69..b23449c946d7db49c1a0f92c587ed403fb392e7b 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
@@ -45,7 +45,11 @@ PageActionImageView::PageActionImageView(LocationBarView* owner,
ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)),
current_tab_id_(-1),
preview_enabled_(false),
- popup_(NULL) {
+ popup_(NULL),
+ ALLOW_THIS_IN_INITIALIZER_LIST(scoped_icon_animation_observer_(
+ page_action->GetIconAnimation(
+ owner->GetTabContents()->extension_tab_helper()->tab_id()),
+ this)) {
const Extension* extension = owner_->profile()->GetExtensionService()->
GetExtensionById(page_action->extension_id(), false);
DCHECK(extension);
@@ -202,11 +206,10 @@ void PageActionImageView::OnImageLoaded(const gfx::Image& image,
page_action_icons_[page_action_->default_icon_path()] = *bitmap;
}
- // During object construction (before the parent has been set) we are already
- // in a UpdatePageActions call, so we don't need to start another one (and
- // doing so causes crash described in http://crbug.com/57333).
- if (parent())
- owner_->UpdatePageActions();
+ // During object construction owner_ will be NULL.
+ TabContents* tab_contents = owner_ ? owner_->GetTabContents() : NULL;
+ if (tab_contents)
+ UpdateVisibility(tab_contents->web_contents(), current_url_);
}
bool PageActionImageView::AcceleratorPressed(
@@ -262,8 +265,14 @@ void PageActionImageView::UpdateVisibility(WebContents* contents,
icon = iter->second;
}
}
- if (!icon.isNull())
+
+ if (!icon.isNull()) {
+ const ExtensionAction::IconAnimation* icon_animation =
+ scoped_icon_animation_observer_.icon_animation();
+ if (icon_animation)
+ icon = icon_animation->Apply(icon);
SetImage(icon);
+ }
SetVisible(true);
}
@@ -284,6 +293,13 @@ void PageActionImageView::Observe(int type,
owner_->UpdatePageActions();
}
+void PageActionImageView::OnIconChanged(
+ const ExtensionAction::IconAnimation& animation) {
+ TabContents* tab_contents = owner_->GetTabContents();
+ if (tab_contents)
+ UpdateVisibility(tab_contents->web_contents(), current_url_);
+}
+
void PageActionImageView::ShowPopupWithURL(const GURL& popup_url) {
bool popup_showing = popup_ != NULL;
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698