Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2759)

Unified Diff: chrome/browser/themes/theme_service.cc

Issue 11445038: Revert changes to have ExtensionService notify ThemeService directly for themes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge error Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/themes/theme_service.cc
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 5457f1bafcaa7c287b0b40c08222dce319ef22c9..4dfe640fbaf7bbd21c836b6cce67337c09b33d2a 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -224,6 +224,14 @@ void ThemeService::Init(Profile* profile) {
DCHECK(CalledOnValidThread());
profile_ = profile;
+ // Listen to EXTENSION_LOADED instead of EXTENSION_INSTALLED because
+ // the extension cannot yet be found via GetExtensionById() if it is
+ // installed but not loaded (which may confuse listeners to
+ // BROWSER_THEME_CHANGED).
+ registrar_.Add(this,
+ chrome::NOTIFICATION_EXTENSION_LOADED,
+ content::Source<Profile>(profile_));
+
LoadThemePrefs();
theme_syncable_service_.reset(new ThemeSyncableService(profile_, this));
@@ -340,12 +348,6 @@ void ThemeService::SetTheme(const Extension* extension) {
DCHECK(extension);
DCHECK(extension->is_theme());
- if (DCHECK_IS_ON()) {
- ExtensionService* service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- DCHECK(service);
- DCHECK(service->GetExtensionById(extension->id(), false));
- }
BuildFromExtension(extension);
SaveThemeID(extension->id());
@@ -654,6 +656,17 @@ void ThemeService::FreePlatformCaches() {
}
#endif
+void ThemeService::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK(type == chrome::NOTIFICATION_EXTENSION_LOADED);
+ const Extension* extension = content::Details<const Extension>(details).ptr();
+ if (!extension->is_theme()) {
+ return;
+ }
+ SetTheme(extension);
+}
+
void ThemeService::SavePackName(const FilePath& pack_path) {
profile_->GetPrefs()->SetFilePath(
prefs::kCurrentThemePackFilename, pack_path);
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698