OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "chrome/browser/extensions/manifest_url_parser.h" | |
6 | |
7 #include "base/lazy_instance.h" | |
8 #include "chrome/browser/extensions/extension_web_ui.h" | |
9 #include "chrome/browser/profiles/profile.h" | |
10 #include "chrome/common/chrome_notification_types.h" | |
11 #include "chrome/common/extensions/manifest_url_handler.h" | |
12 #include "content/public/browser/notification_details.h" | |
13 #include "content/public/browser/notification_service.h" | |
14 | |
15 namespace extensions { | |
16 | |
17 ManifestURLParser::ManifestURLParser(Profile* profile) | |
18 : profile_(profile) { | |
19 (new DevToolsPageHandler)->Register(); | |
20 (new HomepageURLHandler)->Register(); | |
21 (new UpdateURLHandler)->Register(); | |
22 (new OptionsPageHandler)->Register(); | |
23 (new URLOverridesHandler)->Register(); | |
24 | |
25 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | |
26 content::Source<Profile>(profile)); | |
27 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | |
28 content::Source<Profile>(profile)); | |
29 } | |
30 | |
31 ManifestURLParser::~ManifestURLParser() { | |
32 } | |
33 | |
34 void ManifestURLParser::Observe(int type, | |
35 const content::NotificationSource& source, | |
36 const content::NotificationDetails& details) { | |
37 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { | |
38 const Extension* extension = | |
39 content::Details<const Extension>(details).ptr(); | |
40 ExtensionWebUI::RegisterChromeURLOverrides( | |
41 profile_, URLOverrides::GetChromeURLOverrides(extension)); | |
42 | |
43 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { | |
44 const Extension* extension = | |
45 content::Details<const UnloadedExtensionInfo>(details)->extension; | |
46 ExtensionWebUI::UnregisterChromeURLOverrides( | |
47 profile_, URLOverrides::GetChromeURLOverrides(extension)); | |
48 } | |
49 } | |
50 | |
51 static base::LazyInstance<ProfileKeyedAPIFactory<ManifestURLParser> > | |
52 g_factory = LAZY_INSTANCE_INITIALIZER; | |
53 | |
54 // static | |
55 ProfileKeyedAPIFactory<ManifestURLParser>* | |
56 ManifestURLParser::GetFactoryInstance() { | |
57 return &g_factory.Get(); | |
58 } | |
59 | |
60 } // namespace extensions | |
OLD | NEW |