diff options
4 files changed, 18 insertions, 8 deletions
diff --git a/chrome/browser/cocoa/location_bar/content_setting_decoration.h b/chrome/browser/cocoa/location_bar/content_setting_decoration.h index bc571d1..d54db31 100644 --- a/chrome/browser/cocoa/location_bar/content_setting_decoration.h +++ b/chrome/browser/cocoa/location_bar/content_setting_decoration.h @@ -26,7 +26,8 @@ class ContentSettingDecoration : public ImageDecoration { virtual ~ContentSettingDecoration(); // Updates the image and visibility state based on the supplied TabContents. - void UpdateFromTabContents(const TabContents* tab_contents); + // Returns true if the decoration's visible state changed. + bool UpdateFromTabContents(const TabContents* tab_contents); // Overridden from |LocationBarDecoration| virtual bool AcceptsMousePress() { return true; } diff --git a/chrome/browser/cocoa/location_bar/content_setting_decoration.mm b/chrome/browser/cocoa/location_bar/content_setting_decoration.mm index 790b5c2..6f99c41 100644 --- a/chrome/browser/cocoa/location_bar/content_setting_decoration.mm +++ b/chrome/browser/cocoa/location_bar/content_setting_decoration.mm @@ -39,10 +39,14 @@ ContentSettingDecoration::ContentSettingDecoration( ContentSettingDecoration::~ContentSettingDecoration() { } -void ContentSettingDecoration::UpdateFromTabContents( +bool ContentSettingDecoration::UpdateFromTabContents( const TabContents* tab_contents) { + bool was_visible = IsVisible(); + int old_icon = content_setting_image_model_->get_icon(); content_setting_image_model_->UpdateFromTabContents(tab_contents); SetVisible(content_setting_image_model_->is_visible()); + bool decoration_changed = was_visible != IsVisible() || + old_icon != content_setting_image_model_->get_icon(); if (IsVisible()) { // TODO(thakis): We should use pdfs for these icons on OSX. // http://crbug.com/35847 @@ -51,6 +55,7 @@ void ContentSettingDecoration::UpdateFromTabContents( SetToolTip(base::SysUTF8ToNSString( content_setting_image_model_->get_tooltip())); } + return decoration_changed; } NSPoint ContentSettingDecoration::GetBubblePointInFrame(NSRect frame) { diff --git a/chrome/browser/cocoa/location_bar/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar/location_bar_view_mac.h index 7c1db4e..2400252 100644 --- a/chrome/browser/cocoa/location_bar/location_bar_view_mac.h +++ b/chrome/browser/cocoa/location_bar/location_bar_view_mac.h @@ -158,7 +158,7 @@ class LocationBarViewMac : public AutocompleteEditController, // Updates visibility of the content settings icons based on the current // tab contents state. - void RefreshContentSettingsDecorations(); + bool RefreshContentSettingsDecorations(); void ShowFirstRunBubbleInternal(FirstRun::BubbleType bubble_type); diff --git a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm index 32d021c..b1cf7a7 100644 --- a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm @@ -144,9 +144,10 @@ void LocationBarViewMac::FocusSearch() { } void LocationBarViewMac::UpdateContentSettingsIcons() { - RefreshContentSettingsDecorations(); - [field_ updateCursorAndToolTipRects]; - [field_ setNeedsDisplay:YES]; + if (RefreshContentSettingsDecorations()) { + [field_ updateCursorAndToolTipRects]; + [field_ setNeedsDisplay:YES]; + } } void LocationBarViewMac::UpdatePageActions() { @@ -429,13 +430,16 @@ void LocationBarViewMac::PostNotification(NSString* notification) { object:[NSValue valueWithPointer:this]]; } -void LocationBarViewMac::RefreshContentSettingsDecorations() { +bool LocationBarViewMac::RefreshContentSettingsDecorations() { const bool input_in_progress = toolbar_model_->input_in_progress(); const TabContents* tab_contents = input_in_progress ? NULL : browser_->GetSelectedTabContents(); + bool icons_updated = false; for (size_t i = 0; i < content_setting_decorations_.size(); ++i) { - content_setting_decorations_[i]->UpdateFromTabContents(tab_contents); + icons_updated |= + content_setting_decorations_[i]->UpdateFromTabContents(tab_contents); } + return icons_updated; } void LocationBarViewMac::DeletePageActionDecorations() { |