diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 17:18:02 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 17:18:02 +0000 |
commit | 3b5f92640e0634eb5c071edd0c92eb992630b96c (patch) | |
tree | 5115e8205ef673e4bd0b6ca9ca77b9193b2d586a | |
parent | 89cabc49e14c635d9aae572d34443f3c9c44ffd6 (diff) | |
download | chromium_src-3b5f92640e0634eb5c071edd0c92eb992630b96c.zip chromium_src-3b5f92640e0634eb5c071edd0c92eb992630b96c.tar.gz chromium_src-3b5f92640e0634eb5c071edd0c92eb992630b96c.tar.bz2 |
GTK Themes: The Theme Installed Infobar's "Undo" button should work with GTK Themes.
http://crbug.com/20629
Review URL: http://codereview.chromium.org/181022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25050 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 86 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index 08740a5..732019f 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -26,6 +26,9 @@ #include "base/scoped_cftyperef.h" #include "base/sys_string_conversions.h" #include <CoreFoundation/CFUserNotification.h> +#elif defined(TOOLKIT_GTK) +#include "chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h" +#include "chrome/browser/gtk/gtk_theme_provider.h" #endif namespace { @@ -82,7 +85,11 @@ static std::wstring GetInstallWarning(Extension* extension) { } ExtensionInstallUI::ExtensionInstallUI(Profile* profile) - : profile_(profile), ui_loop_(MessageLoop::current()) { + : profile_(profile), ui_loop_(MessageLoop::current()) +#if defined(TOOLKIT_GTK) + ,previous_use_gtk_theme_(false) +#endif +{ } void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, @@ -99,6 +106,13 @@ void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, if (previous_theme) previous_theme_id_ = previous_theme->id(); +#if defined(TOOLKIT_GTK) + // On linux, we also need to take the user's system settings into account + // to undo theme installation. + previous_use_gtk_theme_ = + GtkThemeProvider::GetFrom(profile_)->UseGtkTheme(); +#endif + delegate->ContinueInstall(); return; } @@ -215,8 +229,15 @@ void ExtensionInstallUI::ShowThemeInfoBar(Extension* new_theme) { } // Then either replace that old one or add a new one. - InfoBarDelegate* new_delegate = new ThemePreviewInfobarDelegate(tab_contents, - new_theme->name(), previous_theme_id_); + InfoBarDelegate* new_delegate = +#if defined(TOOLKIT_GTK) + new GtkThemePreviewInfobarDelegate( + tab_contents, + new_theme->name(), previous_theme_id_, previous_use_gtk_theme_); +#else + new ThemePreviewInfobarDelegate(tab_contents, + new_theme->name(), previous_theme_id_); +#endif if (old_delegate) tab_contents->ReplaceInfoBar(old_delegate, new_delegate); diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h index 0147d9c..9d97b73 100644 --- a/chrome/browser/extensions/extension_install_ui.h +++ b/chrome/browser/extensions/extension_install_ui.h @@ -65,6 +65,11 @@ class ExtensionInstallUI { Profile* profile_; MessageLoop* ui_loop_; std::string previous_theme_id_; // Used to undo theme installation. + +#if defined(TOOLKIT_GTK) + // Also needed to undo theme installation in the linux UI. + bool previous_use_gtk_theme_; +#endif }; #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ diff --git a/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.cc b/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.cc new file mode 100644 index 0000000..e577158 --- /dev/null +++ b/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.cc @@ -0,0 +1,25 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h" + +#include "chrome/browser/profile.h" + +GtkThemePreviewInfobarDelegate::GtkThemePreviewInfobarDelegate( + TabContents* tab_contents, + const std::string& name, + const std::string& previous_theme, + bool previous_use_gtk_theme) + : ThemePreviewInfobarDelegate(tab_contents, name, previous_theme), + previous_use_gtk_theme_(previous_use_gtk_theme) { +} + +bool GtkThemePreviewInfobarDelegate::Cancel() { + if (previous_use_gtk_theme_) { + profile()->SetNativeTheme(); + return true; + } else { + return ThemePreviewInfobarDelegate::Cancel(); + } +} diff --git a/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h b/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h new file mode 100644 index 0000000..cfc213de --- /dev/null +++ b/chrome/browser/extensions/gtk_theme_preview_infobar_delegate.h @@ -0,0 +1,27 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_ +#define CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_ + +#include "chrome/browser/extensions/theme_preview_infobar_delegate.h" + +class SkBitmap; +class TabContents; + +// A specialization of ThemePreviewInfobarDelegate to make "Undo" reset to the +// GTK theme if the user was in GTK theme mode before installing the theme. +class GtkThemePreviewInfobarDelegate : public ThemePreviewInfobarDelegate { + public: + GtkThemePreviewInfobarDelegate(TabContents* tab_contents, + const std::string& name, + const std::string& previous_theme, + bool previous_use_gtk_theme); + virtual bool Cancel(); + + private: + bool previous_use_gtk_theme_; +}; + +#endif // CHROME_BROWSER_VIEWS_EXTENSIONS_GTK_THEME_PREVIEW_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/extensions/theme_preview_infobar_delegate.h b/chrome/browser/extensions/theme_preview_infobar_delegate.h index 9b214bb..fdffe07 100644 --- a/chrome/browser/extensions/theme_preview_infobar_delegate.h +++ b/chrome/browser/extensions/theme_preview_infobar_delegate.h @@ -29,6 +29,9 @@ class ThemePreviewInfobarDelegate : public ConfirmInfoBarDelegate { ConfirmInfoBarDelegate::InfoBarButton button) const; virtual bool Cancel(); + protected: + Profile* profile() { return profile_; } + private: Profile* profile_; std::string name_; // name of theme to install diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 3e23149..f8c8485 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1141,6 +1141,8 @@ 'browser/extensions/external_registry_extension_provider_win.h', 'browser/extensions/external_pref_extension_provider.cc', 'browser/extensions/external_pref_extension_provider.h', + 'browser/extensions/gtk_theme_preview_infobar_delegate.cc', + 'browser/extensions/gtk_theme_preview_infobar_delegate.h', 'browser/extensions/pack_extension_job.cc', 'browser/extensions/pack_extension_job.h', 'browser/extensions/sandboxed_extension_unpacker.cc', |