Index: chrome/browser/ui/gtk/location_bar_view_gtk.cc |
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
index ae4c929281391e95161d8e0c0f543bd1b3227ac6..cde768731ab46df1c58ef544d921afb06c5e0a37 100644 |
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
@@ -724,11 +724,11 @@ void LocationBarViewGtk::UpdatePageActions() { |
std::vector<ExtensionAction*> new_page_actions; |
TabContents* tab_contents = GetTabContents(); |
- if (tab_contents) { |
- LocationBarController* controller = |
- tab_contents->extension_tab_helper()->location_bar_controller(); |
- new_page_actions = controller->GetCurrentActions(); |
- } |
+ LocationBarController* location_bar_controller = tab_contents ? |
+ tab_contents->extension_tab_helper()->location_bar_controller() : NULL; |
+ |
+ if (location_bar_controller) |
+ new_page_actions = location_bar_controller->GetCurrentActions(); |
// Initialize on the first call, or re-initialize if more extensions have been |
// loaded or added after startup. |
@@ -737,8 +737,11 @@ void LocationBarViewGtk::UpdatePageActions() { |
page_action_views_.reset(); |
for (size_t i = 0; i < page_actions_.size(); ++i) { |
- page_action_views_.push_back( |
- new PageActionViewGtk(this, page_actions_[i])); |
+ ExtensionAction* page_action = page_actions_[i]; |
+ page_action_views_.push_back(new PageActionViewGtk( |
+ this, |
+ page_action, |
+ location_bar_controller->GetIconAnimation(page_action))); |
gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), |
page_action_views_[i]->widget(), FALSE, FALSE, 0); |
} |
@@ -1612,7 +1615,9 @@ void LocationBarViewGtk::ContentSettingImageViewGtk::BubbleClosing( |
LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( |
LocationBarViewGtk* owner, |
- ExtensionAction* page_action) |
+ ExtensionAction* page_action, |
+ const base::WeakPtr<extensions::LocationBarController::IconAnimation>& |
+ icon_animation) |
: owner_(NULL), |
page_action_(page_action), |
last_icon_pixbuf_(NULL), |
@@ -1620,7 +1625,8 @@ LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( |
current_tab_id_(-1), |
window_(NULL), |
accel_group_(NULL), |
- preview_enabled_(false) { |
+ preview_enabled_(false), |
+ icon_animation_(icon_animation) { |
event_box_.Own(gtk_event_box_new()); |
gtk_widget_set_size_request(event_box_.get(), |
Extension::kPageActionIconMaxSize, |
@@ -1657,6 +1663,9 @@ LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( |
ImageLoadingTracker::DONT_CACHE); |
} |
+ if (icon_animation_.get()) |
+ icon_animation_->AddObserver(this); |
+ |
// We set the owner last of all so that we can determine whether we are in |
// the process of initializing this class or not. |
owner_ = owner; |
@@ -1665,6 +1674,9 @@ LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( |
LocationBarViewGtk::PageActionViewGtk::~PageActionViewGtk() { |
DisconnectPageActionAccelerator(); |
+ if (icon_animation_.get()) |
+ icon_animation_->RemoveObserver(this); |
+ |
image_.Destroy(); |
event_box_.Destroy(); |
for (PixbufMap::iterator iter = pixbufs_.begin(); iter != pixbufs_.end(); |
@@ -1728,8 +1740,19 @@ void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( |
} |
} |
// The pixbuf might not be loaded yet. |
- if (pixbuf) |
- gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), pixbuf); |
+ if (pixbuf) { |
+ if (icon_animation_.get()) { |
+ // Draw |pixbuf| with the fade-in |icon_animation_| applied to it. |
+ // Use a temporary gfx::Image to do the conversion to/from a SkBitmap. |
+ g_object_ref(pixbuf); // don't let gfx::Image take ownership. |
+ gfx::Image animated_image( |
+ icon_animation_->Apply(*gfx::Image(pixbuf).ToSkBitmap())); |
+ gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), |
+ animated_image.ToGdkPixbuf()); |
+ } else { |
+ gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), pixbuf); |
+ } |
+ } |
} |
bool old_visible = IsVisible(); |
@@ -1768,11 +1791,10 @@ void LocationBarViewGtk::PageActionViewGtk::OnImageLoaded( |
pixbufs_[page_action_->default_icon_path()] = pixbuf; |
} |
- // 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_); |
not at google - send to devlin
2012/06/20 22:43:25
ditto
|
} |
void LocationBarViewGtk::PageActionViewGtk::TestActivatePageAction() { |
@@ -1835,6 +1857,20 @@ void LocationBarViewGtk::PageActionViewGtk::ConnectPageActionAccelerator() { |
} |
} |
+void LocationBarViewGtk::PageActionViewGtk::OnIconChanged( |
+ const LocationBarController::IconAnimation& animation, |
+ LocationBarController* controller) { |
+ TabContents* tab_contents = owner_->GetTabContents(); |
+ |
+ // Animation notification might be for another tab. |
Yoyo Zhou
2012/06/22 00:50:29
Same comment as mac.
|
+ LocationBarController* current_controller = tab_contents ? |
+ tab_contents->extension_tab_helper()->location_bar_controller() : NULL; |
+ if (controller != current_controller) |
+ return; |
+ |
+ UpdateVisibility(tab_contents->web_contents(), current_url_); |
+} |
+ |
void LocationBarViewGtk::PageActionViewGtk::DisconnectPageActionAccelerator() { |
if (accel_group_) { |
gtk_accel_group_disconnect_key( |