This source file includes following definitions.
- Observe
- GetFactoryInstance
#include "chrome/browser/extensions/extension_web_ui_override_registrar.h"
#include "base/lazy_instance.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
namespace extensions {
ExtensionWebUIOverrideRegistrar::ExtensionWebUIOverrideRegistrar(
content::BrowserContext* context)
: profile_(Profile::FromBrowserContext(context)) {
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(profile_));
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
content::Source<Profile>(profile_));
}
ExtensionWebUIOverrideRegistrar::~ExtensionWebUIOverrideRegistrar() {
}
void ExtensionWebUIOverrideRegistrar::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
const Extension* extension =
content::Details<const Extension>(details).ptr();
ExtensionWebUI::RegisterChromeURLOverrides(
profile_, URLOverrides::GetChromeURLOverrides(extension));
} else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) {
const Extension* extension =
content::Details<UnloadedExtensionInfo>(details)->extension;
ExtensionWebUI::UnregisterChromeURLOverrides(
profile_, URLOverrides::GetChromeURLOverrides(extension));
}
}
static base::LazyInstance<
BrowserContextKeyedAPIFactory<ExtensionWebUIOverrideRegistrar> > g_factory =
LAZY_INSTANCE_INITIALIZER;
BrowserContextKeyedAPIFactory<ExtensionWebUIOverrideRegistrar>*
ExtensionWebUIOverrideRegistrar::GetFactoryInstance() {
return g_factory.Pointer();
}
}