diff options
-rw-r--r-- | chrome/browser/browser_theme_provider.cc | 14 | ||||
-rw-r--r-- | chrome/browser/browser_theme_provider.h | 11 | ||||
-rw-r--r-- | chrome/browser/dom_ui/dom_ui.cc | 1 | ||||
-rw-r--r-- | chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/theme_installed_infobar_delegate.cc | 23 | ||||
-rw-r--r-- | chrome/browser/extensions/theme_installed_infobar_delegate.h | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/dragged_tab_gtk.cc | 1 | ||||
-rw-r--r-- | chrome/browser/profile.cc | 4 | ||||
-rw-r--r-- | chrome/browser/profile.h | 4 | ||||
-rw-r--r-- | chrome/test/testing_profile.h | 2 |
10 files changed, 30 insertions, 38 deletions
diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc index ae08fa8..338e42e 100644 --- a/chrome/browser/browser_theme_provider.cc +++ b/chrome/browser/browser_theme_provider.cc @@ -179,8 +179,7 @@ bool BrowserThemeProvider::IsThemeableImage(int resource_id) { BrowserThemeProvider::BrowserThemeProvider() : rb_(ResourceBundle::GetSharedInstance()), - profile_(NULL), - number_of_infobars_(0) { + profile_(NULL) { // Initialize the themeable image map so we can use it on other threads. HasThemeableImage(0); } @@ -573,14 +572,3 @@ void BrowserThemeProvider::BuildFromExtension(Extension* extension) { SavePackName(pack_path); theme_pack_ = pack; } - -void BrowserThemeProvider::OnInfobarDisplayed() { - number_of_infobars_++; -} - -void BrowserThemeProvider::OnInfobarDestroyed() { - number_of_infobars_--; - - if (number_of_infobars_ == 0) - RemoveUnusedThemes(); -} diff --git a/chrome/browser/browser_theme_provider.h b/chrome/browser/browser_theme_provider.h index 756e2bc..e6275d6 100644 --- a/chrome/browser/browser_theme_provider.h +++ b/chrome/browser/browser_theme_provider.h @@ -129,14 +129,6 @@ class BrowserThemeProvider : public NonThreadSafe, // locally customized.) std::string GetThemeID() const; - // This class needs to keep track of the number of theme infobars so that we - // clean up unused themes. - void OnInfobarDisplayed(); - - // Decrements the number of theme infobars. If the last infobar has been - // destroyed, uninstalls all themes that aren't the currently selected. - void OnInfobarDestroyed(); - // Convert a bitfield alignment into a string like "top left". Public so that // it can be used to generate CSS values. Takes a bitfield of AlignmentMasks. static std::string AlignmentToString(int alignment); @@ -223,9 +215,6 @@ class BrowserThemeProvider : public NonThreadSafe, scoped_refptr<BrowserThemePack> theme_pack_; - // The number of infobars currently displayed. - int number_of_infobars_; - DISALLOW_COPY_AND_ASSIGN(BrowserThemeProvider); }; diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc index 5017a9f..34c5956 100644 --- a/chrome/browser/dom_ui/dom_ui.cc +++ b/chrome/browser/dom_ui/dom_ui.cc @@ -9,7 +9,6 @@ #include "base/stl_util-inl.h" #include "base/string_util.h" #include "base/values.h" -#include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" diff --git a/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc index d3fc1c0..efca805 100644 --- a/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/gtk_theme_installed_infobar_delegate.cc @@ -16,6 +16,8 @@ GtkThemeInstalledInfoBarDelegate::GtkThemeInstalledInfoBarDelegate( } bool GtkThemeInstalledInfoBarDelegate::Cancel() { + was_canceled_ = true; + if (previous_use_gtk_theme_) { profile()->SetNativeTheme(); return true; diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc index 07072c0..caea07d 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc @@ -7,7 +7,6 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/string_util.h" -#include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -19,17 +18,28 @@ ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate( TabContents* tab_contents, const Extension* new_theme, const std::string& previous_theme_id) : ConfirmInfoBarDelegate(tab_contents), + was_canceled_(false), profile_(tab_contents->profile()), name_(new_theme->name()), + new_theme_id_(new_theme->id()), previous_theme_id_(previous_theme_id) { - profile_->GetThemeProvider()->OnInfobarDisplayed(); -} - -ThemeInstalledInfoBarDelegate::~ThemeInstalledInfoBarDelegate() { - profile_->GetThemeProvider()->OnInfobarDestroyed(); } void ThemeInstalledInfoBarDelegate::InfoBarClosed() { + ExtensionsService* service = profile_->GetExtensionsService(); + // Only delete the theme if we've installed a new theme and not the same + // theme on top of the current one. + if (service && previous_theme_id_ != new_theme_id_) { + std::string uninstall_id; + if (was_canceled_) + uninstall_id = new_theme_id_; + else if (!previous_theme_id_.empty()) + uninstall_id = previous_theme_id_; + // It's possible that the theme was already uninstalled by someone so make + // sure it exists. + if (!uninstall_id.empty() && service->GetExtensionById(uninstall_id, true)) + service->UninstallExtension(uninstall_id, false); + } delete this; } @@ -68,6 +78,7 @@ std::wstring ThemeInstalledInfoBarDelegate::GetButtonLabel( } bool ThemeInstalledInfoBarDelegate::Cancel() { + was_canceled_ = true; if (!previous_theme_id_.empty()) { ExtensionsService* service = profile_->GetExtensionsService(); if (service) { diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h index b8baf41..daa11e6 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.h +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h @@ -18,7 +18,6 @@ class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate { ThemeInstalledInfoBarDelegate(TabContents* tab_contents, const Extension* new_theme, const std::string& previous_theme_id); - virtual ~ThemeInstalledInfoBarDelegate(); virtual void InfoBarClosed(); virtual std::wstring GetMessageText() const; virtual SkBitmap* GetIcon() const; @@ -31,10 +30,15 @@ class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate { protected: Profile* profile() { return profile_; } + // Keeps track of whether we canceled the install or not. + bool was_canceled_; + private: Profile* profile_; // Name of theme that's just been installed. std::string name_; + // Id of theme that's just been installed. + std::string new_theme_id_; // Used to undo theme install. std::string previous_theme_id_; }; diff --git a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc index 12e9639..40127ca 100644 --- a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc +++ b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc @@ -11,7 +11,6 @@ #include "app/gfx/canvas_paint.h" #include "app/gfx/gtk_util.h" #include "app/l10n_util.h" -#include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tabs/tab_strip_model.h" diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 7b1b80e..e61ae5a 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -464,7 +464,7 @@ class OffTheRecordProfileImpl : public Profile, return GetOriginalProfile()->GetTheme(); } - virtual BrowserThemeProvider* GetThemeProvider() { + virtual ThemeProvider* GetThemeProvider() { return GetOriginalProfile()->GetThemeProvider(); } @@ -1228,7 +1228,7 @@ Extension* ProfileImpl::GetTheme() { return extensions_service_->GetExtensionById(id, false); } -BrowserThemeProvider* ProfileImpl::GetThemeProvider() { +ThemeProvider* ProfileImpl::GetThemeProvider() { InitThemes(); return theme_provider_.get(); } diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h index 95f76b0..e72dbd7 100644 --- a/chrome/browser/profile.h +++ b/chrome/browser/profile.h @@ -272,7 +272,7 @@ class Profile { virtual Extension* GetTheme() = 0; // Returns or creates the ThemeProvider associated with this profile - virtual BrowserThemeProvider* GetThemeProvider() = 0; + virtual ThemeProvider* GetThemeProvider() = 0; virtual ThumbnailStore* GetThumbnailStore() = 0; @@ -435,7 +435,7 @@ class ProfileImpl : public Profile, virtual void SetNativeTheme(); virtual void ClearTheme(); virtual Extension* GetTheme(); - virtual BrowserThemeProvider* GetThemeProvider(); + virtual ThemeProvider* GetThemeProvider(); virtual ThumbnailStore* GetThumbnailStore(); virtual bool HasCreatedDownloadManager() const; virtual URLRequestContextGetter* GetRequestContext(); diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index 91066f7..7e01ff0 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -136,7 +136,7 @@ class TestingProfile : public Profile { virtual void SetNativeTheme() {} virtual void ClearTheme() {} virtual Extension* GetTheme() { return NULL; } - virtual BrowserThemeProvider* GetThemeProvider() { + virtual ThemeProvider* GetThemeProvider() { InitThemes(); return theme_provider_.get(); } |