summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 22:10:11 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 22:10:11 +0000
commit6d1b928bc85521046fa7713abadc762beba11881 (patch)
treebb07a4b93384148cf026ac330da81f45f5e106cb
parente170eec2d5259da87c2596d83851267d2e0e5426 (diff)
downloadchromium_src-6d1b928bc85521046fa7713abadc762beba11881.zip
chromium_src-6d1b928bc85521046fa7713abadc762beba11881.tar.gz
chromium_src-6d1b928bc85521046fa7713abadc762beba11881.tar.bz2
Revert 44134 - Show Infobar on new synced theme even if the theme was already
installed (but not loaded). Refactored theme handling code in ExtensionInstallerUI. BUG=40847 TEST=manual Review URL: http://codereview.chromium.org/1625007 TBR=akalin@chromium.org Review URL: http://codereview.chromium.org/1599024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44139 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc38
-rwxr-xr-xchrome/browser/extensions/extension_install_ui.h34
-rw-r--r--chrome/browser/sync/glue/theme_util.cc35
3 files changed, 38 insertions, 69 deletions
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 00c6a51..76eacdd 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -136,11 +136,14 @@ static void GetV2Warnings(Extension* extension,
ExtensionInstallUI::ExtensionInstallUI(Profile* profile)
: profile_(profile),
ui_loop_(MessageLoop::current()),
- previous_use_system_theme_(false),
extension_(NULL),
delegate_(NULL),
prompt_type_(NUM_PROMPT_TYPES),
- ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) {}
+ ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this))
+#if defined(TOOLKIT_GTK)
+ , previous_use_gtk_theme_(false)
+#endif
+{}
void ExtensionInstallUI::ConfirmInstall(Delegate* delegate,
Extension* extension) {
@@ -160,10 +163,8 @@ void ExtensionInstallUI::ConfirmInstall(Delegate* delegate,
#if defined(TOOLKIT_GTK)
// On Linux, we also need to take the user's system settings into account
// to undo theme installation.
- previous_use_system_theme_ =
+ previous_use_gtk_theme_ =
GtkThemeProvider::GetFrom(profile_)->UseGtkTheme();
-#else
- DCHECK(!previous_use_system_theme_);
#endif
delegate->InstallUIProceed(false);
@@ -193,8 +194,7 @@ void ExtensionInstallUI::ConfirmEnableIncognito(Delegate* delegate,
void ExtensionInstallUI::OnInstallSuccess(Extension* extension) {
if (extension->IsTheme()) {
- ShowThemeInfoBar(previous_theme_id_, previous_use_system_theme_,
- extension, profile_);
+ ShowThemeInfoBar(extension);
return;
}
@@ -242,8 +242,7 @@ void ExtensionInstallUI::OnInstallFailure(const std::string& error) {
}
void ExtensionInstallUI::OnOverinstallAttempted(Extension* extension) {
- ShowThemeInfoBar(previous_theme_id_, previous_use_system_theme_,
- extension, profile_);
+ ShowThemeInfoBar(extension);
}
void ExtensionInstallUI::OnImageLoaded(
@@ -291,13 +290,11 @@ void ExtensionInstallUI::OnImageLoaded(
}
}
-void ExtensionInstallUI::ShowThemeInfoBar(
- const std::string& previous_theme_id, bool previous_use_system_theme,
- Extension* new_theme, Profile* profile) {
+void ExtensionInstallUI::ShowThemeInfoBar(Extension* new_theme) {
if (!new_theme->IsTheme())
return;
- Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
+ Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
if (!browser)
return;
@@ -316,10 +313,8 @@ void ExtensionInstallUI::ShowThemeInfoBar(
}
// Then either replace that old one or add a new one.
- InfoBarDelegate* new_delegate =
- GetNewThemeInstalledInfoBarDelegate(
- tab_contents, new_theme,
- previous_theme_id, previous_use_system_theme);
+ InfoBarDelegate* new_delegate = GetNewInfoBarDelegate(new_theme,
+ tab_contents);
if (old_delegate)
tab_contents->ReplaceInfoBar(old_delegate, new_delegate);
@@ -358,14 +353,13 @@ void ExtensionInstallUI::ShowGenericExtensionInstalledInfoBar(
}
#endif
-InfoBarDelegate* ExtensionInstallUI::GetNewThemeInstalledInfoBarDelegate(
- TabContents* tab_contents, Extension* new_theme,
- const std::string& previous_theme_id, bool previous_use_system_theme) {
+InfoBarDelegate* ExtensionInstallUI::GetNewInfoBarDelegate(
+ Extension* new_theme, TabContents* tab_contents) {
#if defined(TOOLKIT_GTK)
return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme,
- previous_theme_id, previous_use_system_theme);
+ previous_theme_id_, previous_use_gtk_theme_);
#else
return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme,
- previous_theme_id);
+ previous_theme_id_);
#endif
}
diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h
index 1fb4b87..822060d 100755
--- a/chrome/browser/extensions/extension_install_ui.h
+++ b/chrome/browser/extensions/extension_install_ui.h
@@ -89,17 +89,11 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
virtual void OnImageLoaded(
SkBitmap* image, ExtensionResource resource, int index);
- // Show an infobar for a newly-installed theme. previous_theme_id
- // should be empty if the previous theme was the system/default
- // theme.
- //
- // TODO(akalin): Find a better home for this (and
- // GetNewThemeInstalledInfoBarDelegate()).
- static void ShowThemeInfoBar(
- const std::string& previous_theme_id, bool previous_use_system_theme,
- Extension* new_theme, Profile* profile);
-
private:
+ // When a Theme is downloaded it is applied and an info bar is shown to give
+ // the user a choice to keep it or undo the installation.
+ void ShowThemeInfoBar(Extension* new_theme);
+
// Starts the process of showing a confirmation UI, which is split into two.
// 1) Set off a 'load icon' task.
// 2) Handle the load icon response and show the UI (OnImageLoaded).
@@ -111,11 +105,10 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
void ShowGenericExtensionInstalledInfoBar(Extension* new_extension);
#endif
- // Returns the delegate to control the browser's info bar. This is
- // within its own function due to its platform-specific nature.
- static InfoBarDelegate* GetNewThemeInstalledInfoBarDelegate(
- TabContents* tab_contents, Extension* new_theme,
- const std::string& previous_theme_id, bool previous_use_system_theme);
+ // Returns the delegate to control the browser's info bar. This is within its
+ // own function due to its platform-specific nature.
+ InfoBarDelegate* GetNewInfoBarDelegate(Extension* new_theme,
+ TabContents* tab_contents);
// Implements the showing of the install/uninstall dialog prompt.
// NOTE: The implementations of this function is platform-specific.
@@ -131,11 +124,7 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
Profile* profile_;
MessageLoop* ui_loop_;
-
- // Used to undo theme installation.
- std::string previous_theme_id_;
- bool previous_use_system_theme_;
-
+ std::string previous_theme_id_; // Used to undo theme installation.
SkBitmap icon_; // The extensions installation icon.
Extension* extension_; // The extension we are showing the UI for.
Delegate* delegate_; // The delegate we will call Proceed/Abort on after
@@ -145,6 +134,11 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
// Keeps track of extension images being loaded on the File thread for the
// purpose of showing the install UI.
ImageLoadingTracker tracker_;
+
+#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/sync/glue/theme_util.cc b/chrome/browser/sync/glue/theme_util.cc
index 6310afe..ada5f72 100644
--- a/chrome/browser/sync/glue/theme_util.cc
+++ b/chrome/browser/sync/glue/theme_util.cc
@@ -9,12 +9,8 @@
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/version.h"
-#include "chrome/browser/extensions/extension_install_ui.h"
#include "chrome/browser/extensions/extension_updater.h"
#include "chrome/browser/extensions/extensions_service.h"
-#if defined(TOOLKIT_GTK)
-#include "chrome/browser/gtk/gtk_theme_provider.h"
-#endif
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/sync/protocol/theme_specifics.pb.h"
@@ -37,14 +33,6 @@ bool IsSystemThemeDistinctFromDefaultTheme() {
#endif
}
-bool UseSystemTheme(Profile* profile) {
-#if defined(TOOLKIT_USES_GTK)
- return GtkThemeProvider::GetFrom(profile)->UseGtkTheme();
-#else
- return false;
-#endif
-}
-
} // namespace
bool AreThemeSpecificsEqual(const sync_pb::ThemeSpecifics& a,
@@ -106,23 +94,11 @@ void SetCurrentThemeFromThemeSpecifics(
LOG(INFO) << "Theme " << id << " is not enabled; aborting";
return;
}
- // Get previous theme info before we set the new theme.
- std::string previous_theme_id;
- {
- const Extension* current_theme = profile->GetTheme();
- if (current_theme) {
- DCHECK(current_theme->IsTheme());
- previous_theme_id = current_theme->id();
- }
- }
- bool previous_use_system_theme = UseSystemTheme(profile);
// An enabled theme extension with the given id was found, so
// just set the current theme to it.
+ // TODO(akalin): Figure out what to do about the fact that this
+ // applies the theme silently (i.e., without an infobar).
profile->SetTheme(extension);
- // Pretend the theme was just installed.
- ExtensionInstallUI::ShowThemeInfoBar(
- previous_theme_id, previous_use_system_theme,
- extension, profile);
} else {
// No extension with this id exists -- we must install it; we do
// so by adding it as a pending extension and then triggering an
@@ -161,10 +137,15 @@ void GetThemeSpecificsFromCurrentTheme(
if (current_theme) {
DCHECK(current_theme->IsTheme());
}
+ bool use_system_theme_by_default = false;
+#if defined(TOOLKIT_USES_GTK)
+ use_system_theme_by_default =
+ profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme);
+#endif
GetThemeSpecificsFromCurrentThemeHelper(
current_theme,
IsSystemThemeDistinctFromDefaultTheme(),
- UseSystemTheme(profile),
+ use_system_theme_by_default,
theme_specifics);
}