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