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

Side by Side Diff: chrome/browser/extensions/extension_web_ui_override_registrar.cc

Issue 14694010: Consolidate manifest handler registration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/chrome_manifest_parser.h" 5 #include "chrome/browser/extensions/extension_web_ui_override_registrar.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "chrome/browser/extensions/extension_web_ui.h" 8 #include "chrome/browser/extensions/extension_web_ui.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
11 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
12 #include "chrome/common/extensions/manifest_handlers/icons_handler.h"
13 #include "chrome/common/extensions/manifest_handlers/kiosk_enabled_info.h"
14 #include "chrome/common/extensions/manifest_handlers/offline_enabled_info.h"
15 #include "chrome/common/extensions/manifest_handlers/requirements_handler.h"
16 #include "chrome/common/extensions/manifest_handlers/shared_module_info.h"
17 #include "chrome/common/extensions/manifest_url_handler.h"
18 #include "content/public/browser/notification_details.h" 11 #include "content/public/browser/notification_details.h"
19 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
20 13
21 namespace extensions { 14 namespace extensions {
22 15
23 ChromeManifestParser::ChromeManifestParser(Profile* profile) 16 ExtensionWebUIOverrideRegistrar::ExtensionWebUIOverrideRegistrar(
24 : profile_(profile) { 17 Profile* profile) : profile_(profile) {
25 (new AppIsolationHandler)->Register();
26 (new DevToolsPageHandler)->Register();
27 (new KioskEnabledHandler)->Register();
28 (new HomepageURLHandler)->Register();
29 (new IconsHandler)->Register();
30 (new OfflineEnabledHandler)->Register();
31 (new OptionsPageHandler)->Register();
32 (new RequirementsHandler)->Register();
33 (new SharedModuleHandler)->Register();
34 (new UpdateURLHandler)->Register();
35 (new URLOverridesHandler)->Register();
36
37 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 18 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
38 content::Source<Profile>(profile)); 19 content::Source<Profile>(profile));
39 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 20 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
40 content::Source<Profile>(profile)); 21 content::Source<Profile>(profile));
41 } 22 }
42 23
43 ChromeManifestParser::~ChromeManifestParser() { 24 ExtensionWebUIOverrideRegistrar::~ExtensionWebUIOverrideRegistrar() {
44 } 25 }
45 26
46 void ChromeManifestParser::Observe( 27 void ExtensionWebUIOverrideRegistrar::Observe(
47 int type, 28 int type,
48 const content::NotificationSource& source, 29 const content::NotificationSource& source,
49 const content::NotificationDetails& details) { 30 const content::NotificationDetails& details) {
50 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { 31 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
51 const Extension* extension = 32 const Extension* extension =
52 content::Details<const Extension>(details).ptr(); 33 content::Details<const Extension>(details).ptr();
53 ExtensionWebUI::RegisterChromeURLOverrides( 34 ExtensionWebUI::RegisterChromeURLOverrides(
54 profile_, URLOverrides::GetChromeURLOverrides(extension)); 35 profile_, URLOverrides::GetChromeURLOverrides(extension));
55 36
56 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { 37 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
57 const Extension* extension = 38 const Extension* extension =
58 content::Details<const UnloadedExtensionInfo>(details)->extension; 39 content::Details<const UnloadedExtensionInfo>(details)->extension;
59 ExtensionWebUI::UnregisterChromeURLOverrides( 40 ExtensionWebUI::UnregisterChromeURLOverrides(
60 profile_, URLOverrides::GetChromeURLOverrides(extension)); 41 profile_, URLOverrides::GetChromeURLOverrides(extension));
61 } 42 }
62 } 43 }
63 44
64 static base::LazyInstance<ProfileKeyedAPIFactory<ChromeManifestParser> > 45 static base::LazyInstance<
46 ProfileKeyedAPIFactory<ExtensionWebUIOverrideRegistrar> >
65 g_factory = LAZY_INSTANCE_INITIALIZER; 47 g_factory = LAZY_INSTANCE_INITIALIZER;
66 48
67 // static 49 // static
68 ProfileKeyedAPIFactory<ChromeManifestParser>* 50 ProfileKeyedAPIFactory<ExtensionWebUIOverrideRegistrar>*
69 ChromeManifestParser::GetFactoryInstance() { 51 ExtensionWebUIOverrideRegistrar::GetFactoryInstance() {
70 return &g_factory.Get(); 52 return &g_factory.Get();
71 } 53 }
72 54
73 } // namespace extensions 55 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_web_ui_override_registrar.h ('k') | chrome/browser/extensions/image_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698