diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-19 21:07:58 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-19 21:07:58 +0000 |
commit | d585229d21c258da19a72bd1cb1a497b9b4aa2da (patch) | |
tree | a1830a6705d47e217e466160659ec2db8e91a9e5 /chrome/browser/ui/libgtk2ui | |
parent | c40bb80c758fc93b05a476125d8a179d9b1958b4 (diff) | |
download | chromium_src-d585229d21c258da19a72bd1cb1a497b9b4aa2da.zip chromium_src-d585229d21c258da19a72bd1cb1a497b9b4aa2da.tar.gz chromium_src-d585229d21c258da19a72bd1cb1a497b9b4aa2da.tar.bz2 |
linux_aura: Keep GTK state from leaking between profiles.
The views::LinuxUI* object is global across profiles. However, it stored
profile specific state in the form of a |use_gtk_| variable. This fixes
Gtk2Borders so that they ask their owning view for a ThemeProvider and
expands the ui::ThemeProvider interface so that it exposes the
UsingNativeTheme() call from the ThemeService layer, instead of asking
the views::LinuxUI provider directly, which will likely return stale state.
BUG=340805, 340799
Review URL: https://codereview.chromium.org/171413002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/libgtk2ui')
-rw-r--r-- | chrome/browser/ui/libgtk2ui/gtk2_border.cc | 15 | ||||
-rw-r--r-- | chrome/browser/ui/libgtk2ui/gtk2_border.h | 7 | ||||
-rw-r--r-- | chrome/browser/ui/libgtk2ui/gtk2_ui.cc | 19 | ||||
-rw-r--r-- | chrome/browser/ui/libgtk2ui/gtk2_ui.h | 2 |
4 files changed, 14 insertions, 29 deletions
diff --git a/chrome/browser/ui/libgtk2ui/gtk2_border.cc b/chrome/browser/ui/libgtk2ui/gtk2_border.cc index 4e8bfd1..8cffcd3 100644 --- a/chrome/browser/ui/libgtk2ui/gtk2_border.cc +++ b/chrome/browser/ui/libgtk2ui/gtk2_border.cc @@ -8,6 +8,7 @@ #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" #include "third_party/skia/include/effects/SkLerpXfermode.h" +#include "ui/base/theme_provider.h" #include "ui/gfx/animation/animation.h" #include "ui/gfx/canvas.h" #include "ui/gfx/image/image_skia_source.h" @@ -73,7 +74,6 @@ Gtk2Border::Gtk2Border(Gtk2UI* gtk2_ui, views::LabelButton* owning_button, scoped_ptr<views::Border> border) : gtk2_ui_(gtk2_ui), - use_gtk_(gtk2_ui_->GetUseSystemTheme()), owning_button_(owning_button), border_(border.Pass()) { gtk2_ui_->AddGtkBorder(this); @@ -83,7 +83,7 @@ Gtk2Border::~Gtk2Border() { gtk2_ui_->RemoveGtkBorder(this); } -void Gtk2Border::InvalidateAndSetUsesGtk(bool use_gtk) { +void Gtk2Border::InvalidateGtkImages() { for (int i = 0; i < kNumberOfFocusedStates; ++i) { for (int j = 0; j < views::Button::STATE_COUNT; ++j) { button_images_[i][j] = gfx::ImageSkia(); @@ -93,12 +93,11 @@ void Gtk2Border::InvalidateAndSetUsesGtk(bool use_gtk) { // Our owning view must have its layout invalidated because the insets could // have changed. owning_button_->InvalidateLayout(); - - use_gtk_ = use_gtk; } void Gtk2Border::Paint(const views::View& view, gfx::Canvas* canvas) { - if (!use_gtk_) { + ui::ThemeProvider* provider = owning_button_->GetThemeProvider(); + if (!provider || !provider->UsingNativeTheme()) { border_->Paint(view, canvas); return; } @@ -133,14 +132,16 @@ void Gtk2Border::Paint(const views::View& view, gfx::Canvas* canvas) { } gfx::Insets Gtk2Border::GetInsets() const { - if (!use_gtk_) + ui::ThemeProvider* provider = owning_button_->GetThemeProvider(); + if (!provider || !provider->UsingNativeTheme()) return border_->GetInsets(); return gtk2_ui_->GetButtonInsets(); } gfx::Size Gtk2Border::GetMinimumSize() const { - if (!use_gtk_) + ui::ThemeProvider* provider = owning_button_->GetThemeProvider(); + if (!provider || !provider->UsingNativeTheme()) return border_->GetMinimumSize(); gfx::Insets insets = GetInsets(); diff --git a/chrome/browser/ui/libgtk2ui/gtk2_border.h b/chrome/browser/ui/libgtk2ui/gtk2_border.h index d785480..b0fb24a 100644 --- a/chrome/browser/ui/libgtk2ui/gtk2_border.h +++ b/chrome/browser/ui/libgtk2ui/gtk2_border.h @@ -30,9 +30,9 @@ class Gtk2Border : public views::Border { scoped_ptr<views::Border> border); virtual ~Gtk2Border(); - // Called on theme changes. We invalidate the layout, drop our cached images, - // and update our GTK state. - void InvalidateAndSetUsesGtk(bool use_gtk); + // Called on theme changes. We invalidate the layout and drop our cached GTK + // rendered images. + void InvalidateGtkImages(); // Overridden from views::Border: virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE; @@ -48,7 +48,6 @@ class Gtk2Border : public views::Border { bool ShouldDrawBorder(bool focused, views::Button::ButtonState state); Gtk2UI* gtk2_ui_; - bool use_gtk_; gfx::ImageSkia button_images_[2][views::Button::STATE_COUNT]; diff --git a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc index c84955e..7d31bdf 100644 --- a/chrome/browser/ui/libgtk2ui/gtk2_ui.cc +++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.cc @@ -50,7 +50,6 @@ // // TODO(erg): There's still a lot that needs ported or done for the first time: // -// - Render and inject the button overlay from the gtk theme. // - Render and inject the omnibox background. // - Listen for the "style-set" signal on |fake_frame_| and recreate theme // colors and images. @@ -315,7 +314,7 @@ color_utils::HSL GetDefaultTint(int id) { namespace libgtk2ui { -Gtk2UI::Gtk2UI() : use_gtk_(false) { +Gtk2UI::Gtk2UI() { GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); } @@ -366,7 +365,7 @@ gfx::Image Gtk2UI::GetThemeImageNamed(int id) const { if (it != gtk_images_.end()) return it->second; - if (/*use_gtk_ && */ IsOverridableImage(id)) { + if (IsOverridableImage(id)) { gfx::Image image = gfx::Image( gfx::ImageSkia::CreateFrom1xBitmap(GenerateGtkThemeBitmap(id))); gtk_images_[id] = image; @@ -443,19 +442,7 @@ double Gtk2UI::GetCursorBlinkInterval() const { } ui::NativeTheme* Gtk2UI::GetNativeTheme() const { - return use_gtk_ ? NativeThemeGtk2::instance() : - ui::NativeTheme::instance(); -} - -void Gtk2UI::SetUseSystemTheme(bool use_system_theme) { - use_gtk_ = use_system_theme; - - FOR_EACH_OBSERVER(Gtk2Border, border_list_, - InvalidateAndSetUsesGtk(use_system_theme)); -} - -bool Gtk2UI::GetUseSystemTheme() const { - return use_gtk_; + return NativeThemeGtk2::instance(); } bool Gtk2UI::GetDefaultUsesSystemTheme() const { diff --git a/chrome/browser/ui/libgtk2ui/gtk2_ui.h b/chrome/browser/ui/libgtk2ui/gtk2_ui.h index 3516699..757438e 100644 --- a/chrome/browser/ui/libgtk2ui/gtk2_ui.h +++ b/chrome/browser/ui/libgtk2ui/gtk2_ui.h @@ -89,8 +89,6 @@ class Gtk2UI : public views::LinuxUI { virtual SkColor GetInactiveSelectionFgColor() const OVERRIDE; virtual double GetCursorBlinkInterval() const OVERRIDE; virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE; - virtual void SetUseSystemTheme(bool use_system_theme) OVERRIDE; - virtual bool GetUseSystemTheme() const OVERRIDE; virtual bool GetDefaultUsesSystemTheme() const OVERRIDE; virtual void SetDownloadCount(int count) const OVERRIDE; virtual void SetProgressFraction(float percentage) const OVERRIDE; |