summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/glue/theme_util.cc
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 23:15:13 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 23:15:13 +0000
commitf5a723719c2df2ba09915e6afcf1d54c5e445fa0 (patch)
tree415e0f5e9e8840e5e5212e4cab4f1dfcae29967a /chrome/browser/sync/glue/theme_util.cc
parent5e7a6bc9cca84dc5554ce9f145f83871972c0725 (diff)
downloadchromium_src-f5a723719c2df2ba09915e6afcf1d54c5e445fa0.zip
chromium_src-f5a723719c2df2ba09915e6afcf1d54c5e445fa0.tar.gz
chromium_src-f5a723719c2df2ba09915e6afcf1d54c5e445fa0.tar.bz2
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 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=44134 Review URL: http://codereview.chromium.org/1625007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44157 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/glue/theme_util.cc')
-rw-r--r--chrome/browser/sync/glue/theme_util.cc35
1 files changed, 27 insertions, 8 deletions
diff --git a/chrome/browser/sync/glue/theme_util.cc b/chrome/browser/sync/glue/theme_util.cc
index ada5f72..75f768a 100644
--- a/chrome/browser/sync/glue/theme_util.cc
+++ b/chrome/browser/sync/glue/theme_util.cc
@@ -9,8 +9,12 @@
#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_USES_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"
@@ -33,6 +37,14 @@ 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,
@@ -94,11 +106,23 @@ 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
@@ -137,15 +161,10 @@ 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(),
- use_system_theme_by_default,
+ UseSystemTheme(profile),
theme_specifics);
}