summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc17
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.h11
2 files changed, 27 insertions, 1 deletions
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index 7de4808..c37b4f1 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -262,6 +262,9 @@ TabRendererGtk::TabRendererGtk(ThemeProvider* theme_provider)
hover_animation_.reset(new SlideAnimation(this));
hover_animation_->SetSlideDuration(kHoverDurationMs);
+
+ registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
+ NotificationService::AllSources());
}
TabRendererGtk::~TabRendererGtk() {
@@ -530,6 +533,20 @@ void TabRendererGtk::SetBounds(const gfx::Rect& bounds) {
gtk_widget_set_size_request(tab_.get(), bounds.width(), bounds.height());
}
+void TabRendererGtk::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(type == NotificationType::BROWSER_THEME_CHANGED);
+
+ // Clear our cache when we receive a theme change notification because it
+ // contains cached bitmaps based off the previous theme.
+ for (BitmapCache::iterator it = cached_bitmaps_.begin();
+ it != cached_bitmaps_.end(); ++it) {
+ delete it->second.bitmap;
+ }
+ cached_bitmaps_.clear();
+}
+
////////////////////////////////////////////////////////////////////////////////
// TabRendererGtk, protected:
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
index 0c50f12..440a0d7 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
@@ -30,7 +30,8 @@ class TabContents;
class ThemeProvider;
class ThrobAnimation;
-class TabRendererGtk : public AnimationDelegate {
+class TabRendererGtk : public AnimationDelegate,
+ public NotificationObserver {
public:
// Possible animation states.
enum AnimationState {
@@ -146,6 +147,11 @@ class TabRendererGtk : public AnimationDelegate {
// Sets the bounds of the tab.
virtual void SetBounds(const gfx::Rect& bounds);
+ // Provide NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
// Advance the loading animation to the next frame, or hide the animation if
// the tab isn't loading. Returns |true| if the icon area needs to be
// repainted.
@@ -407,6 +413,9 @@ class TabRendererGtk : public AnimationDelegate {
// The current color of the close button.
SkColor close_button_color_;
+ // Used to listen for theme change notifications.
+ NotificationRegistrar registrar_;
+
DISALLOW_COPY_AND_ASSIGN(TabRendererGtk);
};