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

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

Issue 2893693002: Remove NOTIFICATION_EXTENSION_ENABLED. (Closed)
Patch Set: Created 3 years, 7 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 3a0161e9881e235d2e307ff2307da9b772a3538d..dab060c65898b52bb8ba43be2bcefaacdda5bd95 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -49,6 +49,7 @@
#include "ui/native_theme/native_theme.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
+#include "base/scoped_observer.h"
#include "extensions/browser/extension_registry_observer.h"
#endif
@@ -160,17 +161,17 @@ base::RefCountedMemory* ThemeService::BrowserThemeProvider::GetRawData(
class ThemeService::ThemeObserver
: public extensions::ExtensionRegistryObserver {
public:
- explicit ThemeObserver(ThemeService* service) : theme_service_(service) {
- extensions::ExtensionRegistry::Get(theme_service_->profile_)
- ->AddObserver(this);
+ explicit ThemeObserver(ThemeService* service)
+ : theme_service_(service), extension_registry_observer_(this) {
+ extension_registry_observer_.Add(
+ extensions::ExtensionRegistry::Get(theme_service_->profile_));
}
~ThemeObserver() override {
- extensions::ExtensionRegistry::Get(theme_service_->profile_)
- ->RemoveObserver(this);
}
private:
+ // extensions::ExtensionRegistryObserver::
void OnExtensionWillBeInstalled(content::BrowserContext* browser_context,
const extensions::Extension* extension,
bool is_update,
@@ -191,6 +192,12 @@ class ThemeService::ThemeObserver
theme_service_->installed_pending_load_id_ = kDefaultThemeID;
}
+ void OnExtensionEnabled(content::BrowserContext* browser_context,
Devlin 2017/05/17 18:37:48 Hmm... does this care about enablement? OnExtensi
lazyboy 2017/05/17 22:23:25 Is it possible for a theme to be loaded but it sta
Devlin 2017/05/18 01:34:45 I don't know how it could be. If it's disabled, w
lazyboy 2017/05/18 18:10:52 I missed the comments over installed_pending_load_
+ const extensions::Extension* extension) override {
+ if (extension->is_theme())
+ theme_service_->SetTheme(extension);
+ }
+
void OnExtensionUnloaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension,
@@ -204,6 +211,12 @@ class ThemeService::ThemeObserver
}
ThemeService* theme_service_;
+
+ ScopedObserver<extensions::ExtensionRegistry,
+ extensions::ExtensionRegistryObserver>
+ extension_registry_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThemeObserver);
};
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
@@ -258,12 +271,6 @@ void ThemeService::Observe(int type,
content::Source<Profile>(profile_));
OnExtensionServiceReady();
break;
- case extensions::NOTIFICATION_EXTENSION_ENABLED: {
- const Extension* extension = Details<const Extension>(details).ptr();
- if (extension->is_theme())
- SetTheme(extension);
- break;
- }
default:
NOTREACHED();
}
@@ -791,13 +798,9 @@ void ThemeService::OnExtensionServiceReady() {
}
#if BUILDFLAG(ENABLE_EXTENSIONS)
- theme_observer_.reset(new ThemeObserver(this));
+ theme_observer_ = base::MakeUnique<ThemeObserver>(this);
#endif
- registrar_.Add(this,
- extensions::NOTIFICATION_EXTENSION_ENABLED,
- content::Source<Profile>(profile_));
-
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&ThemeService::RemoveUnusedThemes,
weak_ptr_factory_.GetWeakPtr(), false),

Powered by Google App Engine
This is Rietveld 408576698