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

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

Issue 965233002: Remove deprecated extension notification from theme_service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ExtensionRegistryObserver and Call from ExtensionService instead. Created 5 years, 9 months 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
Index: chrome/browser/themes/theme_service.cc
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 7b20d395050affc0ef04d13c678e325166625070..c7cad917822d3ef3b0581e9fdee9f0a56af5dd4b 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -96,12 +96,45 @@ bool IsColorGrayscale(SkColor color) {
} // namespace
+ThemeService::ExtensionObserver::ExtensionObserver(ThemeService& service)
+ : theme_service_(service) {
+}
+
+ThemeService::ExtensionObserver::~ExtensionObserver() {
+}
+
+void ThemeService::ExtensionObserver::OnExtensionWillBeInstalled(
+ const extensions::Extension* extension) {
+ if (extension->is_theme()) {
+ // The theme may be initially disabled. Wait till it is loaded (if ever).
+ theme_service_.installed_pending_load_id_ = extension->id();
+ }
+}
+
+void ThemeService::ExtensionObserver::OnExtensionLoaded(
+ const extensions::Extension* extension) {
+ if (extension->is_theme() &&
+ theme_service_.installed_pending_load_id_ != kDefaultThemeID &&
+ theme_service_.installed_pending_load_id_ == extension->id()) {
+ theme_service_.SetTheme(extension);
+ }
+ theme_service_.installed_pending_load_id_ = kDefaultThemeID;
+}
+
+void ThemeService::ExtensionObserver::OnExtensionUnloaded(
+ const extensions::Extension* extension) {
+ if (extension->is_theme() && extension->id() == theme_service_.GetThemeID()) {
+ theme_service_.UseDefaultTheme();
+ }
+}
+
ThemeService::ThemeService()
: ready_(false),
rb_(ResourceBundle::GetSharedInstance()),
profile_(NULL),
installed_pending_load_id_(kDefaultThemeID),
number_of_infobars_(0),
+ extension_observer_(*this),
weak_ptr_factory_(this) {
}
@@ -268,40 +301,12 @@ void ThemeService::Observe(int type,
content::Source<Profile>(profile_));
OnExtensionServiceReady();
break;
- case extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED: {
- // The theme may be initially disabled. Wait till it is loaded (if ever).
- Details<const extensions::InstalledExtensionInfo> installed_details(
- details);
- if (installed_details->extension->is_theme())
- installed_pending_load_id_ = installed_details->extension->id();
- break;
- }
- case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
- const Extension* extension = Details<const Extension>(details).ptr();
- if (extension->is_theme() &&
- installed_pending_load_id_ != kDefaultThemeID &&
- installed_pending_load_id_ == extension->id()) {
- SetTheme(extension);
- }
- installed_pending_load_id_ = kDefaultThemeID;
- break;
- }
case extensions::NOTIFICATION_EXTENSION_ENABLED: {
const Extension* extension = Details<const Extension>(details).ptr();
if (extension->is_theme())
SetTheme(extension);
break;
}
- case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
- Details<const UnloadedExtensionInfo> unloaded_details(details);
- if (unloaded_details->reason != UnloadedExtensionInfo::REASON_UPDATE &&
- unloaded_details->reason != UnloadedExtensionInfo::REASON_LOCK_ALL &&
- unloaded_details->extension->is_theme() &&
- unloaded_details->extension->id() == GetThemeID()) {
- UseDefaultTheme();
- }
- break;
- }
}
}
@@ -529,19 +534,9 @@ void ThemeService::OnExtensionServiceReady() {
NotifyThemeChanged();
}
- registrar_.Add(
- this,
- extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
- content::Source<Profile>(profile_));
- registrar_.Add(this,
- extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
- content::Source<Profile>(profile_));
registrar_.Add(this,
extensions::NOTIFICATION_EXTENSION_ENABLED,
content::Source<Profile>(profile_));
- registrar_.Add(this,
- extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
- content::Source<Profile>(profile_));
base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
base::Bind(&ThemeService::RemoveUnusedThemes,
@@ -636,3 +631,7 @@ void ThemeService::OnInfobarDestroyed() {
ThemeSyncableService* ThemeService::GetThemeSyncableService() const {
return theme_syncable_service_.get();
}
+
+ThemeService::ExtensionObserver ThemeService::extension_observer() const {
+ return extension_observer_;
+}

Powered by Google App Engine
This is Rietveld 408576698