blob: a0ffd99849a6275bdaad88e24d920eeb023bc520 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_web_ui_override_registrar.h"
#include "base/lazy_instance.h"
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/browser/extension_registry.h"
namespace extensions {
ExtensionWebUIOverrideRegistrar::ExtensionWebUIOverrideRegistrar(
content::BrowserContext* context)
: extension_registry_observer_(this) {
extension_registry_observer_.Add(ExtensionRegistry::Get(context));
}
ExtensionWebUIOverrideRegistrar::~ExtensionWebUIOverrideRegistrar() {
}
void ExtensionWebUIOverrideRegistrar::OnExtensionLoaded(
content::BrowserContext* browser_context,
const Extension* extension) {
ExtensionWebUI::RegisterChromeURLOverrides(
Profile::FromBrowserContext(browser_context),
URLOverrides::GetChromeURLOverrides(extension));
}
void ExtensionWebUIOverrideRegistrar::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionInfo::Reason reason) {
ExtensionWebUI::UnregisterChromeURLOverrides(
Profile::FromBrowserContext(browser_context),
URLOverrides::GetChromeURLOverrides(extension));
}
static base::LazyInstance<
BrowserContextKeyedAPIFactory<ExtensionWebUIOverrideRegistrar> > g_factory =
LAZY_INSTANCE_INITIALIZER;
// static
BrowserContextKeyedAPIFactory<ExtensionWebUIOverrideRegistrar>*
ExtensionWebUIOverrideRegistrar::GetFactoryInstance() {
return g_factory.Pointer();
}
} // namespace extensions
|