Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_web_ui_override_registrar.cc
bloba0ffd99849a6275bdaad88e24d920eeb023bc520
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/extension_web_ui_override_registrar.h"
7 #include "base/lazy_instance.h"
8 #include "chrome/browser/extensions/extension_web_ui.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "extensions/browser/extension_registry.h"
12 namespace extensions {
14 ExtensionWebUIOverrideRegistrar::ExtensionWebUIOverrideRegistrar(
15 content::BrowserContext* context)
16 : extension_registry_observer_(this) {
17 extension_registry_observer_.Add(ExtensionRegistry::Get(context));
20 ExtensionWebUIOverrideRegistrar::~ExtensionWebUIOverrideRegistrar() {
23 void ExtensionWebUIOverrideRegistrar::OnExtensionLoaded(
24 content::BrowserContext* browser_context,
25 const Extension* extension) {
26 ExtensionWebUI::RegisterChromeURLOverrides(
27 Profile::FromBrowserContext(browser_context),
28 URLOverrides::GetChromeURLOverrides(extension));
31 void ExtensionWebUIOverrideRegistrar::OnExtensionUnloaded(
32 content::BrowserContext* browser_context,
33 const Extension* extension,
34 UnloadedExtensionInfo::Reason reason) {
35 ExtensionWebUI::UnregisterChromeURLOverrides(
36 Profile::FromBrowserContext(browser_context),
37 URLOverrides::GetChromeURLOverrides(extension));
40 static base::LazyInstance<
41 BrowserContextKeyedAPIFactory<ExtensionWebUIOverrideRegistrar> > g_factory =
42 LAZY_INSTANCE_INITIALIZER;
44 // static
45 BrowserContextKeyedAPIFactory<ExtensionWebUIOverrideRegistrar>*
46 ExtensionWebUIOverrideRegistrar::GetFactoryInstance() {
47 return g_factory.Pointer();
50 } // namespace extensions