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

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

Issue 11660016: Move the parsing of "chrome_url_overrides" out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch-rebased Created 7 years, 11 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
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/manifest_url_parser.h" 5 #include "chrome/browser/extensions/manifest_url_parser.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/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_notification_types.h"
9 #include "chrome/common/extensions/extension_manifest_constants.h" 11 #include "chrome/common/extensions/extension_manifest_constants.h"
10 #include "chrome/common/extensions/manifest_handler.h" 12 #include "chrome/common/extensions/manifest_handler.h"
11 #include "chrome/common/extensions/manifest_url_handler.h" 13 #include "chrome/common/extensions/manifest_url_handler.h"
14 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_service.h"
12 16
13 namespace extensions { 17 namespace extensions {
14 18
15 ManifestURLParser::ManifestURLParser(Profile* profile) { 19 ManifestURLParser::ManifestURLParser(Profile* profile)
20 : profile_(profile) {
16 ManifestHandler::Register(extension_manifest_keys::kDevToolsPage, 21 ManifestHandler::Register(extension_manifest_keys::kDevToolsPage,
17 new DevToolsPageHandler); 22 new DevToolsPageHandler);
18 ManifestHandler::Register(extension_manifest_keys::kHomepageURL, 23 ManifestHandler::Register(extension_manifest_keys::kHomepageURL,
19 new HomepageURLHandler); 24 new HomepageURLHandler);
25 ManifestHandler::Register(extension_manifest_keys::kChromeURLOverrides,
26 new URLOverridesHandler);
27
28 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
29 content::Source<Profile>(profile));
30 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
31 content::Source<Profile>(profile));
20 } 32 }
21 33
22 ManifestURLParser::~ManifestURLParser() { 34 ManifestURLParser::~ManifestURLParser() {
23 } 35 }
24 36
37 void ManifestURLParser::Observe(int type,
38 const content::NotificationSource& source,
39 const content::NotificationDetails& details) {
40 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
41 const Extension* extension =
42 content::Details<const Extension>(details).ptr();
43 ExtensionWebUI::RegisterChromeURLOverrides(
44 profile_, URLOverrides::GetChromeURLOverrides(extension));
45
46 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
47 const Extension* extension =
48 content::Details<const UnloadedExtensionInfo>(details)->extension;
49 ExtensionWebUI::UnregisterChromeURLOverrides(
50 profile_, URLOverrides::GetChromeURLOverrides(extension));
51 }
52 }
53
25 static base::LazyInstance<ProfileKeyedAPIFactory<ManifestURLParser> > 54 static base::LazyInstance<ProfileKeyedAPIFactory<ManifestURLParser> >
26 g_factory = LAZY_INSTANCE_INITIALIZER; 55 g_factory = LAZY_INSTANCE_INITIALIZER;
27 56
28 // static 57 // static
29 ProfileKeyedAPIFactory<ManifestURLParser>* 58 ProfileKeyedAPIFactory<ManifestURLParser>*
30 ManifestURLParser::GetFactoryInstance() { 59 ManifestURLParser::GetFactoryInstance() {
31 return &g_factory.Get(); 60 return &g_factory.Get();
32 } 61 }
33 62
34 } // namespace extensions 63 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/manifest_url_parser.h ('k') | chrome/browser/ui/webui/uber/uber_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698