summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-01 01:29:29 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-01 01:29:29 +0000
commit9367eabc44c192bd864c0be9ce0514aad4a2ae95 (patch)
tree7f3609bb4526f89591422a69b496ca930f7c12b2
parent94cc369eaa08ac1fa115a2e80fd81a7b160dd3fe (diff)
downloadchromium_src-9367eabc44c192bd864c0be9ce0514aad4a2ae95.zip
chromium_src-9367eabc44c192bd864c0be9ce0514aad4a2ae95.tar.gz
chromium_src-9367eabc44c192bd864c0be9ce0514aad4a2ae95.tar.bz2
Manifest handler for all keys background-related.
Changes the manifest handler registration interface to (new Handler)->Register() and requires handlers to declare what keys they parse in Keys(). Also fixes const correctness in Manifest::Get* and ManifestHandler. Based on https://codereview.chromium.org/12256031/. BUG=159265 TBR=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/12253022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185391 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc6
-rw-r--r--chrome/browser/background/background_application_list_model.cc3
-rw-r--r--chrome/browser/background/background_contents_service.cc23
-rw-r--r--chrome/browser/chrome_content_browser_client.cc7
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_handler.cc4
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_handler.h3
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_manifest_unittest.cc9
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_private_api.cc5
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_resource_throttle_unittest.cc10
-rw-r--r--chrome/browser/chromeos/extensions/file_handler_util.cc3
-rw-r--r--chrome/browser/extensions/api/alarms/alarms_api_unittest.cc3
-rw-r--r--chrome/browser/extensions/api/commands/command_service.cc4
-rw-r--r--chrome/browser/extensions/api/context_menus/context_menus_api.cc5
-rw-r--r--chrome/browser/extensions/api/developer_private/developer_private_api.cc15
-rw-r--r--chrome/browser/extensions/api/extension_action/extension_action_api.cc14
-rw-r--r--chrome/browser/extensions/api/file_handlers/file_handlers_api.cc4
-rw-r--r--chrome/browser/extensions/api/i18n/i18n_api.cc5
-rw-r--r--chrome/browser/extensions/api/icons/icons_api.cc3
-rw-r--r--chrome/browser/extensions/api/identity/identity_api.cc3
-rw-r--r--chrome/browser/extensions/api/identity/identity_apitest.cc8
-rw-r--r--chrome/browser/extensions/api/input_ime/input_ime_api.cc4
-rw-r--r--chrome/browser/extensions/api/messaging/extension_message_port.cc3
-rw-r--r--chrome/browser/extensions/api/messaging/message_service.cc3
-rw-r--r--chrome/browser/extensions/api/omnibox/omnibox_api.cc5
-rw-r--r--chrome/browser/extensions/api/page_launcher/page_launcher_api.cc5
-rw-r--r--chrome/browser/extensions/api/runtime/runtime_api.cc4
-rw-r--r--chrome/browser/extensions/api/themes/theme_api.cc7
-rw-r--r--chrome/browser/extensions/component_loader_unittest.cc3
-rw-r--r--chrome/browser/extensions/csp_parser.cc10
-rw-r--r--chrome/browser/extensions/event_router.cc10
-rw-r--r--chrome/browser/extensions/extension_browsertest.cc4
-rw-r--r--chrome/browser/extensions/extension_host.cc5
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc19
-rw-r--r--chrome/browser/extensions/extension_protocols.cc7
-rw-r--r--chrome/browser/extensions/extension_protocols_unittest.cc4
-rw-r--r--chrome/browser/extensions/extension_service.cc7
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc8
-rw-r--r--chrome/browser/extensions/image_loader_unittest.cc9
-rw-r--r--chrome/browser/extensions/lazy_background_task_queue.cc12
-rw-r--r--chrome/browser/extensions/manifest_url_parser.cc17
-rw-r--r--chrome/browser/extensions/menu_manager.cc5
-rw-r--r--chrome/browser/extensions/sandboxed_unpacker_unittest.cc7
-rw-r--r--chrome/browser/extensions/startup_helper.cc5
-rw-r--r--chrome/browser/extensions/updater/extension_updater_unittest.cc5
-rw-r--r--chrome/browser/extensions/web_accessible_resources_parser.cc5
-rw-r--r--chrome/browser/media_galleries/media_file_system_registry_unittest.cc4
-rw-r--r--chrome/browser/media_galleries/media_galleries_preferences_unittest.cc4
-rw-r--r--chrome/browser/speech/extension_api/tts_extension_api.cc4
-rw-r--r--chrome/browser/themes/browser_theme_pack_unittest.cc9
-rw-r--r--chrome/browser/ui/browser.cc3
-rw-r--r--chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller_unittest.mm4
-rw-r--r--chrome/browser/ui/webui/extensions/extension_settings_handler.cc13
-rw-r--r--chrome/chrome_common.gypi2
-rw-r--r--chrome/common/extensions/api/commands/commands_handler.cc6
-rw-r--r--chrome/common/extensions/api/commands/commands_handler.h6
-rw-r--r--chrome/common/extensions/api/commands/commands_manifest_unittest.cc5
-rw-r--r--chrome/common/extensions/api/extension_action/browser_action_handler.cc4
-rw-r--r--chrome/common/extensions/api/extension_action/browser_action_handler.h5
-rw-r--r--chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc4
-rw-r--r--chrome/common/extensions/api/extension_action/page_action_handler.cc7
-rw-r--r--chrome/common/extensions/api/extension_action/page_action_handler.h5
-rw-r--r--chrome/common/extensions/api/extension_action/page_action_manifest_unittest.cc38
-rw-r--r--chrome/common/extensions/api/extension_action/script_badge_handler.cc17
-rw-r--r--chrome/common/extensions/api/extension_action/script_badge_handler.h6
-rw-r--r--chrome/common/extensions/api/extension_action/script_badge_manifest_unittest.cc8
-rw-r--r--chrome/common/extensions/api/file_handlers/file_handlers_parser.cc24
-rw-r--r--chrome/common/extensions/api/file_handlers/file_handlers_parser.h5
-rw-r--r--chrome/common/extensions/api/i18n/default_locale_handler.cc4
-rw-r--r--chrome/common/extensions/api/i18n/default_locale_handler.h2
-rw-r--r--chrome/common/extensions/api/i18n/default_locale_manifest_unittest.cc4
-rw-r--r--chrome/common/extensions/api/icons/icons_handler.cc4
-rw-r--r--chrome/common/extensions/api/icons/icons_handler.h2
-rw-r--r--chrome/common/extensions/api/icons/icons_manifest_unittest.cc3
-rw-r--r--chrome/common/extensions/api/identity/extension_manifests_auth_unittest.cc4
-rw-r--r--chrome/common/extensions/api/identity/oauth2_manifest_handler.cc4
-rw-r--r--chrome/common/extensions/api/identity/oauth2_manifest_handler.h3
-rw-r--r--chrome/common/extensions/api/input_ime/input_components_handler.cc4
-rw-r--r--chrome/common/extensions/api/input_ime/input_components_handler.h5
-rw-r--r--chrome/common/extensions/api/omnibox/omnibox_handler.cc4
-rw-r--r--chrome/common/extensions/api/omnibox/omnibox_handler.h3
-rw-r--r--chrome/common/extensions/api/page_launcher/page_launcher_handler.cc4
-rw-r--r--chrome/common/extensions/api/page_launcher/page_launcher_handler.h3
-rw-r--r--chrome/common/extensions/api/speech/tts_engine_manifest_handler.cc4
-rw-r--r--chrome/common/extensions/api/speech/tts_engine_manifest_handler.h5
-rw-r--r--chrome/common/extensions/api/themes/theme_handler.cc4
-rw-r--r--chrome/common/extensions/api/themes/theme_handler.h2
-rw-r--r--chrome/common/extensions/background_info.cc255
-rw-r--r--chrome/common/extensions/background_info.h82
-rw-r--r--chrome/common/extensions/csp_handler.cc12
-rw-r--r--chrome/common/extensions/csp_handler.h4
-rw-r--r--chrome/common/extensions/extension.cc190
-rw-r--r--chrome/common/extensions/extension.h45
-rw-r--r--chrome/common/extensions/extension_file_util.cc17
-rw-r--r--chrome/common/extensions/extension_file_util_unittest.cc25
-rw-r--r--chrome/common/extensions/extension_unittest.cc10
-rw-r--r--chrome/common/extensions/manifest.cc24
-rw-r--r--chrome/common/extensions/manifest.h5
-rw-r--r--chrome/common/extensions/manifest_handler.cc27
-rw-r--r--chrome/common/extensions/manifest_handler.h26
-rw-r--r--chrome/common/extensions/manifest_handler_unittest.cc63
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc43
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_contentsecuritypolicy_unittest.cc8
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc5
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc9
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc17
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_offline_unittest.cc17
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc5
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc5
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc11
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc7
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_ui_unittest.cc11
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_update_unittest.cc5
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc5
-rw-r--r--chrome/common/extensions/manifest_unittest.cc2
-rw-r--r--chrome/common/extensions/manifest_url_handler.cc20
-rw-r--r--chrome/common/extensions/manifest_url_handler.h25
-rw-r--r--chrome/common/extensions/permissions/permission_set_unittest.cc66
-rw-r--r--chrome/common/extensions/unpacker_unittest.cc12
-rw-r--r--chrome/common/extensions/web_accessible_resources_handler.cc4
-rw-r--r--chrome/common/extensions/web_accessible_resources_handler.h5
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc25
-rw-r--r--chrome/renderer/extensions/dispatcher.cc7
-rw-r--r--chrome/renderer/extensions/event_bindings.cc33
-rw-r--r--chrome/utility/chrome_content_utility_client.cc27
124 files changed, 994 insertions, 726 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 66c4a3c..9261d38 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -117,6 +117,7 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/extensions/permissions/permission_set.h"
@@ -3676,8 +3677,9 @@ void TestingAutomationProvider::GetExtensionsInfo(DictionaryValue* args,
extension_value->SetString("name", extension->name());
extension_value->SetString("public_key", extension->public_key());
extension_value->SetString("description", extension->description());
- extension_value->SetString("background_url",
- extension->GetBackgroundURL().spec());
+ extension_value->SetString(
+ "background_url",
+ extensions::BackgroundInfo::GetBackgroundURL(extension).spec());
extension_value->SetString("options_url",
extensions::ManifestURL::GetOptionsPage(extension).spec());
extension_value->Set("host_permissions",
diff --git a/chrome/browser/background/background_application_list_model.cc b/chrome/browser/background/background_application_list_model.cc
index 9c5aad5..a039ece 100644
--- a/chrome/browser/background/background_application_list_model.cc
+++ b/chrome/browser/background/background_application_list_model.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/api/icons/icons_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_icon_set.h"
@@ -287,7 +288,7 @@ bool BackgroundApplicationListModel::IsBackgroundApp(
return true;
// Hosted apps with manifest-provided background pages are background apps.
- if (extension.has_background_page())
+ if (extensions::BackgroundInfo::HasBackgroundPage(&extension))
return true;
BackgroundContentsService* service =
diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc
index 883160b..8cd75d7 100644
--- a/chrome/browser/background/background_contents_service.cc
+++ b/chrome/browser/background/background_contents_service.cc
@@ -29,6 +29,7 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/icons/icons_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_icon_set.h"
@@ -42,6 +43,7 @@
using content::SiteInstance;
using content::WebContents;
+using extensions::BackgroundInfo;
using extensions::Extension;
using extensions::UnloadedExtensionInfo;
@@ -267,7 +269,7 @@ void BackgroundContentsService::Observe(
if (extension_service) {
const Extension* extension =
extension_service->GetExtensionById(UTF16ToUTF8(appid), false);
- if (extension && extension->has_background_page())
+ if (extension && BackgroundInfo::HasBackgroundPage(extension))
break;
}
RegisterBackgroundContents(bgcontents);
@@ -278,7 +280,7 @@ void BackgroundContentsService::Observe(
content::Details<const Extension>(details).ptr();
Profile* profile = content::Source<Profile>(source).ptr();
if (extension->is_hosted_app() &&
- extension->has_background_page()) {
+ BackgroundInfo::HasBackgroundPage(extension)) {
// If there is a background page specified in the manifest for a hosted
// app, then blow away registered urls in the pref.
ShutdownAssociatedBackgroundContents(ASCIIToUTF16(extension->id()));
@@ -289,8 +291,10 @@ void BackgroundContentsService::Observe(
// Now load the manifest-specified background page. If service isn't
// ready, then the background page will be loaded from the
// EXTENSIONS_READY callback.
- LoadBackgroundContents(profile, extension->GetBackgroundURL(),
- ASCIIToUTF16("background"), UTF8ToUTF16(extension->id()));
+ LoadBackgroundContents(profile,
+ BackgroundInfo::GetBackgroundURL(extension),
+ ASCIIToUTF16("background"),
+ UTF8ToUTF16(extension->id()));
}
}
@@ -349,7 +353,7 @@ void BackgroundContentsService::Observe(
// from the LOADED callback.
const Extension* extension =
content::Details<UnloadedExtensionInfo>(details)->extension;
- if (extension->has_background_page())
+ if (BackgroundInfo::HasBackgroundPage(extension))
ShutdownAssociatedBackgroundContents(ASCIIToUTF16(extension->id()));
break;
}
@@ -422,9 +426,9 @@ void BackgroundContentsService::LoadBackgroundContentsForExtension(
extensions::ExtensionSystem::Get(profile)->extension_service()->
GetExtensionById(extension_id, false);
DCHECK(!extension || extension->is_hosted_app());
- if (extension && extension->has_background_page()) {
+ if (extension && BackgroundInfo::HasBackgroundPage(extension)) {
LoadBackgroundContents(profile,
- extension->GetBackgroundURL(),
+ BackgroundInfo::GetBackgroundURL(extension),
ASCIIToUTF16("background"),
UTF8ToUTF16(extension->id()));
return;
@@ -470,9 +474,10 @@ void BackgroundContentsService::LoadBackgroundContentsFromManifests(
ExtensionSet::const_iterator iter = extensions->begin();
for (; iter != extensions->end(); ++iter) {
const Extension* extension = *iter;
- if (extension->is_hosted_app() && extension->has_background_page()) {
+ if (extension->is_hosted_app() &&
+ BackgroundInfo::HasBackgroundPage(extension)) {
LoadBackgroundContents(profile,
- extension->GetBackgroundURL(),
+ BackgroundInfo::GetBackgroundURL(extension),
ASCIIToUTF16("background"),
UTF8ToUTF16(extension->id()));
}
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 9677f91..df7068a 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -82,6 +82,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_process_policy.h"
#include "chrome/common/extensions/extension_set.h"
@@ -751,7 +752,7 @@ bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
// responsiveness.
if (extension->GetType() == Manifest::TYPE_HOSTED_APP) {
if (!extension->HasAPIPermission(APIPermission::kBackground) ||
- !extension->allow_background_js_access()) {
+ !extensions::BackgroundInfo::AllowJSAccess(extension)) {
return false;
}
}
@@ -875,7 +876,7 @@ bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost(
service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url));
if (!extension)
return false;
- if (!extension->has_background_page())
+ if (!extensions::BackgroundInfo::HasBackgroundPage(extension))
return false;
std::set<int> process_ids;
@@ -1644,7 +1645,7 @@ bool ChromeContentBrowserClient::CanCreateWindow(
// just the origin.
const Extension* extension = map->extensions().GetExtensionOrAppByURL(
ExtensionURLInfo(opener_url));
- if (extension && !extension->allow_background_js_access())
+ if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension))
*no_javascript_access = true;
}
return true;
diff --git a/chrome/browser/chromeos/extensions/file_browser_handler.cc b/chrome/browser/chromeos/extensions/file_browser_handler.cc
index 59b23bd..e314b8c 100644
--- a/chrome/browser/chromeos/extensions/file_browser_handler.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_handler.cc
@@ -354,3 +354,7 @@ bool FileBrowserHandlerParser::Parse(extensions::Extension* extension,
extension->SetManifestData(keys::kFileBrowserHandlers, info.release());
return true;
}
+
+const std::vector<std::string> FileBrowserHandlerParser::Keys() const {
+ return SingleKey(keys::kFileBrowserHandlers);
+}
diff --git a/chrome/browser/chromeos/extensions/file_browser_handler.h b/chrome/browser/chromeos/extensions/file_browser_handler.h
index 56913a9..c4aa5eb 100644
--- a/chrome/browser/chromeos/extensions/file_browser_handler.h
+++ b/chrome/browser/chromeos/extensions/file_browser_handler.h
@@ -118,6 +118,9 @@ class FileBrowserHandlerParser : public extensions::ManifestHandler {
virtual bool Parse(extensions::Extension* extension,
string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
};
#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_HANDLER_H_
diff --git a/chrome/browser/chromeos/extensions/file_browser_manifest_unittest.cc b/chrome/browser/chromeos/extensions/file_browser_manifest_unittest.cc
index b86e698..c39ede6 100644
--- a/chrome/browser/chromeos/extensions/file_browser_manifest_unittest.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_manifest_unittest.cc
@@ -6,7 +6,6 @@
#include "chrome/browser/chromeos/extensions/file_browser_handler.h"
#include "chrome/common/extensions/extension_builder.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/extensions/value_builder.h"
@@ -25,12 +24,8 @@ namespace {
class FileBrowserHandlerManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kFileBrowserHandlers,
- make_linked_ptr(new FileBrowserHandlerParser));
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kChromeURLOverrides,
- make_linked_ptr(new extensions::URLOverridesHandler));
+ (new FileBrowserHandlerParser)->Register();
+ (new extensions::URLOverridesHandler)->Register();
}
};
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
index 9a06b59..00a567b 100644
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
@@ -59,7 +59,6 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_icon_set.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/pref_names.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "content/public/browser/child_process_security_policy.h"
@@ -564,9 +563,7 @@ class RequestLocalFileSystemFunction::LocalFileSystemCallbackDispatcher {
FileBrowserPrivateAPI::FileBrowserPrivateAPI(Profile* profile)
: event_router_(make_scoped_refptr(new FileBrowserEventRouter(profile))) {
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kFileBrowserHandlers,
- make_linked_ptr(new FileBrowserHandlerParser));
+ (new FileBrowserHandlerParser)->Register();
ExtensionFunctionRegistry* registry =
ExtensionFunctionRegistry::GetInstance();
diff --git a/chrome/browser/chromeos/extensions/file_browser_resource_throttle_unittest.cc b/chrome/browser/chromeos/extensions/file_browser_resource_throttle_unittest.cc
index 66cb7f7..4c9ad63 100644
--- a/chrome/browser/chromeos/extensions/file_browser_resource_throttle_unittest.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_resource_throttle_unittest.cc
@@ -9,7 +9,6 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_builder.h"
#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/value_builder.h"
#include "content/public/browser/resource_controller.h"
@@ -66,10 +65,8 @@ class FileBrowserResourceThrottleTest : public testing::Test {
virtual ~FileBrowserResourceThrottleTest() {}
- virtual void SetUp() {
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kFileBrowserHandlers,
- make_linked_ptr(new FileBrowserHandlerParser));
+ virtual void SetUp() OVERRIDE {
+ (new FileBrowserHandlerParser)->Register();
// Extension info map must be created before |CreateAndInstallTestExtension|
// is called (the method will add created extension to the info map).
extension_info_map_ = new ExtensionInfoMap();
@@ -77,8 +74,9 @@ class FileBrowserResourceThrottleTest : public testing::Test {
InitResourceController();
}
- virtual void TearDown() {
+ virtual void TearDown() OVERRIDE {
FileBrowserHandler::set_extension_whitelisted_for_test(NULL);
+ extensions::ManifestHandler::ClearRegistryForTesting();
}
protected:
diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc
index bdfa722..f338c67 100644
--- a/chrome/browser/chromeos/extensions/file_handler_util.cc
+++ b/chrome/browser/chromeos/extensions/file_handler_util.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/host_desktop.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
@@ -820,7 +821,7 @@ bool ExtensionTaskExecutor::ExecuteAndNotify(
int handler_pid = ExtractProcessFromExtensionId(profile(), handler->id());
if (handler_pid <= 0) {
- if (!handler->has_lazy_background_page())
+ if (!extensions::BackgroundInfo::HasLazyBackgroundPage(handler))
return false;
}
diff --git a/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc b/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc
index fb3d8ed..60c367a 100644
--- a/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc
+++ b/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "content/public/browser/web_contents.h"
@@ -61,7 +62,7 @@ class ExtensionAlarmsTest : public BrowserWithTestWindowTest {
extensions::Manifest::UNPACKED);
// Make sure there's a RenderViewHost for alarms to warn into.
- AddTab(browser(), extension_->GetBackgroundURL());
+ AddTab(browser(), BackgroundInfo::GetBackgroundURL(extension_));
contents_ = browser()->tab_strip_model()->GetActiveWebContents();
test_clock_.SetNow(base::Time::FromDoubleT(10));
diff --git a/chrome/browser/extensions/api/commands/command_service.cc b/chrome/browser/extensions/api/commands/command_service.cc
index 84b40e4..cec171c 100644
--- a/chrome/browser/extensions/api/commands/command_service.cc
+++ b/chrome/browser/extensions/api/commands/command_service.cc
@@ -17,7 +17,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/api/commands/commands_handler.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
@@ -47,8 +46,7 @@ void CommandService::RegisterUserPrefs(PrefRegistrySyncable* registry) {
CommandService::CommandService(Profile* profile)
: profile_(profile) {
- ManifestHandler::Register(extension_manifest_keys::kCommands,
- make_linked_ptr(new CommandsHandler));
+ (new CommandsHandler)->Register();
ExtensionFunctionRegistry::GetInstance()->
RegisterFunction<GetAllCommandsFunction>();
diff --git a/chrome/browser/extensions/api/context_menus/context_menus_api.cc b/chrome/browser/extensions/api/context_menus/context_menus_api.cc
index b3cf3d7..fc02e28 100644
--- a/chrome/browser/extensions/api/context_menus/context_menus_api.cc
+++ b/chrome/browser/extensions/api/context_menus/context_menus_api.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/extensions/menu_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/context_menus.h"
+#include "chrome/common/extensions/background_info.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/url_pattern_set.h"
@@ -157,7 +158,7 @@ bool ContextMenusCreateFunction::RunImpl() {
if (params->create_properties.id.get()) {
id.string_uid = *params->create_properties.id;
} else {
- if (GetExtension()->has_lazy_background_page()) {
+ if (BackgroundInfo::HasLazyBackgroundPage(GetExtension())) {
error_ = kIdRequiredError;
return false;
}
@@ -181,7 +182,7 @@ bool ContextMenusCreateFunction::RunImpl() {
return false;
}
- if (GetExtension()->has_lazy_background_page() &&
+ if (BackgroundInfo::HasLazyBackgroundPage(GetExtension()) &&
params->create_properties.onclick.get()) {
error_ = kOnclickDisallowedError;
return false;
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
index 8f48d42..3d71e19 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/view_type_utils.h"
#include "chrome/common/extensions/api/developer_private.h"
#include "chrome/common/extensions/api/icons/icons_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_resource.h"
#include "chrome/common/extensions/manifest_url_handler.h"
@@ -302,10 +303,11 @@ ItemInspectViewList DeveloperPrivateGetItemsInfoFunction::
GetShellWindowPagesForExtensionProfile(extension, &result);
// Include a link to start the lazy background page, if applicable.
- if (extension->has_lazy_background_page() && extension_is_enabled &&
+ if (BackgroundInfo::HasLazyBackgroundPage(extension) &&
+ extension_is_enabled &&
!process_manager->GetBackgroundHostForExtension(extension->id())) {
- result.push_back(
- constructInspectView(extension->GetBackgroundURL(), -1, -1, false));
+ result.push_back(constructInspectView(
+ BackgroundInfo::GetBackgroundURL(extension), -1, -1, false));
}
ExtensionService* service = profile()->GetExtensionService();
@@ -319,10 +321,11 @@ ItemInspectViewList DeveloperPrivateGetItemsInfoFunction::
process_manager->GetRenderViewHostsForExtension(extension->id()),
&result);
- if (extension->has_lazy_background_page() && extension_is_enabled &&
+ if (BackgroundInfo::HasLazyBackgroundPage(extension) &&
+ extension_is_enabled &&
!process_manager->GetBackgroundHostForExtension(extension->id())) {
- result.push_back(
- constructInspectView(extension->GetBackgroundURL(), -1, -1, false));
+ result.push_back(constructInspectView(
+ BackgroundInfo::GetBackgroundURL(extension), -1, -1, false));
}
}
diff --git a/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
index a33e7cf..7acf586 100644
--- a/chrome/browser/extensions/api/extension_action/extension_action_api.cc
+++ b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
@@ -27,8 +27,6 @@
#include "chrome/common/extensions/api/extension_action/browser_action_handler.h"
#include "chrome/common/extensions/api/extension_action/page_action_handler.h"
#include "chrome/common/extensions/api/extension_action/script_badge_handler.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/render_messages.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
@@ -189,15 +187,9 @@ static base::LazyInstance<ProfileKeyedAPIFactory<ExtensionActionAPI> >
g_factory = LAZY_INSTANCE_INITIALIZER;
ExtensionActionAPI::ExtensionActionAPI(Profile* profile) {
- ManifestHandler::Register(extension_manifest_keys::kBrowserAction,
- make_linked_ptr(new BrowserActionHandler));
- linked_ptr<PageActionHandler> page_action_handler(new PageActionHandler);
- ManifestHandler::Register(
- extension_manifest_keys::kPageAction, page_action_handler);
- ManifestHandler::Register(
- extension_manifest_keys::kPageActions, page_action_handler);
- ManifestHandler::Register(extension_manifest_keys::kScriptBadge,
- make_linked_ptr(new ScriptBadgeHandler));
+ (new BrowserActionHandler)->Register();
+ (new PageActionHandler)->Register();
+ (new ScriptBadgeHandler)->Register();
ExtensionFunctionRegistry* registry =
ExtensionFunctionRegistry::GetInstance();
diff --git a/chrome/browser/extensions/api/file_handlers/file_handlers_api.cc b/chrome/browser/extensions/api/file_handlers/file_handlers_api.cc
index 81c212c..85e7758 100644
--- a/chrome/browser/extensions/api/file_handlers/file_handlers_api.cc
+++ b/chrome/browser/extensions/api/file_handlers/file_handlers_api.cc
@@ -6,13 +6,11 @@
#include "base/lazy_instance.h"
#include "chrome/common/extensions/api/file_handlers/file_handlers_parser.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
namespace extensions {
FileHandlersAPI::FileHandlersAPI(Profile* profile) {
- ManifestHandler::Register(extension_manifest_keys::kFileHandlers,
- make_linked_ptr(new FileHandlersParser));
+ (new FileHandlersParser)->Register();
}
FileHandlersAPI::~FileHandlersAPI() {
diff --git a/chrome/browser/extensions/api/i18n/i18n_api.cc b/chrome/browser/extensions/api/i18n/i18n_api.cc
index 554c304..165ec1f 100644
--- a/chrome/browser/extensions/api/i18n/i18n_api.cc
+++ b/chrome/browser/extensions/api/i18n/i18n_api.cc
@@ -15,8 +15,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/i18n.h"
#include "chrome/common/extensions/api/i18n/default_locale_handler.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/pref_names.h"
namespace GetAcceptLanguages = extensions::api::i18n::GetAcceptLanguages;
@@ -63,8 +61,7 @@ bool I18nGetAcceptLanguagesFunction::RunImpl() {
}
I18nAPI::I18nAPI(Profile* profile) {
- ManifestHandler::Register(extension_manifest_keys::kDefaultLocale,
- make_linked_ptr(new DefaultLocaleHandler));
+ (new DefaultLocaleHandler)->Register();
}
I18nAPI::~I18nAPI() {
diff --git a/chrome/browser/extensions/api/icons/icons_api.cc b/chrome/browser/extensions/api/icons/icons_api.cc
index e3b6c89..16d42fd 100644
--- a/chrome/browser/extensions/api/icons/icons_api.cc
+++ b/chrome/browser/extensions/api/icons/icons_api.cc
@@ -21,8 +21,7 @@ ProfileKeyedAPIFactory<IconsAPI>* IconsAPI::GetFactoryInstance() {
}
IconsAPI::IconsAPI(Profile* profile) {
- ManifestHandler::Register(extension_manifest_keys::kIcons,
- make_linked_ptr(new IconsHandler));
+ (new IconsHandler)->Register();
}
IconsAPI::~IconsAPI() {
diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc
index 6087ede0..72658a3 100644
--- a/chrome/browser/extensions/api/identity/identity_api.cc
+++ b/chrome/browser/extensions/api/identity/identity_api.cc
@@ -257,8 +257,7 @@ void IdentityLaunchWebAuthFlowFunction::OnAuthFlowFailure() {
}
IdentityAPI::IdentityAPI(Profile* profile) {
- ManifestHandler::Register(extension_manifest_keys::kOAuth2,
- make_linked_ptr(new OAuth2ManifestHandler));
+ (new OAuth2ManifestHandler)->Register();
}
IdentityAPI::~IdentityAPI() {
diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc
index 913aade..3a17641 100644
--- a/chrome/browser/extensions/api/identity/identity_apitest.cc
+++ b/chrome/browser/extensions/api/identity/identity_apitest.cc
@@ -16,8 +16,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
@@ -144,12 +142,6 @@ class MockGetAuthTokenFunction : public IdentityGetAuthTokenFunction {
};
class GetAuthTokenFunctionTest : public ExtensionBrowserTest {
- public:
- virtual void SetUp() OVERRIDE {
- ExtensionBrowserTest::SetUp();
- ManifestHandler::Register(extension_manifest_keys::kOAuth2,
- make_linked_ptr(new OAuth2ManifestHandler));
- }
protected:
enum OAuth2Fields {
NONE = 0,
diff --git a/chrome/browser/extensions/api/input_ime/input_ime_api.cc b/chrome/browser/extensions/api/input_ime/input_ime_api.cc
index 1ca4dc3..248442a 100644
--- a/chrome/browser/extensions/api/input_ime/input_ime_api.cc
+++ b/chrome/browser/extensions/api/input_ime/input_ime_api.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/extensions/extension_input_module_constants.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
namespace keys = extension_input_module_constants;
@@ -861,8 +860,7 @@ bool KeyEventHandled::RunImpl() {
InputImeAPI::InputImeAPI(Profile* profile)
: profile_(profile) {
- ManifestHandler::Register(extension_manifest_keys::kInputComponents,
- make_linked_ptr(new InputComponentsHandler));
+ (new InputComponentsHandler)->Register();
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(profile));
diff --git a/chrome/browser/extensions/api/messaging/extension_message_port.cc b/chrome/browser/extensions/api/messaging/extension_message_port.cc
index b0c4afc..ea66e46 100644
--- a/chrome/browser/extensions/api/messaging/extension_message_port.cc
+++ b/chrome/browser/extensions/api/messaging/extension_message_port.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension_messages.h"
#include "content/public/browser/render_process_host.h"
@@ -51,7 +52,7 @@ void ExtensionMessagePort::IncrementLazyKeepaliveCount() {
ExtensionProcessManager* pm =
ExtensionSystem::Get(profile)->process_manager();
ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_);
- if (host && host->extension()->has_lazy_background_page())
+ if (host && BackgroundInfo::HasLazyBackgroundPage(host->extension()))
pm->IncrementLazyKeepaliveCount(host->extension());
// Keep track of the background host, so when we decrement, we only do so if
diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc
index 36e141c..d531dac 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/view_type.h"
@@ -448,7 +449,7 @@ bool MessageService::MaybeAddPendingOpenChannelTask(
ExtensionService* service = profile->GetExtensionService();
const std::string& extension_id = params->target_extension_id;
const Extension* extension = service->extensions()->GetByID(extension_id);
- if (extension && extension->has_lazy_background_page()) {
+ if (extension && BackgroundInfo::HasLazyBackgroundPage(extension)) {
// If the extension uses spanning incognito mode, make sure we're always
// using the original profile since that is what the extension process
// will use.
diff --git a/chrome/browser/extensions/api/omnibox/omnibox_api.cc b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
index 55a6ee7..8ade2fa 100644
--- a/chrome/browser/extensions/api/omnibox/omnibox_api.cc
+++ b/chrome/browser/extensions/api/omnibox/omnibox_api.cc
@@ -22,8 +22,6 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/api/omnibox/omnibox_handler.h"
#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "ui/gfx/image/image.h"
@@ -131,8 +129,7 @@ void ExtensionOmniboxEventRouter::OnInputCancelled(
OmniboxAPI::OmniboxAPI(Profile* profile)
: profile_(profile),
url_service_(TemplateURLServiceFactory::GetForProfile(profile)) {
- ManifestHandler::Register(extension_manifest_keys::kOmnibox,
- make_linked_ptr(new OmniboxHandler));
+ (new OmniboxHandler)->Register();
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
diff --git a/chrome/browser/extensions/api/page_launcher/page_launcher_api.cc b/chrome/browser/extensions/api/page_launcher/page_launcher_api.cc
index e7c70c1..4fc8d82 100644
--- a/chrome/browser/extensions/api/page_launcher/page_launcher_api.cc
+++ b/chrome/browser/extensions/api/page_launcher/page_launcher_api.cc
@@ -10,8 +10,6 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/common/extensions/api/page_launcher.h"
#include "chrome/common/extensions/api/page_launcher/page_launcher_handler.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "googleurl/src/gurl.h"
namespace extensions {
@@ -20,8 +18,7 @@ static base::LazyInstance<ProfileKeyedAPIFactory<PageLauncherAPI> >
g_factory = LAZY_INSTANCE_INITIALIZER;
PageLauncherAPI::PageLauncherAPI(Profile* profile) {
- ManifestHandler::Register(extension_manifest_keys::kPageLauncher,
- make_linked_ptr(new PageLauncherHandler));
+ (new PageLauncherHandler)->Register();
}
PageLauncherAPI::~PageLauncherAPI() {
diff --git a/chrome/browser/extensions/api/runtime/runtime_api.cc b/chrome/browser/extensions/api/runtime/runtime_api.cc
index 328ef22..1349fb2 100644
--- a/chrome/browser/extensions/api/runtime/runtime_api.cc
+++ b/chrome/browser/extensions/api/runtime/runtime_api.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "googleurl/src/gurl.h"
@@ -60,7 +61,8 @@ static void DispatchOnStartupEventImpl(
// If it fails to load the first time, don't bother trying again.
const Extension* extension =
system->extension_service()->extensions()->GetByID(extension_id);
- if (extension && extension->has_persistent_background_page() && first_call &&
+ if (extension && BackgroundInfo::HasPersistentBackgroundPage(extension) &&
+ first_call &&
system->lazy_background_task_queue()->
ShouldEnqueueTask(profile, extension)) {
system->lazy_background_task_queue()->AddPendingTask(
diff --git a/chrome/browser/extensions/api/themes/theme_api.cc b/chrome/browser/extensions/api/themes/theme_api.cc
index 51e4099..a527536 100644
--- a/chrome/browser/extensions/api/themes/theme_api.cc
+++ b/chrome/browser/extensions/api/themes/theme_api.cc
@@ -6,16 +6,11 @@
#include "base/lazy_instance.h"
#include "chrome/common/extensions/api/themes/theme_handler.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
namespace extensions {
ThemeAPI::ThemeAPI(Profile* profile) {
- // Register the ManifestHandler for parsing 'theme' manifest key.
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kTheme,
- make_linked_ptr(new extensions::ThemeHandler));
+ (new extensions::ThemeHandler)->Register();
}
ThemeAPI::~ThemeAPI() {
diff --git a/chrome/browser/extensions/component_loader_unittest.cc b/chrome/browser/extensions/component_loader_unittest.cc
index 7cd8271..f3de989 100644
--- a/chrome/browser/extensions/component_loader_unittest.cc
+++ b/chrome/browser/extensions/component_loader_unittest.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/extensions/test_extension_service.h"
#include "chrome/browser/prefs/pref_registry_syncable.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/pref_names.h"
@@ -81,6 +82,8 @@ class ComponentLoaderTest : public testing::Test {
}
virtual void SetUp() {
+ (new BackgroundManifestHandler)->Register();
+
extension_path_ =
GetBasePath().AppendASCII("good")
.AppendASCII("Extensions")
diff --git a/chrome/browser/extensions/csp_parser.cc b/chrome/browser/extensions/csp_parser.cc
index ff72325..2c1dfc85 100644
--- a/chrome/browser/extensions/csp_parser.cc
+++ b/chrome/browser/extensions/csp_parser.cc
@@ -7,18 +7,12 @@
#include "base/lazy_instance.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/csp_handler.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
namespace extensions {
CSPParser::CSPParser(Profile* profile) {
- ManifestHandler::Register(
- extension_manifest_keys::kContentSecurityPolicy,
- make_linked_ptr(new CSPHandler(false))); // not platform app.
- ManifestHandler::Register(
- extension_manifest_keys::kPlatformAppContentSecurityPolicy,
- make_linked_ptr(new CSPHandler(true))); // platform app.
+ (new CSPHandler(false))->Register(); // platform app.
+ (new CSPHandler(true))->Register(); // platform app.
}
CSPParser::~CSPParser() {
diff --git a/chrome/browser/extensions/event_router.cc b/chrome/browser/extensions/event_router.cc
index df5b2f7..c24342b 100644
--- a/chrome/browser/extensions/event_router.cc
+++ b/chrome/browser/extensions/event_router.cc
@@ -30,6 +30,7 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/extension_api.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/view_type.h"
@@ -557,7 +558,7 @@ void EventRouter::IncrementInFlightEvents(Profile* profile,
const Extension* extension) {
// Only increment in-flight events if the lazy background page is active,
// because that's the only time we'll get an ACK.
- if (extension->has_lazy_background_page()) {
+ if (BackgroundInfo::HasLazyBackgroundPage(extension)) {
ExtensionProcessManager* pm =
ExtensionSystem::Get(profile)->process_manager();
ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id());
@@ -575,8 +576,9 @@ void EventRouter::OnEventAck(Profile* profile,
// NULL.
CHECK(host);
// TODO(mpcomplete): We should never get this message unless
- // has_lazy_background_page is true. Find out why we're getting it anyway.
- if (host->extension() && host->extension()->has_lazy_background_page())
+ // HasLazyBackgroundPage is true. Find out why we're getting it anyway.
+ if (host->extension() &&
+ BackgroundInfo::HasLazyBackgroundPage(host->extension()))
pm->DecrementLazyKeepaliveCount(host->extension());
}
@@ -614,7 +616,7 @@ void EventRouter::Observe(int type,
// to register the events the extension is interested in.
const Extension* extension =
content::Details<const Extension>(details).ptr();
- if (extension->has_lazy_background_page()) {
+ if (BackgroundInfo::HasLazyBackgroundPage(extension)) {
LazyBackgroundTaskQueue* queue =
ExtensionSystem::Get(profile_)->lazy_background_task_queue();
queue->AddPendingTask(profile_, extension->id(),
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index b02437b..dee9968 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -36,7 +36,6 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
-#include "chrome/common/extensions/api/icons/icons_handler.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/extensions/manifest_handler.h"
@@ -112,9 +111,6 @@ void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) {
void ExtensionBrowserTest::SetUpOnMainThread() {
InProcessBrowserTest::SetUpOnMainThread();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kIcons,
- make_linked_ptr(new extensions::IconsHandler));
}
const Extension* ExtensionBrowserTest::LoadExtensionWithFlags(
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 334054f..5c678ad 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -32,6 +32,7 @@
#include "chrome/browser/view_type_utils.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_messages.h"
@@ -158,7 +159,7 @@ ExtensionHost::ExtensionHost(const Extension* extension,
ExtensionHost::~ExtensionHost() {
if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE &&
- extension_ && extension_->has_lazy_background_page()) {
+ extension_ && BackgroundInfo::HasLazyBackgroundPage(extension_)) {
UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageActiveTime",
since_created_.Elapsed());
}
@@ -351,7 +352,7 @@ void ExtensionHost::DidStopLoading(content::RenderViewHost* render_view_host) {
}
if (notify) {
if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
- if (extension_ && extension_->has_lazy_background_page()) {
+ if (extension_ && BackgroundInfo::HasLazyBackgroundPage(extension_)) {
UMA_HISTOGRAM_TIMES("Extensions.EventPageLoadTime",
since_created_.Elapsed());
} else {
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 7aee97d..0a7a7a3 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -25,8 +25,10 @@
#include "chrome/browser/view_type_utils.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
@@ -48,6 +50,8 @@ using content::Referrer;
using content::RenderViewHost;
using content::SiteInstance;
using content::WebContents;
+using extensions::BackgroundInfo;
+using extensions::BackgroundManifestHandler;
using extensions::Extension;
using extensions::ExtensionHost;
@@ -92,8 +96,9 @@ class IncognitoExtensionProcessManager : public ExtensionProcessManager {
static void CreateBackgroundHostForExtensionLoad(
ExtensionProcessManager* manager, const Extension* extension) {
- if (extension->has_persistent_background_page())
- manager->CreateBackgroundHost(extension, extension->GetBackgroundURL());
+ if (BackgroundInfo::HasPersistentBackgroundPage(extension))
+ manager->CreateBackgroundHost(extension,
+ BackgroundInfo::GetBackgroundURL(extension));
}
static void CreateBackgroundHostsForProfileStartup(
@@ -185,6 +190,8 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
event_page_suspending_time_ = base::TimeDelta::FromSeconds(
suspending_time_sec);
}
+
+ (new BackgroundManifestHandler())->Register();
}
ExtensionProcessManager::~ExtensionProcessManager() {
@@ -427,7 +434,7 @@ bool ExtensionProcessManager::IsBackgroundHostClosing(
}
int ExtensionProcessManager::GetLazyKeepaliveCount(const Extension* extension) {
- if (!extension->has_lazy_background_page())
+ if (!BackgroundInfo::HasLazyBackgroundPage(extension))
return 0;
return background_page_data_[extension->id()].lazy_keepalive_count;
@@ -435,7 +442,7 @@ int ExtensionProcessManager::GetLazyKeepaliveCount(const Extension* extension) {
int ExtensionProcessManager::IncrementLazyKeepaliveCount(
const Extension* extension) {
- if (!extension->has_lazy_background_page())
+ if (!BackgroundInfo::HasLazyBackgroundPage(extension))
return 0;
int& count = background_page_data_[extension->id()].lazy_keepalive_count;
@@ -447,7 +454,7 @@ int ExtensionProcessManager::IncrementLazyKeepaliveCount(
int ExtensionProcessManager::DecrementLazyKeepaliveCount(
const Extension* extension) {
- if (!extension->has_lazy_background_page())
+ if (!BackgroundInfo::HasLazyBackgroundPage(extension))
return 0;
int& count = background_page_data_[extension->id()].lazy_keepalive_count;
@@ -720,7 +727,7 @@ void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host,
if (is_background) {
background_hosts_.insert(host);
- if (host->extension()->has_lazy_background_page()) {
+ if (BackgroundInfo::HasLazyBackgroundPage(host->extension())) {
linked_ptr<PerfTimer> since_suspended(
background_page_data_[host->extension()->id()].
since_suspended.release());
diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc
index 0129074..4072d39 100644
--- a/chrome/browser/extensions/extension_protocols.cc
+++ b/chrome/browser/extensions/extension_protocols.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/api/icons/icons_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_file_util.h"
#include "chrome/common/extensions/extension_resource.h"
@@ -170,9 +171,11 @@ class GeneratedBackgroundPageJob : public net::URLRequestSimpleJob {
*charset = "utf-8";
*data = "<!DOCTYPE html>\n<body>\n";
- for (size_t i = 0; i < extension_->background_scripts().size(); ++i) {
+ const std::vector<std::string>& background_scripts =
+ extensions::BackgroundInfo::GetBackgroundScripts(extension_);
+ for (size_t i = 0; i < background_scripts.size(); ++i) {
*data += "<script src=\"";
- *data += extension_->background_scripts()[i];
+ *data += background_scripts[i];
*data += "\"></script>\n";
}
diff --git a/chrome/browser/extensions/extension_protocols_unittest.cc b/chrome/browser/extensions/extension_protocols_unittest.cc
index a8274f9..48fffb6 100644
--- a/chrome/browser/extensions/extension_protocols_unittest.cc
+++ b/chrome/browser/extensions/extension_protocols_unittest.cc
@@ -76,14 +76,14 @@ class ExtensionProtocolTest : public testing::Test {
resource_context_.GetRequestContext();
old_factory_ = request_context->job_factory();
- ManifestHandler::Register(extension_manifest_keys::kIcons,
- make_linked_ptr(new IconsHandler));
+ (new IconsHandler)->Register();
}
virtual void TearDown() {
net::URLRequestContext* request_context =
resource_context_.GetRequestContext();
request_context->set_job_factory(old_factory_);
+ ManifestHandler::ClearRegistryForTesting();
}
void SetProtocolHandler(bool incognito) {
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index c333ae1..301bcd7 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -79,6 +79,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_file_util.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
@@ -2787,7 +2788,7 @@ ExtensionIdSet ExtensionService::GetAppIds() const {
}
bool ExtensionService::IsBackgroundPageReady(const Extension* extension) const {
- if (!extension->has_persistent_background_page())
+ if (!extensions::BackgroundInfo::HasPersistentBackgroundPage(extension))
return true;
ExtensionRuntimeDataMap::const_iterator it =
extension_runtime_data_.find(extension->id());
@@ -2796,7 +2797,7 @@ bool ExtensionService::IsBackgroundPageReady(const Extension* extension) const {
}
void ExtensionService::SetBackgroundPageReady(const Extension* extension) {
- DCHECK(extension->has_background_page());
+ DCHECK(extensions::BackgroundInfo::HasBackgroundPage(extension));
extension_runtime_data_[extension->id()].background_page_ready = true;
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY,
@@ -3028,7 +3029,7 @@ bool ExtensionService::ShouldDelayExtensionUpdate(
if (!old)
return false;
- if (old->has_persistent_background_page()) {
+ if (extensions::BackgroundInfo::HasPersistentBackgroundPage(old)) {
// Delay installation if the extension listens for the onUpdateAvailable
// event.
return system_->event_router()->ExtensionHasEventListener(
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index fe89f3f..14f169b 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -65,6 +65,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/i18n/default_locale_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_l10n_util.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
@@ -545,9 +546,8 @@ void ExtensionServiceTestBase::SetUpTestCase() {
void ExtensionServiceTestBase::SetUp() {
testing::Test::SetUp();
ExtensionErrorReporter::GetInstance()->ClearErrors();
- extensions::ManifestHandler::Register(
- keys::kDefaultLocale,
- make_linked_ptr(new extensions::DefaultLocaleHandler));
+ (new extensions::BackgroundManifestHandler)->Register();
+ (new extensions::DefaultLocaleHandler)->Register();
}
void ExtensionServiceTestBase::TearDown() {
@@ -1191,7 +1191,7 @@ TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectorySuccess) {
EXPECT_EQ(std::string("My extension 2"), loaded_[1]->name());
EXPECT_EQ(std::string(""), loaded_[1]->description());
EXPECT_EQ(loaded_[1]->GetResourceURL("background.html"),
- loaded_[1]->GetBackgroundURL());
+ extensions::BackgroundInfo::GetBackgroundURL(loaded_[1]));
EXPECT_EQ(0u, loaded_[1]->content_scripts().size());
// We don't parse the plugins section on Chrome OS.
#if defined(OS_CHROMEOS)
diff --git a/chrome/browser/extensions/image_loader_unittest.cc b/chrome/browser/extensions/image_loader_unittest.cc
index 002c5bb..fcb846a 100644
--- a/chrome/browser/extensions/image_loader_unittest.cc
+++ b/chrome/browser/extensions/image_loader_unittest.cc
@@ -13,7 +13,6 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_icon_set.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/extension_resource.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/manifest_handler.h"
@@ -100,14 +99,16 @@ class ImageLoaderTest : public testing::Test {
private:
virtual void SetUp() OVERRIDE {
testing::Test::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kIcons,
- make_linked_ptr(new extensions::IconsHandler));
+ (new extensions::IconsHandler)->Register();
file_thread_.Start();
io_thread_.Start();
}
+ virtual void TearDown() OVERRIDE {
+ extensions::ManifestHandler::ClearRegistryForTesting();
+ }
+
int image_loaded_count_;
bool quit_in_image_loaded_;
MessageLoop ui_loop_;
diff --git a/chrome/browser/extensions/lazy_background_task_queue.cc b/chrome/browser/extensions/lazy_background_task_queue.cc
index b5ae6b0..da9054a 100644
--- a/chrome/browser/extensions/lazy_background_task_queue.cc
+++ b/chrome/browser/extensions/lazy_background_task_queue.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/view_type.h"
@@ -41,7 +42,7 @@ LazyBackgroundTaskQueue::~LazyBackgroundTaskQueue() {
bool LazyBackgroundTaskQueue::ShouldEnqueueTask(
Profile* profile, const Extension* extension) {
DCHECK(extension);
- if (extension->has_background_page()) {
+ if (BackgroundInfo::HasBackgroundPage(extension)) {
ExtensionProcessManager* pm = extensions::ExtensionSystem::Get(profile)->
process_manager();
ExtensionHost* background_host =
@@ -69,13 +70,14 @@ void LazyBackgroundTaskQueue::AddPendingTask(
const Extension* extension =
ExtensionSystem::Get(profile)->extension_service()->
extensions()->GetByID(extension_id);
- if (extension && extension->has_lazy_background_page()) {
+ if (extension && BackgroundInfo::HasLazyBackgroundPage(extension)) {
// If this is the first enqueued task, and we're not waiting for the
// background page to unload, ensure the background page is loaded.
ExtensionProcessManager* pm =
ExtensionSystem::Get(profile)->process_manager();
pm->IncrementLazyKeepaliveCount(extension);
- pm->CreateBackgroundHost(extension, extension->GetBackgroundURL());
+ pm->CreateBackgroundHost(extension,
+ BackgroundInfo::GetBackgroundURL(extension));
}
} else {
tasks_list = it->second.get();
@@ -94,7 +96,7 @@ void LazyBackgroundTaskQueue::ProcessPendingTasks(
PendingTasksKey key(profile, extension->id());
PendingTasksMap::iterator map_it = pending_tasks_.find(key);
if (map_it == pending_tasks_.end()) {
- if (extension->has_lazy_background_page())
+ if (BackgroundInfo::HasLazyBackgroundPage(extension))
CHECK(!host); // lazy page should not load without any pending tasks
return;
}
@@ -112,7 +114,7 @@ void LazyBackgroundTaskQueue::ProcessPendingTasks(
// Balance the keepalive in AddPendingTask. Note we don't do this on a
// failure to load, because the keepalive count is reset in that case.
- if (host && extension->has_lazy_background_page()) {
+ if (host && BackgroundInfo::HasLazyBackgroundPage(extension)) {
ExtensionSystem::Get(profile)->process_manager()->
DecrementLazyKeepaliveCount(extension);
}
diff --git a/chrome/browser/extensions/manifest_url_parser.cc b/chrome/browser/extensions/manifest_url_parser.cc
index 927db07..6079d74 100644
--- a/chrome/browser/extensions/manifest_url_parser.cc
+++ b/chrome/browser/extensions/manifest_url_parser.cc
@@ -8,8 +8,6 @@
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
@@ -18,16 +16,11 @@ namespace extensions {
ManifestURLParser::ManifestURLParser(Profile* profile)
: profile_(profile) {
- ManifestHandler::Register(extension_manifest_keys::kDevToolsPage,
- make_linked_ptr(new DevToolsPageHandler));
- ManifestHandler::Register(extension_manifest_keys::kHomepageURL,
- make_linked_ptr(new HomepageURLHandler));
- ManifestHandler::Register(extension_manifest_keys::kUpdateURL,
- make_linked_ptr(new UpdateURLHandler));
- ManifestHandler::Register(extension_manifest_keys::kOptionsPage,
- make_linked_ptr(new OptionsPageHandler));
- ManifestHandler::Register(extension_manifest_keys::kChromeURLOverrides,
- make_linked_ptr(new URLOverridesHandler));
+ (new DevToolsPageHandler)->Register();
+ (new HomepageURLHandler)->Register();
+ (new UpdateURLHandler)->Register();
+ (new OptionsPageHandler)->Register();
+ (new URLOverridesHandler)->Register();
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(profile));
diff --git a/chrome/browser/extensions/menu_manager.cc b/chrome/browser/extensions/menu_manager.cc
index ed423e4..0335866 100644
--- a/chrome/browser/extensions/menu_manager.cc
+++ b/chrome/browser/extensions/menu_manager.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/extensions/state_store.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
@@ -746,7 +747,7 @@ bool MenuManager::ItemUpdated(const MenuItem::Id& id) {
}
void MenuManager::WriteToStorage(const Extension* extension) {
- if (!extension->has_lazy_background_page())
+ if (!BackgroundInfo::HasLazyBackgroundPage(extension))
return;
const MenuItem::List* top_items = MenuItems(extension->id());
MenuItem::List all_items;
@@ -801,7 +802,7 @@ void MenuManager::Observe(int type,
const Extension* extension =
content::Details<const Extension>(details).ptr();
StateStore* store = ExtensionSystem::Get(profile_)->state_store();
- if (store && extension->has_lazy_background_page()) {
+ if (store && BackgroundInfo::HasLazyBackgroundPage(extension)) {
store->GetExtensionValue(extension->id(), kContextMenusKey,
base::Bind(&MenuManager::ReadFromStorage,
AsWeakPtr(), extension->id()));
diff --git a/chrome/browser/extensions/sandboxed_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_unpacker_unittest.cc
index 1f5cb1b..a0c73b5 100644
--- a/chrome/browser/extensions/sandboxed_unpacker_unittest.cc
+++ b/chrome/browser/extensions/sandboxed_unpacker_unittest.cc
@@ -13,7 +13,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/api/i18n/default_locale_handler.h"
#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/unpacker.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -67,9 +67,7 @@ class SandboxedUnpackerTest : public testing::Test {
// It will delete itself.
client_ = new MockSandboxedUnpackerClient;
client_->DelegateToFake();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kDefaultLocale,
- make_linked_ptr(new extensions::DefaultLocaleHandler));
+ (new extensions::DefaultLocaleHandler)->Register();
}
virtual void TearDown() {
@@ -77,6 +75,7 @@ class SandboxedUnpackerTest : public testing::Test {
// it posts a task to it.
sandboxed_unpacker_ = NULL;
loop_.RunUntilIdle();
+ ManifestHandler::ClearRegistryForTesting();
}
void SetupUnpacker(const std::string& crx_name) {
diff --git a/chrome/browser/extensions/startup_helper.cc b/chrome/browser/extensions/startup_helper.cc
index f815502..a0add61 100644
--- a/chrome/browser/extensions/startup_helper.cc
+++ b/chrome/browser/extensions/startup_helper.cc
@@ -16,8 +16,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/i18n/default_locale_handler.h"
#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "content/public/browser/web_contents.h"
#include "ipc/ipc_message.h"
@@ -32,8 +30,7 @@ void PrintPackExtensionMessage(const std::string& message) {
namespace extensions {
StartupHelper::StartupHelper() : pack_job_succeeded_(false) {
- ManifestHandler::Register(extension_manifest_keys::kDefaultLocale,
- make_linked_ptr(new DefaultLocaleHandler));
+ (new DefaultLocaleHandler)->Register();
}
void StartupHelper::OnPackSuccess(
diff --git a/chrome/browser/extensions/updater/extension_updater_unittest.cc b/chrome/browser/extensions/updater/extension_updater_unittest.cc
index 756a492..1bd8576 100644
--- a/chrome/browser/extensions/updater/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc
@@ -458,9 +458,7 @@ class ExtensionUpdaterTest : public testing::Test {
virtual void SetUp() OVERRIDE {
prefs_.reset(new TestExtensionPrefs(loop_.message_loop_proxy()));
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kUpdateURL,
- make_linked_ptr(new extensions::UpdateURLHandler));
+ (new extensions::UpdateURLHandler)->Register();
}
virtual void TearDown() OVERRIDE {
@@ -469,6 +467,7 @@ class ExtensionUpdaterTest : public testing::Test {
// those objects are released.
RunUntilIdle();
prefs_.reset();
+ ManifestHandler::ClearRegistryForTesting();
}
void RunUntilIdle() {
diff --git a/chrome/browser/extensions/web_accessible_resources_parser.cc b/chrome/browser/extensions/web_accessible_resources_parser.cc
index ad5d757..63f00a4 100644
--- a/chrome/browser/extensions/web_accessible_resources_parser.cc
+++ b/chrome/browser/extensions/web_accessible_resources_parser.cc
@@ -6,15 +6,12 @@
#include "base/lazy_instance.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/web_accessible_resources_handler.h"
namespace extensions {
WebAccessibleResourcesParser::WebAccessibleResourcesParser(Profile* profile) {
- ManifestHandler::Register(extension_manifest_keys::kWebAccessibleResources,
- make_linked_ptr(new WebAccessibleResourcesHandler));
+ (new WebAccessibleResourcesHandler)->Register();
}
WebAccessibleResourcesParser::~WebAccessibleResourcesParser() {
diff --git a/chrome/browser/media_galleries/media_file_system_registry_unittest.cc b/chrome/browser/media_galleries/media_file_system_registry_unittest.cc
index 2bbe23d..ec08062 100644
--- a/chrome/browser/media_galleries/media_file_system_registry_unittest.cc
+++ b/chrome/browser/media_galleries/media_file_system_registry_unittest.cc
@@ -31,7 +31,9 @@
#include "chrome/browser/storage_monitor/removable_device_constants.h"
#include "chrome/browser/storage_monitor/storage_monitor.h"
#include "chrome/browser/storage_monitor/test_storage_monitor.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
@@ -789,6 +791,7 @@ void MediaFileSystemRegistryTest::SetUp() {
TestMediaStorageUtil::SetTestingMode();
test_file_system_context_ = new TestMediaFileSystemContext(
g_browser_process->media_file_system_registry());
+ (new extensions::BackgroundManifestHandler)->Register();
ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir());
empty_dir_ = galleries_dir_.path().AppendASCII("empty");
@@ -806,6 +809,7 @@ void MediaFileSystemRegistryTest::TearDown() {
EXPECT_EQ(0U, registry->GetExtensionGalleriesHostCountForTests());
BrowserThread::GetBlockingPool()->FlushForTesting();
MessageLoop::current()->RunUntilIdle();
+ extensions::ManifestHandler::ClearRegistryForTesting();
}
///////////
diff --git a/chrome/browser/media_galleries/media_galleries_preferences_unittest.cc b/chrome/browser/media_galleries/media_galleries_preferences_unittest.cc
index 4fca507..93198ec 100644
--- a/chrome/browser/media_galleries/media_galleries_preferences_unittest.cc
+++ b/chrome/browser/media_galleries/media_galleries_preferences_unittest.cc
@@ -18,7 +18,9 @@
#include "chrome/browser/media_galleries/media_file_system_registry.h"
#include "chrome/browser/media_galleries/media_galleries_test_util.h"
#include "chrome/browser/storage_monitor/media_storage_util.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread.h"
#include "sync/api/string_ordinal.h"
@@ -101,6 +103,7 @@ class MediaGalleriesPreferencesTest : public testing::Test {
extensions::ExtensionSystem::Get(profile_.get())));
extension_system->CreateExtensionService(
CommandLine::ForCurrentProcess(), base::FilePath(), false);
+ (new extensions::BackgroundManifestHandler)->Register();
gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get()));
@@ -134,6 +137,7 @@ class MediaGalleriesPreferencesTest : public testing::Test {
virtual void TearDown() OVERRIDE {
Verify();
+ extensions::ManifestHandler::ClearRegistryForTesting();
}
void Verify() {
diff --git a/chrome/browser/speech/extension_api/tts_extension_api.cc b/chrome/browser/speech/extension_api/tts_extension_api.cc
index 7a9ab7a..96ca3e1 100644
--- a/chrome/browser/speech/extension_api/tts_extension_api.cc
+++ b/chrome/browser/speech/extension_api/tts_extension_api.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/speech/extension_api/tts_extension_api_constants.h"
#include "chrome/browser/speech/tts_controller.h"
#include "chrome/common/extensions/api/speech/tts_engine_manifest_handler.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
#include "ui/base/l10n/l10n_util.h"
namespace constants = tts_extension_api_constants;
@@ -186,8 +185,7 @@ TtsAPI* TtsAPI::Get(Profile* profile) {
}
TtsAPI::TtsAPI(Profile* profile) {
- ManifestHandler::Register(extension_manifest_keys::kTtsEngine,
- make_linked_ptr(new TtsEngineManifestHandler));
+ (new TtsEngineManifestHandler)->Register();
ExtensionFunctionRegistry* registry =
ExtensionFunctionRegistry::GetInstance();
registry->RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>();
diff --git a/chrome/browser/themes/browser_theme_pack_unittest.cc b/chrome/browser/themes/browser_theme_pack_unittest.cc
index 3c1df2a..07c3eb3 100644
--- a/chrome/browser/themes/browser_theme_pack_unittest.cc
+++ b/chrome/browser/themes/browser_theme_pack_unittest.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/api/themes/theme_handler.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/manifest_handler.h"
#include "content/public/test/test_browser_thread.h"
#include "grit/theme_resources.h"
@@ -35,9 +34,11 @@ class BrowserThemePackTest : public ::testing::Test {
virtual void SetUp() OVERRIDE {
testing::Test::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kTheme,
- make_linked_ptr(new extensions::ThemeHandler));
+ (new extensions::ThemeHandler)->Register();
+ }
+
+ virtual void TearDown() OVERRIDE {
+ extensions::ManifestHandler::ClearRegistryForTesting();
}
// Transformation for link underline colors.
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 16f0a2d..37a03a6 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -142,6 +142,7 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/custom_handlers/protocol_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
@@ -2231,7 +2232,7 @@ bool Browser::MaybeCreateBackgroundContents(int route_id,
}
// Only allow a single background contents per app.
- bool allow_js_access = extension->allow_background_js_access();
+ bool allow_js_access = extensions::BackgroundInfo::AllowJSAccess(extension);
BackgroundContents* existing =
service->GetAppBackgroundContents(ASCIIToUTF16(extension->id()));
if (existing) {
diff --git a/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller_unittest.mm
index add2bc7..f084e28 100644
--- a/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller_unittest.mm
@@ -11,8 +11,10 @@
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
#include "chrome/browser/ui/toolbar/action_box_menu_model.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_builder.h"
+#include "chrome/common/extensions/manifest_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -57,11 +59,13 @@ class ActionBoxMenuBubbleControllerTest : public CocoaProfileTest {
&command_line, base::FilePath(), false);
EXPECT_TRUE(service_->extensions_enabled());
service_->Init();
+ (new extensions::BackgroundManifestHandler)->Register();
}
virtual void TearDown() OVERRIDE {
// Close our windows.
[controller_ close];
+ extensions::ManifestHandler::ClearRegistryForTesting();
CocoaProfileTest::TearDown();
}
diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
index 3330c12..2d6638e 100644
--- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
@@ -44,6 +44,7 @@
#include "chrome/browser/view_type_utils.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_icon_set.h"
@@ -974,10 +975,12 @@ ExtensionSettingsHandler::GetInspectablePagesForExtension(
extension_service_->profile(), &result);
// Include a link to start the lazy background page, if applicable.
- if (extension->has_lazy_background_page() && extension_is_enabled &&
+ if (extensions::BackgroundInfo::HasLazyBackgroundPage(extension) &&
+ extension_is_enabled &&
!process_manager->GetBackgroundHostForExtension(extension->id())) {
result.push_back(
- ExtensionPage(extension->GetBackgroundURL(), -1, -1, false));
+ ExtensionPage(extensions::BackgroundInfo::GetBackgroundURL(extension),
+ -1, -1, false));
}
// Repeat for the incognito process, if applicable. Don't try to get
@@ -991,10 +994,12 @@ ExtensionSettingsHandler::GetInspectablePagesForExtension(
process_manager->GetRenderViewHostsForExtension(extension->id()),
&result);
- if (extension->has_lazy_background_page() && extension_is_enabled &&
+ if (extensions::BackgroundInfo::HasLazyBackgroundPage(extension)
+ && extension_is_enabled &&
!process_manager->GetBackgroundHostForExtension(extension->id())) {
result.push_back(
- ExtensionPage(extension->GetBackgroundURL(), -1, -1, true));
+ ExtensionPage(extensions::BackgroundInfo::GetBackgroundURL(extension),
+ -1, -1, true));
}
}
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 7efde3f..30c300e 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -184,6 +184,8 @@
'common/extensions/api/speech/tts_engine_manifest_handler.h',
'common/extensions/api/themes/theme_handler.cc',
'common/extensions/api/themes/theme_handler.h',
+ 'common/extensions/background_info.cc',
+ 'common/extensions/background_info.h',
'common/extensions/command.cc',
'common/extensions/command.h',
'common/extensions/csp_handler.cc',
diff --git a/chrome/common/extensions/api/commands/commands_handler.cc b/chrome/common/extensions/api/commands/commands_handler.cc
index 09cb4f6..d41b4b1 100644
--- a/chrome/common/extensions/api/commands/commands_handler.cc
+++ b/chrome/common/extensions/api/commands/commands_handler.cc
@@ -124,7 +124,7 @@ bool CommandsHandler::Parse(Extension* extension, string16* error) {
return true;
}
-bool CommandsHandler::AlwaysParseForType(Manifest::Type type) {
+bool CommandsHandler::AlwaysParseForType(Manifest::Type type) const {
return type == Manifest::TYPE_EXTENSION ||
type == Manifest::TYPE_LEGACY_PACKAGED_APP ||
type == Manifest::TYPE_PLATFORM_APP;
@@ -139,4 +139,8 @@ void CommandsHandler::MaybeSetBrowserActionDefault(const Extension* extension,
}
}
+const std::vector<std::string> CommandsHandler::Keys() const {
+ return SingleKey(keys::kCommands);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/commands/commands_handler.h b/chrome/common/extensions/api/commands/commands_handler.h
index eb88ac7..d38cc2b 100644
--- a/chrome/common/extensions/api/commands/commands_handler.h
+++ b/chrome/common/extensions/api/commands/commands_handler.h
@@ -41,7 +41,7 @@ class CommandsHandler : public ManifestHandler {
virtual ~CommandsHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
- virtual bool AlwaysParseForType(Manifest::Type type) OVERRIDE;
+ virtual bool AlwaysParseForType(Manifest::Type type) const OVERRIDE;
private:
// If the extension defines a browser action, but no command for it, then
@@ -49,6 +49,10 @@ class CommandsHandler : public ManifestHandler {
// No keyboard shortcut will be assigned to it, until the user selects one.
void MaybeSetBrowserActionDefault(const Extension* extension,
CommandsInfo* info);
+
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(CommandsHandler);
};
} // namespace extensions
diff --git a/chrome/common/extensions/api/commands/commands_manifest_unittest.cc b/chrome/common/extensions/api/commands/commands_manifest_unittest.cc
index 9a27c39..80f3317 100644
--- a/chrome/common/extensions/api/commands/commands_manifest_unittest.cc
+++ b/chrome/common/extensions/api/commands/commands_manifest_unittest.cc
@@ -8,8 +8,6 @@
#include "base/string_util.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/commands/commands_handler.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace errors = extension_manifest_errors;
@@ -19,8 +17,7 @@ namespace extensions {
class CommandsManifestTest : public ExtensionManifestTest {
protected:
virtual void SetUp() OVERRIDE {
- ManifestHandler::Register(extension_manifest_keys::kCommands,
- make_linked_ptr(new CommandsHandler));
+ (new CommandsHandler)->Register();
}
};
diff --git a/chrome/common/extensions/api/extension_action/browser_action_handler.cc b/chrome/common/extensions/api/extension_action/browser_action_handler.cc
index b5ab1db..e8dcda9 100644
--- a/chrome/common/extensions/api/extension_action/browser_action_handler.cc
+++ b/chrome/common/extensions/api/extension_action/browser_action_handler.cc
@@ -41,4 +41,8 @@ bool BrowserActionHandler::Parse(Extension* extension,
return true;
}
+const std::vector<std::string> BrowserActionHandler::Keys() const {
+ return SingleKey(extension_manifest_keys::kBrowserAction);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/extension_action/browser_action_handler.h b/chrome/common/extensions/api/extension_action/browser_action_handler.h
index e204a22..7f71b0f 100644
--- a/chrome/common/extensions/api/extension_action/browser_action_handler.h
+++ b/chrome/common/extensions/api/extension_action/browser_action_handler.h
@@ -20,6 +20,11 @@ class BrowserActionHandler : public ManifestHandler {
virtual ~BrowserActionHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserActionHandler);
};
} // namespace extensions
diff --git a/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc b/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc
index 338a2d9..84277176 100644
--- a/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc
+++ b/chrome/common/extensions/api/extension_action/browser_action_manifest_unittest.cc
@@ -7,7 +7,6 @@
#include "chrome/common/extensions/extension_builder.h"
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "chrome/common/extensions/value_builder.h"
#include "extensions/common/error_utils.h"
@@ -22,8 +21,7 @@ class BrowserActionManifestTest : public ExtensionManifestTest {
protected:
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- ManifestHandler::Register(extension_manifest_keys::kBrowserAction,
- make_linked_ptr(new BrowserActionHandler));
+ (new BrowserActionHandler)->Register();
}
};
diff --git a/chrome/common/extensions/api/extension_action/page_action_handler.cc b/chrome/common/extensions/api/extension_action/page_action_handler.cc
index 90690cc..aa498d9 100644
--- a/chrome/common/extensions/api/extension_action/page_action_handler.cc
+++ b/chrome/common/extensions/api/extension_action/page_action_handler.cc
@@ -67,4 +67,11 @@ bool PageActionHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> PageActionHandler::Keys() const {
+ std::vector<std::string> keys;
+ keys.push_back(keys::kPageAction);
+ keys.push_back(keys::kPageActions);
+ return keys;
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/extension_action/page_action_handler.h b/chrome/common/extensions/api/extension_action/page_action_handler.h
index d770a14..50130e14 100644
--- a/chrome/common/extensions/api/extension_action/page_action_handler.h
+++ b/chrome/common/extensions/api/extension_action/page_action_handler.h
@@ -20,6 +20,11 @@ class PageActionHandler : public ManifestHandler {
virtual ~PageActionHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(PageActionHandler);
};
} // namespace extensions
diff --git a/chrome/common/extensions/api/extension_action/page_action_manifest_unittest.cc b/chrome/common/extensions/api/extension_action/page_action_manifest_unittest.cc
index 6362b9f0..2591ebe 100644
--- a/chrome/common/extensions/api/extension_action/page_action_manifest_unittest.cc
+++ b/chrome/common/extensions/api/extension_action/page_action_manifest_unittest.cc
@@ -6,7 +6,6 @@
#include "chrome/common/extensions/api/extension_action/page_action_handler.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "extensions/common/error_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -20,9 +19,7 @@ class PageActionManifestTest : public ExtensionManifestTest {
protected:
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- linked_ptr<PageActionHandler> page_action_handler(new PageActionHandler);
- ManifestHandler::Register(keys::kPageAction, page_action_handler);
- ManifestHandler::Register(keys::kPageActions, page_action_handler);
+ (new PageActionHandler)->Register();
}
virtual const char* test_data_dir() OVERRIDE {
@@ -67,7 +64,7 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) {
// First try with an empty dictionary.
action = LoadAction("page_action_empty.json");
- ASSERT_TRUE(action != NULL);
+ ASSERT_TRUE(action);
// Now setup some values to use in the action.
const std::string id("MyExtensionActionId");
@@ -75,7 +72,7 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) {
std::string img1("image1.png");
action = LoadAction("page_action.json");
- ASSERT_TRUE(NULL != action.get());
+ ASSERT_TRUE(action);
ASSERT_EQ(id, action->id);
// No title, so fall back to name.
@@ -86,20 +83,20 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) {
// Same test with explicitly set type.
action = LoadAction("page_action_type.json");
- ASSERT_TRUE(NULL != action.get());
+ ASSERT_TRUE(action);
// Try an action without id key.
action = LoadAction("page_action_no_id.json");
- ASSERT_TRUE(NULL != action.get());
+ ASSERT_TRUE(action);
// Then try without the name key. It's optional, so no error.
action = LoadAction("page_action_no_name.json");
- ASSERT_TRUE(NULL != action.get());
+ ASSERT_TRUE(action);
ASSERT_TRUE(action->default_title.empty());
// Then try without the icon paths key.
action = LoadAction("page_action_no_icon.json");
- ASSERT_TRUE(NULL != action.get());
+ ASSERT_TRUE(action);
// Now test that we can parse the new format for page actions.
const std::string kTitle("MyExtensionActionTitle");
@@ -107,7 +104,7 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) {
const std::string kPopupHtmlFile("a_popup.html");
action = LoadAction("page_action_new_format.json");
- ASSERT_TRUE(action.get());
+ ASSERT_TRUE(action);
ASSERT_EQ(kTitle, action->default_title);
ASSERT_FALSE(action->default_icon.empty());
@@ -117,7 +114,7 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) {
// Invalid name should give an error only with no title.
action = LoadAction("page_action_invalid_name.json");
- ASSERT_TRUE(NULL != action.get());
+ ASSERT_TRUE(action);
ASSERT_EQ(kTitle, action->default_title);
LoadAndExpectError("page_action_invalid_name_no_title.json",
@@ -130,12 +127,11 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) {
// Only use "popup", expect success.
scoped_refptr<Extension> extension =
LoadAndExpectSuccess("page_action_popup.json");
- // TODO(yoz): this is dumb
- action = LoadAction("page_action_popup.json");
- ASSERT_TRUE(NULL != action.get());
+ const ActionInfo* extension_action = ActionInfo::GetPageActionInfo(extension);
+ ASSERT_TRUE(extension_action);
ASSERT_STREQ(
extension->url().Resolve(kPopupHtmlFile).spec().c_str(),
- action->default_popup_url.spec().c_str());
+ extension_action->default_popup_url.spec().c_str());
// Use both "popup" and "default_popup", expect failure.
LoadAndExpectError("page_action_popup_and_default_popup.json",
@@ -146,15 +142,15 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) {
// Use only "default_popup", expect success.
extension = LoadAndExpectSuccess("page_action_popup.json");
- action = LoadAction("page_action_default_popup.json");
- ASSERT_TRUE(NULL != action.get());
+ extension_action = ActionInfo::GetPageActionInfo(extension);
+ ASSERT_TRUE(extension_action);
ASSERT_STREQ(
extension->url().Resolve(kPopupHtmlFile).spec().c_str(),
- action->default_popup_url.spec().c_str());
+ extension_action->default_popup_url.spec().c_str());
// Setting default_popup to "" is the same as having no popup.
action = LoadAction("page_action_empty_default_popup.json");
- ASSERT_TRUE(NULL != action.get());
+ ASSERT_TRUE(action);
EXPECT_TRUE(action->default_popup_url.is_empty());
ASSERT_STREQ(
"",
@@ -163,7 +159,7 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) {
// Setting popup to "" is the same as having no popup.
action = LoadAction("page_action_empty_popup.json");
- ASSERT_TRUE(NULL != action.get());
+ ASSERT_TRUE(action);
EXPECT_TRUE(action->default_popup_url.is_empty());
ASSERT_STREQ(
"",
diff --git a/chrome/common/extensions/api/extension_action/script_badge_handler.cc b/chrome/common/extensions/api/extension_action/script_badge_handler.cc
index 444b80d..851c3b4 100644
--- a/chrome/common/extensions/api/extension_action/script_badge_handler.cc
+++ b/chrome/common/extensions/api/extension_action/script_badge_handler.cc
@@ -17,25 +17,25 @@
#include "extensions/common/install_warning.h"
namespace errors = extension_manifest_errors;
+namespace keys = extension_manifest_keys;
namespace extensions {
ScriptBadgeHandler::ScriptBadgeHandler() {
- prerequisite_keys_.push_back(extension_manifest_keys::kIcons);
}
ScriptBadgeHandler::~ScriptBadgeHandler() {
}
-const std::vector<std::string>& ScriptBadgeHandler::PrerequisiteKeys() {
- return prerequisite_keys_;
+const std::vector<std::string> ScriptBadgeHandler::PrerequisiteKeys() const {
+ return SingleKey(keys::kIcons);
}
bool ScriptBadgeHandler::Parse(Extension* extension, string16* error) {
scoped_ptr<ActionInfo> action_info(new ActionInfo);
// Provide a default script badge if one isn't declared in the manifest.
- if (!extension->manifest()->HasKey(extension_manifest_keys::kScriptBadge)) {
+ if (!extension->manifest()->HasKey(keys::kScriptBadge)) {
SetActionInfoDefaults(extension, action_info.get());
ActionInfo::SetScriptBadgeInfo(extension, action_info.release());
return true;
@@ -51,8 +51,7 @@ bool ScriptBadgeHandler::Parse(Extension* extension, string16* error) {
}
const DictionaryValue* dict = NULL;
- if (!extension->manifest()->GetDictionary(
- extension_manifest_keys::kScriptBadge, &dict)) {
+ if (!extension->manifest()->GetDictionary(keys::kScriptBadge, &dict)) {
*error = ASCIIToUTF16(errors::kInvalidScriptBadge);
return false;
}
@@ -86,7 +85,7 @@ bool ScriptBadgeHandler::Parse(Extension* extension, string16* error) {
return true;
}
-bool ScriptBadgeHandler::AlwaysParseForType(Manifest::Type type) {
+bool ScriptBadgeHandler::AlwaysParseForType(Manifest::Type type) const {
return type == Manifest::TYPE_EXTENSION;
}
@@ -105,4 +104,8 @@ void ScriptBadgeHandler::SetActionInfoDefaults(const Extension* extension,
}
}
+const std::vector<std::string> ScriptBadgeHandler::Keys() const {
+ return SingleKey(keys::kScriptBadge);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/extension_action/script_badge_handler.h b/chrome/common/extensions/api/extension_action/script_badge_handler.h
index d539aaf..cd742bc0 100644
--- a/chrome/common/extensions/api/extension_action/script_badge_handler.h
+++ b/chrome/common/extensions/api/extension_action/script_badge_handler.h
@@ -20,8 +20,8 @@ class ScriptBadgeHandler : public ManifestHandler {
virtual ~ScriptBadgeHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
- virtual const std::vector<std::string>& PrerequisiteKeys() OVERRIDE;
- virtual bool AlwaysParseForType(Manifest::Type type) OVERRIDE;
+ virtual const std::vector<std::string> PrerequisiteKeys() const OVERRIDE;
+ virtual bool AlwaysParseForType(Manifest::Type type) const OVERRIDE;
private:
// Sets the fields of ActionInfo to the default values, matching the parent
@@ -29,7 +29,7 @@ class ScriptBadgeHandler : public ManifestHandler {
// is present in the manifest.
void SetActionInfoDefaults(const Extension* extension, ActionInfo* info);
- std::vector<std::string> prerequisite_keys_;
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(ScriptBadgeHandler);
};
diff --git a/chrome/common/extensions/api/extension_action/script_badge_manifest_unittest.cc b/chrome/common/extensions/api/extension_action/script_badge_manifest_unittest.cc
index 8dbdd7a..5142ab7 100644
--- a/chrome/common/extensions/api/extension_action/script_badge_manifest_unittest.cc
+++ b/chrome/common/extensions/api/extension_action/script_badge_manifest_unittest.cc
@@ -10,7 +10,6 @@
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/feature_switch.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "extensions/common/install_warning.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -35,11 +34,8 @@ std::vector<InstallWarning> StripMissingFlagWarning(
class ScriptBadgeManifestTest : public ExtensionManifestTest {
protected:
virtual void SetUp() OVERRIDE {
- ExtensionManifestTest::SetUp();
- ManifestHandler::Register(extension_manifest_keys::kScriptBadge,
- make_linked_ptr(new ScriptBadgeHandler));
- ManifestHandler::Register(extension_manifest_keys::kIcons,
- make_linked_ptr(new IconsHandler));
+ (new IconsHandler)->Register();
+ (new ScriptBadgeHandler)->Register();
}
};
diff --git a/chrome/common/extensions/api/file_handlers/file_handlers_parser.cc b/chrome/common/extensions/api/file_handlers/file_handlers_parser.cc
index 894e37e..9917869 100644
--- a/chrome/common/extensions/api/file_handlers/file_handlers_parser.cc
+++ b/chrome/common/extensions/api/file_handlers/file_handlers_parser.cc
@@ -12,6 +12,8 @@
#include "chrome/common/extensions/manifest.h"
#include "extensions/common/error_utils.h"
+namespace keys = extension_manifest_keys;
+
namespace extensions {
FileHandlerInfo::FileHandlerInfo() {}
@@ -45,17 +47,16 @@ bool LoadFileHandler(const std::string& handler_id,
const ListValue* mime_types = NULL;
// TODO(benwells): handle file extensions.
- if (!handler_info.HasKey(extension_manifest_keys::kFileHandlerTypes) ||
- !handler_info.GetList(extension_manifest_keys::kFileHandlerTypes,
- &mime_types) || mime_types->GetSize() == 0) {
+ if (!handler_info.HasKey(keys::kFileHandlerTypes) ||
+ !handler_info.GetList(keys::kFileHandlerTypes, &mime_types) ||
+ mime_types->GetSize() == 0) {
*error = ErrorUtils::FormatErrorMessageUTF16(
extension_manifest_errors::kInvalidFileHandlerType, handler_id);
return false;
}
- if (handler_info.HasKey(extension_manifest_keys::kFileHandlerTitle) &&
- !handler_info.GetString(extension_manifest_keys::kFileHandlerTitle,
- &handler.title)) {
+ if (handler_info.HasKey(keys::kFileHandlerTitle) &&
+ !handler_info.GetString(keys::kFileHandlerTitle, &handler.title)) {
*error = ASCIIToUTF16(extension_manifest_errors::kInvalidFileHandlerTitle);
return false;
}
@@ -78,8 +79,8 @@ bool LoadFileHandler(const std::string& handler_id,
bool FileHandlersParser::Parse(Extension* extension, string16* error) {
scoped_ptr<FileHandlers> info(new FileHandlers);
const DictionaryValue* all_handlers = NULL;
- if (!extension->manifest()->GetDictionary(
- extension_manifest_keys::kFileHandlers, &all_handlers)) {
+ if (!extension->manifest()->GetDictionary(keys::kFileHandlers,
+ &all_handlers)) {
*error = ASCIIToUTF16(extension_manifest_errors::kInvalidFileHandlers);
return false;
}
@@ -99,9 +100,12 @@ bool FileHandlersParser::Parse(Extension* extension, string16* error) {
}
}
- extension->SetManifestData(extension_manifest_keys::kFileHandlers,
- info.release());
+ extension->SetManifestData(keys::kFileHandlers, info.release());
return true;
}
+const std::vector<std::string> FileHandlersParser::Keys() const {
+ return SingleKey(keys::kFileHandlers);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/file_handlers/file_handlers_parser.h b/chrome/common/extensions/api/file_handlers/file_handlers_parser.h
index 00a69c2..3e6589d 100644
--- a/chrome/common/extensions/api/file_handlers/file_handlers_parser.h
+++ b/chrome/common/extensions/api/file_handlers/file_handlers_parser.h
@@ -45,6 +45,11 @@ class FileHandlersParser : public ManifestHandler {
virtual ~FileHandlersParser();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(FileHandlersParser);
};
} // namespace extensions
diff --git a/chrome/common/extensions/api/i18n/default_locale_handler.cc b/chrome/common/extensions/api/i18n/default_locale_handler.cc
index 7baa9b59..d46d490 100644
--- a/chrome/common/extensions/api/i18n/default_locale_handler.cc
+++ b/chrome/common/extensions/api/i18n/default_locale_handler.cc
@@ -41,4 +41,8 @@ bool DefaultLocaleHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> DefaultLocaleHandler::Keys() const {
+ return SingleKey(keys::kDefaultLocale);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/i18n/default_locale_handler.h b/chrome/common/extensions/api/i18n/default_locale_handler.h
index f3541d3..1735ba3 100644
--- a/chrome/common/extensions/api/i18n/default_locale_handler.h
+++ b/chrome/common/extensions/api/i18n/default_locale_handler.h
@@ -29,6 +29,8 @@ class DefaultLocaleHandler : public ManifestHandler {
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
DISALLOW_COPY_AND_ASSIGN(DefaultLocaleHandler);
};
diff --git a/chrome/common/extensions/api/i18n/default_locale_manifest_unittest.cc b/chrome/common/extensions/api/i18n/default_locale_manifest_unittest.cc
index c387d8a..94587b3 100644
--- a/chrome/common/extensions/api/i18n/default_locale_manifest_unittest.cc
+++ b/chrome/common/extensions/api/i18n/default_locale_manifest_unittest.cc
@@ -4,7 +4,6 @@
#include "chrome/common/extensions/api/i18n/default_locale_handler.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -13,8 +12,7 @@ namespace extensions {
class DefaultLocaleManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- ManifestHandler::Register(extension_manifest_keys::kDefaultLocale,
- make_linked_ptr(new DefaultLocaleHandler));
+ (new DefaultLocaleHandler)->Register();
}
};
diff --git a/chrome/common/extensions/api/icons/icons_handler.cc b/chrome/common/extensions/api/icons/icons_handler.cc
index fd8eae0..5076b4d 100644
--- a/chrome/common/extensions/api/icons/icons_handler.cc
+++ b/chrome/common/extensions/api/icons/icons_handler.cc
@@ -144,4 +144,8 @@ bool IconsHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> IconsHandler::Keys() const {
+ return SingleKey(keys::kIcons);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/icons/icons_handler.h b/chrome/common/extensions/api/icons/icons_handler.h
index 8243eb1..af48059 100644
--- a/chrome/common/extensions/api/icons/icons_handler.h
+++ b/chrome/common/extensions/api/icons/icons_handler.h
@@ -72,6 +72,8 @@ class IconsHandler : public ManifestHandler {
virtual ~IconsHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
};
} // namespace extensions
diff --git a/chrome/common/extensions/api/icons/icons_manifest_unittest.cc b/chrome/common/extensions/api/icons/icons_manifest_unittest.cc
index 1d09290..a27549a 100644
--- a/chrome/common/extensions/api/icons/icons_manifest_unittest.cc
+++ b/chrome/common/extensions/api/icons/icons_manifest_unittest.cc
@@ -17,8 +17,7 @@ class IconsManifestTest : public ExtensionManifestTest {
protected:
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- ManifestHandler::Register(extension_manifest_keys::kIcons,
- make_linked_ptr(new IconsHandler));
+ (new IconsHandler)->Register();
}
};
diff --git a/chrome/common/extensions/api/identity/extension_manifests_auth_unittest.cc b/chrome/common/extensions/api/identity/extension_manifests_auth_unittest.cc
index a810544..8a7af96 100644
--- a/chrome/common/extensions/api/identity/extension_manifests_auth_unittest.cc
+++ b/chrome/common/extensions/api/identity/extension_manifests_auth_unittest.cc
@@ -15,8 +15,8 @@ namespace extensions {
class OAuth2ManifestTest : public ExtensionManifestTest {
protected:
virtual void SetUp() OVERRIDE {
- ManifestHandler::Register(extension_manifest_keys::kOAuth2,
- make_linked_ptr(new OAuth2ManifestHandler));
+ ExtensionManifestTest::SetUp();
+ (new OAuth2ManifestHandler)->Register();
}
};
diff --git a/chrome/common/extensions/api/identity/oauth2_manifest_handler.cc b/chrome/common/extensions/api/identity/oauth2_manifest_handler.cc
index 6a7d8b1..bec0631 100644
--- a/chrome/common/extensions/api/identity/oauth2_manifest_handler.cc
+++ b/chrome/common/extensions/api/identity/oauth2_manifest_handler.cc
@@ -73,4 +73,8 @@ bool OAuth2ManifestHandler::Parse(Extension* extension,
return true;
}
+const std::vector<std::string> OAuth2ManifestHandler::Keys() const {
+ return SingleKey(keys::kOAuth2);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/identity/oauth2_manifest_handler.h b/chrome/common/extensions/api/identity/oauth2_manifest_handler.h
index 8a361bd..c2247d1 100644
--- a/chrome/common/extensions/api/identity/oauth2_manifest_handler.h
+++ b/chrome/common/extensions/api/identity/oauth2_manifest_handler.h
@@ -33,7 +33,10 @@ class OAuth2ManifestHandler : public ManifestHandler {
virtual bool Parse(Extension* extension,
string16* error) OVERRIDE;
+
private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
DISALLOW_COPY_AND_ASSIGN(OAuth2ManifestHandler);
};
diff --git a/chrome/common/extensions/api/input_ime/input_components_handler.cc b/chrome/common/extensions/api/input_ime/input_components_handler.cc
index 31f4483..36da8bb 100644
--- a/chrome/common/extensions/api/input_ime/input_components_handler.cc
+++ b/chrome/common/extensions/api/input_ime/input_components_handler.cc
@@ -185,4 +185,8 @@ bool InputComponentsHandler::Parse(Extension* extension,
return true;
}
+const std::vector<std::string> InputComponentsHandler::Keys() const {
+ return SingleKey(keys::kInputComponents);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/input_ime/input_components_handler.h b/chrome/common/extensions/api/input_ime/input_components_handler.h
index c1620a3..215f2f1 100644
--- a/chrome/common/extensions/api/input_ime/input_components_handler.h
+++ b/chrome/common/extensions/api/input_ime/input_components_handler.h
@@ -58,6 +58,11 @@ class InputComponentsHandler : public ManifestHandler {
virtual ~InputComponentsHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(InputComponentsHandler);
};
} // namespace extensions
diff --git a/chrome/common/extensions/api/omnibox/omnibox_handler.cc b/chrome/common/extensions/api/omnibox/omnibox_handler.cc
index 60ab761..95da78f 100644
--- a/chrome/common/extensions/api/omnibox/omnibox_handler.cc
+++ b/chrome/common/extensions/api/omnibox/omnibox_handler.cc
@@ -48,4 +48,8 @@ bool OmniboxHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> OmniboxHandler::Keys() const {
+ return SingleKey(extension_manifest_keys::kOmnibox);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/omnibox/omnibox_handler.h b/chrome/common/extensions/api/omnibox/omnibox_handler.h
index 166559b..5ef709e 100644
--- a/chrome/common/extensions/api/omnibox/omnibox_handler.h
+++ b/chrome/common/extensions/api/omnibox/omnibox_handler.h
@@ -29,6 +29,9 @@ class OmniboxHandler : public ManifestHandler {
virtual ~OmniboxHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
};
} // namespace extensions
diff --git a/chrome/common/extensions/api/page_launcher/page_launcher_handler.cc b/chrome/common/extensions/api/page_launcher/page_launcher_handler.cc
index dbfe7c3..9fa6fe6 100644
--- a/chrome/common/extensions/api/page_launcher/page_launcher_handler.cc
+++ b/chrome/common/extensions/api/page_launcher/page_launcher_handler.cc
@@ -41,4 +41,8 @@ bool PageLauncherHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> PageLauncherHandler::Keys() const {
+ return SingleKey(keys::kPageLauncher);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/page_launcher/page_launcher_handler.h b/chrome/common/extensions/api/page_launcher/page_launcher_handler.h
index 4a964ef..bf18f51 100644
--- a/chrome/common/extensions/api/page_launcher/page_launcher_handler.h
+++ b/chrome/common/extensions/api/page_launcher/page_launcher_handler.h
@@ -20,7 +20,10 @@ class PageLauncherHandler : public ManifestHandler {
virtual ~PageLauncherHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
DISALLOW_COPY_AND_ASSIGN(PageLauncherHandler);
};
} // namespace extensions
diff --git a/chrome/common/extensions/api/speech/tts_engine_manifest_handler.cc b/chrome/common/extensions/api/speech/tts_engine_manifest_handler.cc
index ca502c4..c1b4068 100644
--- a/chrome/common/extensions/api/speech/tts_engine_manifest_handler.cc
+++ b/chrome/common/extensions/api/speech/tts_engine_manifest_handler.cc
@@ -135,4 +135,8 @@ bool TtsEngineManifestHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> TtsEngineManifestHandler::Keys() const {
+ return SingleKey(keys::kTtsEngine);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/speech/tts_engine_manifest_handler.h b/chrome/common/extensions/api/speech/tts_engine_manifest_handler.h
index 9c24b53..71d8e05 100644
--- a/chrome/common/extensions/api/speech/tts_engine_manifest_handler.h
+++ b/chrome/common/extensions/api/speech/tts_engine_manifest_handler.h
@@ -33,6 +33,11 @@ class TtsEngineManifestHandler : public ManifestHandler {
virtual ~TtsEngineManifestHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(TtsEngineManifestHandler);
};
} // namespace extensions
diff --git a/chrome/common/extensions/api/themes/theme_handler.cc b/chrome/common/extensions/api/themes/theme_handler.cc
index 0f1fc9e..ce881af 100644
--- a/chrome/common/extensions/api/themes/theme_handler.cc
+++ b/chrome/common/extensions/api/themes/theme_handler.cc
@@ -169,4 +169,8 @@ bool ThemeHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> ThemeHandler::Keys() const {
+ return SingleKey(keys::kTheme);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/api/themes/theme_handler.h b/chrome/common/extensions/api/themes/theme_handler.h
index 09280fc..928ca7b 100644
--- a/chrome/common/extensions/api/themes/theme_handler.h
+++ b/chrome/common/extensions/api/themes/theme_handler.h
@@ -48,6 +48,8 @@ class ThemeHandler : public ManifestHandler {
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
DISALLOW_COPY_AND_ASSIGN(ThemeHandler);
};
diff --git a/chrome/common/extensions/background_info.cc b/chrome/common/extensions/background_info.cc
new file mode 100644
index 0000000..b7b5a9bf
--- /dev/null
+++ b/chrome/common/extensions/background_info.cc
@@ -0,0 +1,255 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/extensions/background_info.h"
+
+#include "base/command_line.h"
+#include "base/lazy_instance.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/string_number_conversions.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/permissions/api_permission_set.h"
+#include "extensions/common/error_utils.h"
+
+using base::DictionaryValue;
+namespace keys = extension_manifest_keys;
+namespace values = extension_manifest_values;
+namespace errors = extension_manifest_errors;
+
+namespace extensions {
+
+namespace {
+
+const char kBackground[] = "background";
+
+static base::LazyInstance<BackgroundInfo> g_empty_background_info =
+ LAZY_INSTANCE_INITIALIZER;
+
+const BackgroundInfo& GetBackgroundInfo(const Extension* extension) {
+ BackgroundInfo* info = static_cast<BackgroundInfo*>(
+ extension->GetManifestData(kBackground));
+ if (!info)
+ return g_empty_background_info.Get();
+ return *info;
+}
+
+} // namespace
+
+BackgroundInfo::BackgroundInfo()
+ : is_persistent_(true),
+ allow_js_access_(true) {
+}
+
+BackgroundInfo::~BackgroundInfo() {
+}
+
+// static
+GURL BackgroundInfo::GetBackgroundURL(const Extension* extension) {
+ const BackgroundInfo& info = GetBackgroundInfo(extension);
+ if (info.background_scripts_.empty())
+ return info.background_url_;
+ return extension->GetResourceURL(
+ extension_filenames::kGeneratedBackgroundPageFilename);
+}
+
+// static
+const std::vector<std::string>& BackgroundInfo::GetBackgroundScripts(
+ const Extension* extension) {
+ return GetBackgroundInfo(extension).background_scripts_;
+}
+
+// static
+bool BackgroundInfo::HasBackgroundPage(const Extension* extension) {
+ return GetBackgroundInfo(extension).has_background_page();
+}
+
+// static
+bool BackgroundInfo::AllowJSAccess(const Extension* extension) {
+ return GetBackgroundInfo(extension).allow_js_access_;
+}
+
+// static
+bool BackgroundInfo::HasPersistentBackgroundPage(const Extension* extension) {
+ const BackgroundInfo& info = GetBackgroundInfo(extension);
+ return info.has_background_page() && info.is_persistent_;
+}
+
+// static
+bool BackgroundInfo::HasLazyBackgroundPage(const Extension* extension) {
+ const BackgroundInfo& info = GetBackgroundInfo(extension);
+ return info.has_background_page() && !info.is_persistent_;
+}
+
+bool BackgroundInfo::Parse(const Extension* extension, string16* error) {
+ const std::string& bg_scripts_key = extension->is_platform_app() ?
+ keys::kPlatformAppBackgroundScripts : keys::kBackgroundScripts;
+ if (!LoadBackgroundScripts(extension, bg_scripts_key, error) ||
+ !LoadBackgroundPage(extension, error) ||
+ !LoadBackgroundPersistent(extension, error) ||
+ !LoadAllowJSAccess(extension, error)) {
+ return false;
+ }
+ return true;
+}
+
+bool BackgroundInfo::LoadBackgroundScripts(const Extension* extension,
+ const std::string& key,
+ string16* error) {
+ const Value* background_scripts_value = NULL;
+ if (!extension->manifest()->Get(key, &background_scripts_value))
+ return true;
+
+ CHECK(background_scripts_value);
+ if (background_scripts_value->GetType() != Value::TYPE_LIST) {
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundScripts);
+ return false;
+ }
+
+ const ListValue* background_scripts = NULL;
+ background_scripts_value->GetAsList(&background_scripts);
+ for (size_t i = 0; i < background_scripts->GetSize(); ++i) {
+ std::string script;
+ if (!background_scripts->GetString(i, &script)) {
+ *error = ErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidBackgroundScript, base::IntToString(i));
+ return false;
+ }
+ background_scripts_.push_back(script);
+ }
+
+ return true;
+}
+
+bool BackgroundInfo::LoadBackgroundPage(const Extension* extension,
+ const std::string& key,
+ string16* error) {
+ const base::Value* background_page_value = NULL;
+ if (!extension->manifest()->Get(key, &background_page_value))
+ return true;
+
+ if (!background_scripts_.empty()) {
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundCombination);
+ return false;
+ }
+
+ std::string background_str;
+ if (!background_page_value->GetAsString(&background_str)) {
+ *error = ASCIIToUTF16(errors::kInvalidBackground);
+ return false;
+ }
+
+ if (extension->is_hosted_app()) {
+ background_url_ = GURL(background_str);
+
+ if (!extension->initial_api_permissions()->count(
+ APIPermission::kBackground)) {
+ *error = ASCIIToUTF16(errors::kBackgroundPermissionNeeded);
+ return false;
+ }
+ // Hosted apps require an absolute URL.
+ if (!background_url_.is_valid()) {
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp);
+ return false;
+ }
+
+ if (!(background_url_.SchemeIs("https") ||
+ (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAllowHTTPBackgroundPage) &&
+ background_url_.SchemeIs("http")))) {
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp);
+ return false;
+ }
+ } else {
+ background_url_ = extension->GetResourceURL(background_str);
+ }
+
+ return true;
+}
+
+bool BackgroundInfo::LoadBackgroundPage(const Extension* extension,
+ string16* error) {
+ if (extension->is_platform_app()) {
+ return LoadBackgroundPage(
+ extension, keys::kPlatformAppBackgroundPage, error);
+ }
+
+ if (!LoadBackgroundPage(extension, keys::kBackgroundPage, error))
+ return false;
+ if (background_url_.is_empty())
+ return LoadBackgroundPage(extension, keys::kBackgroundPageLegacy, error);
+ return true;
+}
+
+bool BackgroundInfo::LoadBackgroundPersistent(const Extension* extension,
+ string16* error) {
+ if (extension->is_platform_app()) {
+ is_persistent_ = false;
+ return true;
+ }
+
+ const Value* background_persistent = NULL;
+ if (!extension->manifest()->Get(keys::kBackgroundPersistent,
+ &background_persistent))
+ return true;
+
+ if (!background_persistent->GetAsBoolean(&is_persistent_)) {
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistent);
+ return false;
+ }
+
+ if (!has_background_page()) {
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistentNoPage);
+ return false;
+ }
+
+ return true;
+}
+
+bool BackgroundInfo::LoadAllowJSAccess(const Extension* extension,
+ string16* error) {
+ const Value* allow_js_access = NULL;
+ if (!extension->manifest()->Get(keys::kBackgroundAllowJsAccess,
+ &allow_js_access))
+ return true;
+
+ if (!allow_js_access->IsType(Value::TYPE_BOOLEAN) ||
+ !allow_js_access->GetAsBoolean(&allow_js_access_)) {
+ *error = ASCIIToUTF16(errors::kInvalidBackgroundAllowJsAccess);
+ return false;
+ }
+
+ return true;
+}
+
+BackgroundManifestHandler::BackgroundManifestHandler() {
+}
+
+BackgroundManifestHandler::~BackgroundManifestHandler() {
+}
+
+bool BackgroundManifestHandler::Parse(Extension* extension, string16* error) {
+ scoped_ptr<BackgroundInfo> info(new BackgroundInfo);
+ if (!info->Parse(extension, error))
+ return false;
+ extension->SetManifestData(kBackground, info.release());
+ return true;
+}
+
+const std::vector<std::string> BackgroundManifestHandler::Keys() const {
+ static const char* keys[] = {
+ keys::kBackgroundAllowJsAccess,
+ keys::kBackgroundPage,
+ keys::kBackgroundPageLegacy,
+ keys::kBackgroundPersistent,
+ keys::kBackgroundScripts,
+ keys::kPlatformAppBackgroundPage,
+ keys::kPlatformAppBackgroundScripts
+ };
+ return std::vector<std::string>(keys, keys + arraysize(keys));
+}
+
+} // extensions
diff --git a/chrome/common/extensions/background_info.h b/chrome/common/extensions/background_info.h
new file mode 100644
index 0000000..c3d5980
--- /dev/null
+++ b/chrome/common/extensions/background_info.h
@@ -0,0 +1,82 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_EXTENSIONS_BACKGROUND_INFO_H_
+#define CHROME_COMMON_EXTENSIONS_BACKGROUND_INFO_H_
+
+#include <string>
+#include <vector>
+
+#include "base/values.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/manifest_handler.h"
+#include "googleurl/src/gurl.h"
+
+namespace extensions {
+
+class BackgroundInfo : public Extension::ManifestData {
+ public:
+ BackgroundInfo();
+ virtual ~BackgroundInfo();
+
+ static GURL GetBackgroundURL(const Extension* extension);
+ static const std::vector<std::string>& GetBackgroundScripts(
+ const Extension* extension);
+ static bool HasBackgroundPage(const Extension* extension);
+ static bool HasPersistentBackgroundPage(const Extension* extension);
+ static bool HasLazyBackgroundPage(const Extension* extension);
+ static bool AllowJSAccess(const Extension* extension);
+
+ bool has_background_page() const {
+ return background_url_.is_valid() || !background_scripts_.empty();
+ }
+
+ bool Parse(const Extension* extension, string16* error);
+
+ private:
+ bool LoadBackgroundScripts(const Extension* extension,
+ const std::string& key,
+ string16* error);
+ bool LoadBackgroundPage(const Extension* extension,
+ const std::string& key,
+ string16* error);
+ bool LoadBackgroundPage(const Extension* extension, string16* error);
+ bool LoadBackgroundPersistent(const Extension* extension, string16* error);
+ bool LoadAllowJSAccess(const Extension* extension, string16* error);
+
+ // Optional URL to a master page of which a single instance should be always
+ // loaded in the background.
+ GURL background_url_;
+
+ // Optional list of scripts to use to generate a background page. If this is
+ // present, background_url_ will be empty and generated by GetBackgroundURL().
+ std::vector<std::string> background_scripts_;
+
+ // True if the background page should stay loaded forever; false if it should
+ // load on-demand (when it needs to handle an event). Defaults to true.
+ bool is_persistent_;
+
+ // True if the background page can be scripted by pages of the app or
+ // extension, in which case all such pages must run in the same process.
+ // False if such pages are not permitted to script the background page,
+ // allowing them to run in different processes.
+ // Defaults to true.
+ bool allow_js_access_;
+};
+
+// Parses all background/event page-related keys in the manifest.
+class BackgroundManifestHandler : public ManifestHandler {
+ public:
+ BackgroundManifestHandler();
+ virtual ~BackgroundManifestHandler();
+
+ virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+};
+
+} // namespace extensions
+
+#endif // CHROME_COMMON_EXTENSIONS_BACKGROUND_INFO_H_
diff --git a/chrome/common/extensions/csp_handler.cc b/chrome/common/extensions/csp_handler.cc
index 8448854..1ed5832 100644
--- a/chrome/common/extensions/csp_handler.cc
+++ b/chrome/common/extensions/csp_handler.cc
@@ -68,9 +68,7 @@ CSPHandler::~CSPHandler() {
}
bool CSPHandler::Parse(Extension* extension, string16* error) {
- const std::string& key = is_platform_app_ ?
- keys::kPlatformAppContentSecurityPolicy : keys::kContentSecurityPolicy;
-
+ const std::string key = Keys()[0];
if (!extension->manifest()->HasPath(key)) {
if (extension->manifest_version() >= 2) {
// TODO(abarth): Should we continue to let extensions override the
@@ -108,7 +106,7 @@ bool CSPHandler::Parse(Extension* extension, string16* error) {
return true;
}
-bool CSPHandler::AlwaysParseForType(Manifest::Type type) {
+bool CSPHandler::AlwaysParseForType(Manifest::Type type) const {
if (is_platform_app_)
return type == Manifest::TYPE_PLATFORM_APP;
else
@@ -116,4 +114,10 @@ bool CSPHandler::AlwaysParseForType(Manifest::Type type) {
type == Manifest::TYPE_LEGACY_PACKAGED_APP;
}
+const std::vector<std::string> CSPHandler::Keys() const {
+ const std::string& key = is_platform_app_ ?
+ keys::kPlatformAppContentSecurityPolicy : keys::kContentSecurityPolicy;
+ return SingleKey(key);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/csp_handler.h b/chrome/common/extensions/csp_handler.h
index 531393d..cb32c3d 100644
--- a/chrome/common/extensions/csp_handler.h
+++ b/chrome/common/extensions/csp_handler.h
@@ -33,9 +33,11 @@ class CSPHandler : public ManifestHandler {
virtual ~CSPHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
- virtual bool AlwaysParseForType(Manifest::Type type) OVERRIDE;
+ virtual bool AlwaysParseForType(Manifest::Type type) const OVERRIDE;
private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
bool is_platform_app_;
DISALLOW_COPY_AND_ASSIGN(CSPHandler);
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 3fb08fc..7edbf3b 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -30,6 +30,7 @@
#include "chrome/common/extensions/api/extension_action/page_action_handler.h"
#include "chrome/common/extensions/api/icons/icons_handler.h"
#include "chrome/common/extensions/api/themes/theme_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/csp_handler.h"
#include "chrome/common/extensions/csp_validator.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
@@ -148,7 +149,7 @@ bool ReadLaunchDimension(const extensions::Manifest* manifest,
int* target,
bool is_valid_container,
string16* error) {
- Value* temp = NULL;
+ const Value* temp = NULL;
if (manifest->Get(key, &temp)) {
if (!is_valid_container) {
*error = ErrorUtils::FormatErrorMessageUTF16(
@@ -509,7 +510,7 @@ bool Extension::ParsePermissions(const char* key,
APIPermissionSet* api_permissions,
URLPatternSet* host_permissions) {
if (manifest_->HasKey(key)) {
- ListValue* permissions = NULL;
+ const ListValue* permissions = NULL;
if (!manifest_->GetList(key, &permissions)) {
*error = ErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidPermissions, "");
@@ -1103,12 +1104,6 @@ ExtensionResource Extension::GetContentPackSiteList() const {
return GetResource(content_pack_site_list_);
}
-GURL Extension::GetBackgroundURL() const {
- if (background_scripts_.empty())
- return background_url_;
- return GetResourceURL(extension_filenames::kGeneratedBackgroundPageFilename);
-}
-
Extension::RuntimeData::RuntimeData() {}
Extension::RuntimeData::RuntimeData(const PermissionSet* active)
: active_permissions_(active) {}
@@ -1211,7 +1206,7 @@ base::FilePath Extension::MaybeNormalizePath(const base::FilePath& path) {
bool Extension::LoadManagedModeFeatures(string16* error) {
if (!manifest_->HasKey(keys::kContentPack))
return true;
- DictionaryValue* content_pack_value = NULL;
+ const DictionaryValue* content_pack_value = NULL;
if (!manifest_->GetDictionary(keys::kContentPack, &content_pack_value)) {
*error = ASCIIToUTF16(errors::kInvalidContentPack);
return false;
@@ -1261,8 +1256,6 @@ Extension::Extension(const base::FilePath& path,
incognito_split_mode_(false),
offline_enabled_(false),
converted_from_user_script_(false),
- background_page_is_persistent_(true),
- allow_background_js_access_(true),
manifest_(manifest.release()),
finished_parsing_manifest_(false),
is_storage_isolated_(false),
@@ -1401,16 +1394,16 @@ bool Extension::LoadAppIsolation(string16* error) {
|| !is_app())
return true;
- Value* tmp_isolation = NULL;
+ const Value* tmp_isolation = NULL;
if (!manifest_->Get(keys::kIsolation, &tmp_isolation))
return true;
- if (tmp_isolation->GetType() != Value::TYPE_LIST) {
+ const ListValue* isolation_list = NULL;
+ if (!tmp_isolation->GetAsList(&isolation_list)) {
*error = ASCIIToUTF16(errors::kInvalidIsolation);
return false;
}
- ListValue* isolation_list = static_cast<ListValue*>(tmp_isolation);
for (size_t i = 0; i < isolation_list->GetSize(); ++i) {
std::string isolation_string;
if (!isolation_list->GetString(i, &isolation_string)) {
@@ -1493,16 +1486,16 @@ bool Extension::LoadExtent(const char* key,
const char* list_error,
const char* value_error,
string16* error) {
- Value* temp_pattern_value = NULL;
+ const Value* temp_pattern_value = NULL;
if (!manifest_->Get(key, &temp_pattern_value))
return true;
- if (temp_pattern_value->GetType() != Value::TYPE_LIST) {
+ const ListValue* pattern_list = NULL;
+ if (!temp_pattern_value->GetAsList(&pattern_list)) {
*error = ASCIIToUTF16(list_error);
return false;
}
- ListValue* pattern_list = static_cast<ListValue*>(temp_pattern_value);
for (size_t i = 0; i < pattern_list->GetSize(); ++i) {
std::string pattern_string;
if (!pattern_list->GetString(i, &pattern_string)) {
@@ -1563,7 +1556,7 @@ bool Extension::LoadExtent(const char* key,
}
bool Extension::LoadLaunchContainer(string16* error) {
- Value* tmp_launcher_container = NULL;
+ const Value* tmp_launcher_container = NULL;
if (!manifest_->Get(keys::kLaunchContainer, &tmp_launcher_container))
return true;
@@ -1608,7 +1601,7 @@ bool Extension::LoadLaunchContainer(string16* error) {
}
bool Extension::LoadLaunchURL(string16* error) {
- Value* temp = NULL;
+ const Value* temp = NULL;
// launch URL can be either local (to chrome-extension:// root) or an absolute
// web URL.
@@ -1726,12 +1719,7 @@ bool Extension::LoadSharedFeatures(string16* error) {
!LoadNaClModules(error) ||
!LoadSandboxedPages(error) ||
!LoadRequirements(error) ||
- !LoadOfflineEnabled(error) ||
- // LoadBackgroundScripts() must be called before LoadBackgroundPage().
- !LoadBackgroundScripts(error) ||
- !LoadBackgroundPage(error) ||
- !LoadBackgroundPersistent(error) ||
- !LoadBackgroundAllowJSAccess(error))
+ !LoadOfflineEnabled(error))
return false;
return true;
@@ -1776,14 +1764,14 @@ bool Extension::LoadPlugins(string16* error) {
if (!manifest_->HasKey(keys::kPlugins))
return true;
- ListValue* list_value = NULL;
+ const ListValue* list_value = NULL;
if (!manifest_->GetList(keys::kPlugins, &list_value)) {
*error = ASCIIToUTF16(errors::kInvalidPlugins);
return false;
}
for (size_t i = 0; i < list_value->GetSize(); ++i) {
- DictionaryValue* plugin_value = NULL;
+ const DictionaryValue* plugin_value = NULL;
if (!list_value->GetDictionary(i, &plugin_value)) {
*error = ASCIIToUTF16(errors::kInvalidPlugins);
return false;
@@ -1828,14 +1816,14 @@ bool Extension::LoadPlugins(string16* error) {
bool Extension::LoadNaClModules(string16* error) {
if (!manifest_->HasKey(keys::kNaClModules))
return true;
- ListValue* list_value = NULL;
+ const ListValue* list_value = NULL;
if (!manifest_->GetList(keys::kNaClModules, &list_value)) {
*error = ASCIIToUTF16(errors::kInvalidNaClModules);
return false;
}
for (size_t i = 0; i < list_value->GetSize(); ++i) {
- DictionaryValue* module_value = NULL;
+ const DictionaryValue* module_value = NULL;
if (!list_value->GetDictionary(i, &module_value)) {
*error = ASCIIToUTF16(errors::kInvalidNaClModules);
return false;
@@ -1869,7 +1857,7 @@ bool Extension::LoadSandboxedPages(string16* error) {
if (!manifest_->HasPath(keys::kSandboxedPages))
return true;
- ListValue* list_value = NULL;
+ const ListValue* list_value = NULL;
if (!manifest_->GetList(keys::kSandboxedPages, &list_value)) {
*error = ASCIIToUTF16(errors::kInvalidSandboxedPagesList);
return false;
@@ -1920,14 +1908,14 @@ bool Extension::LoadSandboxedPages(string16* error) {
bool Extension::LoadRequirements(string16* error) {
// Before parsing requirements from the manifest, automatically default the
// NPAPI plugin requirement based on whether it includes NPAPI plugins.
- ListValue* list_value = NULL;
+ const ListValue* list_value = NULL;
requirements_.npapi =
manifest_->GetList(keys::kPlugins, &list_value) && !list_value->empty();
if (!manifest_->HasKey(keys::kRequirements))
return true;
- DictionaryValue* requirements_value = NULL;
+ const DictionaryValue* requirements_value = NULL;
if (!manifest_->GetDictionary(keys::kRequirements, &requirements_value)) {
*error = ASCIIToUTF16(errors::kInvalidRequirements);
return false;
@@ -2006,134 +1994,6 @@ bool Extension::LoadOfflineEnabled(string16* error) {
return true;
}
-bool Extension::LoadBackgroundScripts(string16* error) {
- const std::string& key = is_platform_app() ?
- keys::kPlatformAppBackgroundScripts : keys::kBackgroundScripts;
- return LoadBackgroundScripts(key, error);
-}
-
-bool Extension::LoadBackgroundScripts(const std::string& key, string16* error) {
- Value* background_scripts_value = NULL;
- if (!manifest_->Get(key, &background_scripts_value))
- return true;
-
- CHECK(background_scripts_value);
- if (background_scripts_value->GetType() != Value::TYPE_LIST) {
- *error = ASCIIToUTF16(errors::kInvalidBackgroundScripts);
- return false;
- }
-
- ListValue* background_scripts =
- static_cast<ListValue*>(background_scripts_value);
- for (size_t i = 0; i < background_scripts->GetSize(); ++i) {
- std::string script;
- if (!background_scripts->GetString(i, &script)) {
- *error = ErrorUtils::FormatErrorMessageUTF16(
- errors::kInvalidBackgroundScript, base::IntToString(i));
- return false;
- }
- background_scripts_.push_back(script);
- }
-
- return true;
-}
-
-bool Extension::LoadBackgroundPage(string16* error) {
- if (is_platform_app()) {
- return LoadBackgroundPage(keys::kPlatformAppBackgroundPage, error);
- }
-
- if (!LoadBackgroundPage(keys::kBackgroundPage, error))
- return false;
- if (background_url_.is_empty()) {
- return LoadBackgroundPage(
- keys::kBackgroundPageLegacy, error);
- }
- return true;
-}
-
-bool Extension::LoadBackgroundPage(const std::string& key, string16* error) {
- base::Value* background_page_value = NULL;
- if (!manifest_->Get(key, &background_page_value))
- return true;
-
- if (!background_scripts_.empty()) {
- *error = ASCIIToUTF16(errors::kInvalidBackgroundCombination);
- return false;
- }
-
-
- std::string background_str;
- if (!background_page_value->GetAsString(&background_str)) {
- *error = ASCIIToUTF16(errors::kInvalidBackground);
- return false;
- }
-
- if (is_hosted_app()) {
- background_url_ = GURL(background_str);
-
- // Make sure "background" permission is set.
- if (!initial_api_permissions()->count(APIPermission::kBackground)) {
- *error = ASCIIToUTF16(errors::kBackgroundPermissionNeeded);
- return false;
- }
- // Hosted apps require an absolute URL.
- if (!background_url_.is_valid()) {
- *error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp);
- return false;
- }
-
- if (!(background_url_.SchemeIs("https") ||
- (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAllowHTTPBackgroundPage) &&
- background_url_.SchemeIs("http")))) {
- *error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp);
- return false;
- }
- } else {
- background_url_ = GetResourceURL(background_str);
- }
-
- return true;
-}
-
-bool Extension::LoadBackgroundPersistent(string16* error) {
- if (is_platform_app()) {
- background_page_is_persistent_ = false;
- return true;
- }
-
- Value* background_persistent = NULL;
- if (!manifest_->Get(keys::kBackgroundPersistent, &background_persistent))
- return true;
-
- if (!background_persistent->GetAsBoolean(&background_page_is_persistent_)) {
- *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistent);
- return false;
- }
-
- if (!has_background_page()) {
- *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistentNoPage);
- return false;
- }
-
- return true;
-}
-
-bool Extension::LoadBackgroundAllowJSAccess(string16* error) {
- Value* allow_js_access = NULL;
- if (!manifest_->Get(keys::kBackgroundAllowJsAccess, &allow_js_access))
- return true;
-
- if (!allow_js_access->IsType(Value::TYPE_BOOLEAN) ||
- !allow_js_access->GetAsBoolean(&allow_background_js_access_)) {
- *error = ASCIIToUTF16(errors::kInvalidBackgroundAllowJsAccess);
- return false;
- }
-
- return true;
-}
-
bool Extension::LoadExtensionFeatures(string16* error) {
if (manifest_->HasKey(keys::kConvertedFromUserScript))
manifest_->GetBoolean(keys::kConvertedFromUserScript,
@@ -2150,14 +2010,14 @@ bool Extension::LoadExtensionFeatures(string16* error) {
bool Extension::LoadContentScripts(string16* error) {
if (!manifest_->HasKey(keys::kContentScripts))
return true;
- ListValue* list_value;
+ const ListValue* list_value;
if (!manifest_->GetList(keys::kContentScripts, &list_value)) {
*error = ASCIIToUTF16(errors::kInvalidContentScriptsList);
return false;
}
for (size_t i = 0; i < list_value->GetSize(); ++i) {
- DictionaryValue* content_script = NULL;
+ const DictionaryValue* content_script = NULL;
if (!list_value->GetDictionary(i, &content_script)) {
*error = ErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidContentScript, base::IntToString(i));
@@ -2183,7 +2043,7 @@ bool Extension::LoadSystemIndicator(string16* error) {
return true;
}
- DictionaryValue* system_indicator_value = NULL;
+ const DictionaryValue* system_indicator_value = NULL;
if (!manifest_->GetDictionary(keys::kSystemIndicator,
&system_indicator_value)) {
*error = ASCIIToUTF16(errors::kInvalidSystemIndicator);
@@ -2594,7 +2454,7 @@ bool Extension::CheckPlatformAppFeatures(std::string* utf8_error) const {
if (!is_platform_app())
return true;
- if (!has_background_page()) {
+ if (!BackgroundInfo::HasBackgroundPage(this)) {
*utf8_error = errors::kBackgroundRequiredForPlatformApps;
return false;
}
@@ -2608,7 +2468,7 @@ bool Extension::CheckPlatformAppFeatures(std::string* utf8_error) const {
}
bool Extension::CheckConflictingFeatures(std::string* utf8_error) const {
- if (has_lazy_background_page() &&
+ if (BackgroundInfo::HasLazyBackgroundPage(this) &&
HasAPIPermission(APIPermission::kWebRequest)) {
*utf8_error = errors::kWebRequestConflictsWithLazyBackground;
return false;
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index dfb6846..c8755685 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -470,21 +470,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
const std::vector<NaClModuleInfo>& nacl_modules() const {
return nacl_modules_;
}
- bool has_background_page() const {
- return background_url_.is_valid() || !background_scripts_.empty();
- }
- bool allow_background_js_access() const {
- return allow_background_js_access_;
- }
- const std::vector<std::string>& background_scripts() const {
- return background_scripts_;
- }
- bool has_persistent_background_page() const {
- return has_background_page() && background_page_is_persistent_;
- }
- bool has_lazy_background_page() const {
- return has_background_page() && !background_page_is_persistent_;
- }
const PermissionSet* optional_permission_set() const {
return optional_permission_set_.get();
}
@@ -496,6 +481,9 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
APIPermissionSet* initial_api_permissions() {
return initial_api_permissions_.get();
}
+ const APIPermissionSet* initial_api_permissions() const {
+ return initial_api_permissions_.get();
+ }
// Appends |new_warning[s]| to install_warnings_.
void AddInstallWarning(const InstallWarning& new_warning);
void AddInstallWarnings(const std::vector<InstallWarning>& new_warnings);
@@ -542,8 +530,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
bool is_content_pack() const;
ExtensionResource GetContentPackSiteList() const;
- GURL GetBackgroundURL() const;
-
private:
friend class base::RefCountedThreadSafe<Extension>;
@@ -627,13 +613,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// Must be called after LoadPlugins().
bool LoadRequirements(string16* error);
bool LoadOfflineEnabled(string16* error);
- bool LoadBackgroundScripts(string16* error);
- bool LoadBackgroundScripts(const std::string& key, string16* error);
- bool LoadBackgroundPage(string16* error);
- bool LoadBackgroundPage(const std::string& key,
- string16* error);
- bool LoadBackgroundPersistent(string16* error);
- bool LoadBackgroundAllowJSAccess(string16* error);
bool LoadExtensionFeatures(string16* error);
bool LoadContentScripts(string16* error);
bool LoadBrowserAction(string16* error);
@@ -774,24 +753,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// "allow-same-origin" token).
std::string sandboxed_pages_content_security_policy_;
- // Optional URL to a master page of which a single instance should be always
- // loaded in the background.
- GURL background_url_;
-
- // Optional list of scripts to use to generate a background page. If this is
- // present, background_url_ will be empty and generated by GetBackgroundURL().
- std::vector<std::string> background_scripts_;
-
- // True if the background page should stay loaded forever; false if it should
- // load on-demand (when it needs to handle an event). Defaults to true.
- bool background_page_is_persistent_;
-
- // True if the background page can be scripted by pages of the app or
- // extension, in which case all such pages must run in the same process.
- // False if such pages are not permitted to script the background page,
- // allowing them to run in different processes.
- bool allow_background_js_access_;
-
// The public key used to sign the contents of the crx package.
std::string public_key_;
diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc
index dc8791a..7e9d689 100644
--- a/chrome/common/extensions/extension_file_util.cc
+++ b/chrome/common/extensions/extension_file_util.cc
@@ -24,6 +24,7 @@
#include "chrome/common/extensions/api/i18n/default_locale_handler.h"
#include "chrome/common/extensions/api/icons/icons_handler.h"
#include "chrome/common/extensions/api/themes/theme_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_l10n_util.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
@@ -357,13 +358,14 @@ bool ValidateExtension(const Extension* extension,
}
// Validate that background scripts exist.
- for (size_t i = 0; i < extension->background_scripts().size(); ++i) {
+ const std::vector<std::string>& background_scripts =
+ extensions::BackgroundInfo::GetBackgroundScripts(extension);
+ for (size_t i = 0; i < background_scripts.size(); ++i) {
if (!file_util::PathExists(
- extension->GetResource(
- extension->background_scripts()[i]).GetFilePath())) {
+ extension->GetResource(background_scripts[i]).GetFilePath())) {
*error = l10n_util::GetStringFUTF8(
IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED,
- UTF8ToUTF16(extension->background_scripts()[i]));
+ UTF8ToUTF16(background_scripts[i]));
return false;
}
}
@@ -371,11 +373,10 @@ bool ValidateExtension(const Extension* extension,
// Validate background page location, except for hosted apps, which should use
// an external URL. Background page for hosted apps are verified when the
// extension is created (in Extension::InitFromValue)
- if (extension->has_background_page() &&
- !extension->is_hosted_app() &&
- extension->background_scripts().empty()) {
+ if (extensions::BackgroundInfo::HasBackgroundPage(extension) &&
+ !extension->is_hosted_app() && background_scripts.empty()) {
base::FilePath page_path = ExtensionURLToRelativeFilePath(
- extension->GetBackgroundURL());
+ extensions::BackgroundInfo::GetBackgroundURL(extension));
const base::FilePath path = extension->GetResource(page_path).GetFilePath();
if (path.empty() || !file_util::PathExists(path)) {
*error =
diff --git a/chrome/common/extensions/extension_file_util_unittest.cc b/chrome/common/extensions/extension_file_util_unittest.cc
index 0d5da85..96773f0 100644
--- a/chrome/common/extensions/extension_file_util_unittest.cc
+++ b/chrome/common/extensions/extension_file_util_unittest.cc
@@ -15,6 +15,7 @@
#include "chrome/common/extensions/api/extension_action/page_action_handler.h"
#include "chrome/common/extensions/api/i18n/default_locale_handler.h"
#include "chrome/common/extensions/api/icons/icons_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/manifest.h"
@@ -33,21 +34,15 @@ class ExtensionFileUtilTest : public testing::Test {
protected:
virtual void SetUp() OVERRIDE {
testing::Test::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kIcons,
- make_linked_ptr(new extensions::IconsHandler));
- extensions::ManifestHandler::Register(
- keys::kBrowserAction,
- make_linked_ptr(new extensions::BrowserActionHandler));
- linked_ptr<extensions::PageActionHandler> page_action_handler(
- new extensions::PageActionHandler);
- extensions::ManifestHandler::Register(keys::kPageAction,
- page_action_handler);
- extensions::ManifestHandler::Register(keys::kPageActions,
- page_action_handler);
- extensions::ManifestHandler::Register(
- keys::kDefaultLocale,
- make_linked_ptr(new extensions::DefaultLocaleHandler));
+ (new extensions::BackgroundManifestHandler)->Register();
+ (new extensions::BrowserActionHandler)->Register();
+ (new extensions::DefaultLocaleHandler)->Register();
+ (new extensions::IconsHandler)->Register();
+ (new extensions::PageActionHandler)->Register();
+ }
+
+ virtual void TearDown() OVERRIDE {
+ extensions::ManifestHandler::ClearRegistryForTesting();
}
};
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index e4cd7fe..e9a27b5 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -14,6 +14,8 @@
#include "base/utf_string_conversions.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/api/commands/commands_handler.h"
+#include "chrome/common/extensions/api/commands/commands_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/command.h"
#include "chrome/common/extensions/extension_file_util.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
@@ -101,8 +103,12 @@ static scoped_refptr<Extension> LoadManifestStrict(
class ExtensionTest : public testing::Test {
protected:
virtual void SetUp() OVERRIDE {
- ManifestHandler::Register(extension_manifest_keys::kCommands,
- make_linked_ptr(new CommandsHandler));
+ (new BackgroundManifestHandler)->Register();
+ (new CommandsHandler)->Register();
+ }
+
+ virtual void TearDown() OVERRIDE {
+ ManifestHandler::ClearRegistryForTesting();
}
};
diff --git a/chrome/common/extensions/manifest.cc b/chrome/common/extensions/manifest.cc
index 512183e..1aa24fd 100644
--- a/chrome/common/extensions/manifest.cc
+++ b/chrome/common/extensions/manifest.cc
@@ -100,7 +100,7 @@ Manifest::Location Manifest::GetHigherPriorityLocation(
return (loc1_rank > loc2_rank ? loc1 : loc2 );
}
-Manifest::Manifest(Location location, scoped_ptr<DictionaryValue> value)
+Manifest::Manifest(Location location, scoped_ptr<base::DictionaryValue> value)
: location_(location),
value_(value.Pass()),
type_(TYPE_UNKNOWN) {
@@ -158,7 +158,7 @@ void Manifest::ValidateManifest(
}
// Also generate warnings for keys that are not features.
- for (DictionaryValue::key_iterator key = value_->begin_keys();
+ for (base::DictionaryValue::key_iterator key = value_->begin_keys();
key != value_->end_keys(); ++key) {
if (!BaseFeatureProvider::GetManifestFeatures()->GetFeature(*key)) {
warnings->push_back(InstallWarning(
@@ -174,12 +174,12 @@ bool Manifest::HasKey(const std::string& key) const {
}
bool Manifest::HasPath(const std::string& path) const {
- Value* ignored = NULL;
+ base::Value* ignored = NULL;
return CanAccessPath(path) && value_->Get(path, &ignored);
}
bool Manifest::Get(
- const std::string& path, Value** out_value) const {
+ const std::string& path, const base::Value** out_value) const {
return CanAccessPath(path) && value_->Get(path, out_value);
}
@@ -204,28 +204,18 @@ bool Manifest::GetString(
}
bool Manifest::GetDictionary(
- const std::string& path, const DictionaryValue** out_value) const {
- return GetDictionary(path, const_cast<DictionaryValue**>(out_value));
-}
-
-bool Manifest::GetDictionary(
- const std::string& path, DictionaryValue** out_value) const {
+ const std::string& path, const base::DictionaryValue** out_value) const {
return CanAccessPath(path) && value_->GetDictionary(path, out_value);
}
bool Manifest::GetList(
- const std::string& path, const ListValue** out_value) const {
- return GetList(path, const_cast<ListValue**>(out_value));
-}
-
-bool Manifest::GetList(
- const std::string& path, ListValue** out_value) const {
+ const std::string& path, const base::ListValue** out_value) const {
return CanAccessPath(path) && value_->GetList(path, out_value);
}
Manifest* Manifest::DeepCopy() const {
Manifest* manifest = new Manifest(
- location_, scoped_ptr<DictionaryValue>(value_->DeepCopy()));
+ location_, scoped_ptr<base::DictionaryValue>(value_->DeepCopy()));
manifest->set_extension_id(extension_id_);
return manifest;
}
diff --git a/chrome/common/extensions/manifest.h b/chrome/common/extensions/manifest.h
index 1f1f93b..3a92f93 100644
--- a/chrome/common/extensions/manifest.h
+++ b/chrome/common/extensions/manifest.h
@@ -124,18 +124,15 @@ class Manifest {
// does not exist or if the manifest type can't access it.
bool HasKey(const std::string& key) const;
bool HasPath(const std::string& path) const;
- bool Get(const std::string& path, base::Value** out_value) const;
+ bool Get(const std::string& path, const base::Value** out_value) const;
bool GetBoolean(const std::string& path, bool* out_value) const;
bool GetInteger(const std::string& path, int* out_value) const;
bool GetString(const std::string& path, std::string* out_value) const;
bool GetString(const std::string& path, string16* out_value) const;
bool GetDictionary(const std::string& path,
const base::DictionaryValue** out_value) const;
- bool GetDictionary(const std::string& path,
- base::DictionaryValue** out_value) const;
bool GetList(const std::string& path,
const base::ListValue** out_value) const;
- bool GetList(const std::string& path, base::ListValue** out_value) const;
// Returns a new Manifest equal to this one, passing ownership to
// the caller.
diff --git a/chrome/common/extensions/manifest_handler.cc b/chrome/common/extensions/manifest_handler.cc
index 389f4f5..96f138f 100644
--- a/chrome/common/extensions/manifest_handler.cc
+++ b/chrome/common/extensions/manifest_handler.cc
@@ -8,6 +8,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/memory/linked_ptr.h"
#include "base/stl_util.h"
#include "chrome/common/extensions/manifest.h"
@@ -136,9 +137,6 @@ void ManifestHandlerRegistry::SortManifestHandlers() {
static base::LazyInstance<ManifestHandlerRegistry> g_registry =
LAZY_INSTANCE_INITIALIZER;
-static base::LazyInstance<std::vector<std::string> > g_empty_string_vector =
- LAZY_INSTANCE_INITIALIZER;
-
} // namespace
ManifestHandler::ManifestHandler() {
@@ -147,18 +145,24 @@ ManifestHandler::ManifestHandler() {
ManifestHandler::~ManifestHandler() {
}
-bool ManifestHandler::AlwaysParseForType(Manifest::Type type) {
+bool ManifestHandler::AlwaysParseForType(Manifest::Type type) const {
return false;
}
-const std::vector<std::string>& ManifestHandler::PrerequisiteKeys() {
- return g_empty_string_vector.Get();
+const std::vector<std::string> ManifestHandler::PrerequisiteKeys() const {
+ return std::vector<std::string>();
+}
+
+void ManifestHandler::Register() {
+ linked_ptr<ManifestHandler> this_linked(this);
+ const std::vector<std::string> keys = Keys();
+ for (size_t i = 0; i < keys.size(); ++i)
+ g_registry.Get().RegisterManifestHandler(keys[i], this_linked);
}
// static
-void ManifestHandler::Register(const std::string& key,
- linked_ptr<ManifestHandler> handler) {
- g_registry.Get().RegisterManifestHandler(key, handler);
+void ManifestHandler::ClearRegistryForTesting() {
+ g_registry.Get().ClearForTesting();
}
// static
@@ -167,8 +171,9 @@ bool ManifestHandler::ParseExtension(Extension* extension, string16* error) {
}
// static
-void ManifestHandler::ClearRegistryForTesting() {
- g_registry.Get().ClearForTesting();
+const std::vector<std::string> ManifestHandler::SingleKey(
+ const std::string& key) {
+ return std::vector<std::string>(1, key);
}
} // namespace extensions
diff --git a/chrome/common/extensions/manifest_handler.h b/chrome/common/extensions/manifest_handler.h
index 63380c7..6cf0192 100644
--- a/chrome/common/extensions/manifest_handler.h
+++ b/chrome/common/extensions/manifest_handler.h
@@ -7,8 +7,8 @@
#include <set>
#include <string>
+#include <vector>
-#include "base/memory/linked_ptr.h"
#include "base/string16.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/manifest.h"
@@ -31,21 +31,22 @@ class ManifestHandler {
// are present. This allows specifying a default parsed value for
// extensions that don't declare our key in the manifest.
// TODO(yoz): Use Feature availability instead.
- virtual bool AlwaysParseForType(Manifest::Type type);
+ virtual bool AlwaysParseForType(Manifest::Type type) const;
// The list of keys that, if present, should be parsed before calling our
// Parse (typically, because our Parse needs to read those keys).
// Defaults to empty.
- virtual const std::vector<std::string>& PrerequisiteKeys();
+ virtual const std::vector<std::string> PrerequisiteKeys() const;
- // Associate |handler| with |key| in the manifest. A handler can register
- // for multiple keys. The global registry takes ownership of |handler|;
- // if it has an existing handler for |key|, it replaces it with this one.
+ // Associate us with our keys() in the manifest. A handler can register
+ // for multiple keys. The global registry takes ownership of this;
+ // if it has an existing handler for |key|, it replaces it with this.
+ // Typical usage:
+ // (new MyManifestHandler)->Register();
//
// WARNING: Manifest handlers registered only in the browser process
// are not available to renderers or utility processes.
- static void Register(const std::string& key,
- linked_ptr<ManifestHandler> handler);
+ void Register();
// Call Parse on all registered manifest handlers that should parse
// this extension.
@@ -54,6 +55,15 @@ class ManifestHandler {
// Reset the manifest handler registry to an empty state. Useful for
// unit tests.
static void ClearRegistryForTesting();
+
+ protected:
+ // A convenience method for handlers that only register for 1 key,
+ // so that they can define keys() { return SingleKey(kKey); }
+ static const std::vector<std::string> SingleKey(const std::string& key);
+
+ private:
+ // The keys to register us for (in Register).
+ virtual const std::vector<std::string> Keys() const = 0;
};
} // namespace extensions
diff --git a/chrome/common/extensions/manifest_handler_unittest.cc b/chrome/common/extensions/manifest_handler_unittest.cc
index 2cad12e..52694ae 100644
--- a/chrome/common/extensions/manifest_handler_unittest.cc
+++ b/chrome/common/extensions/manifest_handler_unittest.cc
@@ -16,6 +16,14 @@
namespace extensions {
+namespace {
+
+std::vector<std::string> SingleKey(const std::string& key) {
+ return std::vector<std::string>(1, key);
+}
+
+} // namespace
+
class ManifestHandlerTest : public testing::Test {
public:
class ParsingWatcher {
@@ -53,9 +61,10 @@ class ManifestHandlerTest : public testing::Test {
class TestManifestHandler : public ManifestHandler {
public:
TestManifestHandler(const std::string& name,
+ const std::vector<std::string>& keys,
const std::vector<std::string>& prereqs,
ParsingWatcher* watcher)
- : name_(name), prereqs_(prereqs), watcher_(watcher) {
+ : name_(name), keys_(keys), prereqs_(prereqs), watcher_(watcher) {
}
virtual bool Parse(Extension* extension, string16* error) OVERRIDE {
@@ -63,22 +72,29 @@ class ManifestHandlerTest : public testing::Test {
return true;
}
- virtual const std::vector<std::string>& PrerequisiteKeys() OVERRIDE {
+ virtual const std::vector<std::string> PrerequisiteKeys() const OVERRIDE {
return prereqs_;
}
protected:
std::string name_;
+ std::vector<std::string> keys_;
std::vector<std::string> prereqs_;
ParsingWatcher* watcher_;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE {
+ return keys_;
+ }
};
class FailingTestManifestHandler : public TestManifestHandler {
public:
FailingTestManifestHandler(const std::string& name,
- const std::vector<std::string> prereqs,
+ const std::vector<std::string>& keys,
+ const std::vector<std::string>& prereqs,
ParsingWatcher* watcher)
- : TestManifestHandler(name, prereqs, watcher) {
+ : TestManifestHandler(name, keys, prereqs, watcher) {
}
virtual bool Parse(Extension* extension, string16* error) OVERRIDE {
*error = ASCIIToUTF16(name_);
@@ -89,12 +105,13 @@ class ManifestHandlerTest : public testing::Test {
class AlwaysParseTestManifestHandler : public TestManifestHandler {
public:
AlwaysParseTestManifestHandler(const std::string& name,
- const std::vector<std::string> prereqs,
+ const std::vector<std::string>& keys,
+ const std::vector<std::string>& prereqs,
ParsingWatcher* watcher)
- : TestManifestHandler(name, prereqs, watcher) {
+ : TestManifestHandler(name, keys, prereqs, watcher) {
}
- virtual bool AlwaysParseForType(Manifest::Type type) OVERRIDE {
+ virtual bool AlwaysParseForType(Manifest::Type type) const OVERRIDE {
return true;
}
};
@@ -108,26 +125,21 @@ class ManifestHandlerTest : public testing::Test {
TEST_F(ManifestHandlerTest, DependentHandlers) {
ParsingWatcher watcher;
std::vector<std::string> prereqs;
- ManifestHandler::Register(
- "a", make_linked_ptr(new TestManifestHandler("A", prereqs, &watcher)));
- ManifestHandler::Register(
- "b", make_linked_ptr(new TestManifestHandler("B", prereqs, &watcher)));
- ManifestHandler::Register(
- "j", make_linked_ptr(new TestManifestHandler("J", prereqs, &watcher)));
- ManifestHandler::Register(
- "k", make_linked_ptr(
- new AlwaysParseTestManifestHandler("K", prereqs, &watcher)));
+ (new TestManifestHandler("A", SingleKey("a"), prereqs, &watcher))->Register();
+ (new TestManifestHandler("B", SingleKey("b"), prereqs, &watcher))->Register();
+ (new TestManifestHandler("J", SingleKey("j"), prereqs, &watcher))->Register();
+ (new AlwaysParseTestManifestHandler("K", SingleKey("k"), prereqs, &watcher))->
+ Register();
prereqs.push_back("c.d");
- linked_ptr<TestManifestHandler> handler_c2(
- new TestManifestHandler("C.EZ", prereqs, &watcher));
- ManifestHandler::Register("c.e", handler_c2);
- ManifestHandler::Register("c.z", handler_c2);
+ std::vector<std::string> keys;
+ keys.push_back("c.e");
+ keys.push_back("c.z");
+ (new TestManifestHandler("C.EZ", keys, prereqs, &watcher))->Register();
prereqs.clear();
prereqs.push_back("b");
prereqs.push_back("k");
- ManifestHandler::Register(
- "c.d", make_linked_ptr(new TestManifestHandler(
- "C.D", prereqs, &watcher)));
+ (new TestManifestHandler("C.D", SingleKey("c.d"), prereqs, &watcher))->
+ Register();
scoped_refptr<Extension> extension = ExtensionBuilder()
.SetManifest(DictionaryBuilder()
@@ -173,9 +185,8 @@ TEST_F(ManifestHandlerTest, FailingHandlers) {
// Register a handler for "a" that fails.
ParsingWatcher watcher;
- ManifestHandler::Register(
- "a", make_linked_ptr(new FailingTestManifestHandler(
- "A", std::vector<std::string>(), &watcher)));
+ (new FailingTestManifestHandler(
+ "A", SingleKey("a"), std::vector<std::string>(), &watcher))->Register();
extension = Extension::Create(
base::FilePath(),
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc
index e85c9d6..3c9c032 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc
@@ -8,10 +8,12 @@
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/features/base_feature_provider.h"
#include "chrome/common/extensions/features/feature.h"
+#include "chrome/common/extensions/manifest_handler.h"
#include "extensions/common/error_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -20,12 +22,19 @@ namespace keys = extension_manifest_keys;
namespace extensions {
-TEST_F(ExtensionManifestTest, BackgroundPermission) {
+class ExtensionManifestBackgroundTest : public ExtensionManifestTest {
+ virtual void SetUp() OVERRIDE {
+ ExtensionManifestTest::SetUp();
+ (new BackgroundManifestHandler)->Register();
+ }
+};
+
+TEST_F(ExtensionManifestBackgroundTest, BackgroundPermission) {
LoadAndExpectError("background_permission.json",
errors::kBackgroundPermissionNeeded);
}
-TEST_F(ExtensionManifestTest, BackgroundScripts) {
+TEST_F(ExtensionManifestBackgroundTest, BackgroundScripts) {
std::string error;
scoped_ptr<base::DictionaryValue> manifest(
LoadManifest("background_scripts.json", &error));
@@ -34,26 +43,28 @@ TEST_F(ExtensionManifestTest, BackgroundScripts) {
scoped_refptr<Extension> extension(
LoadAndExpectSuccess(Manifest(manifest.get(), "")));
ASSERT_TRUE(extension);
- EXPECT_EQ(2u, extension->background_scripts().size());
- EXPECT_EQ("foo.js", extension->background_scripts()[0u]);
- EXPECT_EQ("bar/baz.js", extension->background_scripts()[1u]);
+ const std::vector<std::string>& background_scripts =
+ BackgroundInfo::GetBackgroundScripts(extension);
+ ASSERT_EQ(2u, background_scripts.size());
+ EXPECT_EQ("foo.js", background_scripts[0u]);
+ EXPECT_EQ("bar/baz.js", background_scripts[1u]);
- EXPECT_TRUE(extension->has_background_page());
+ EXPECT_TRUE(BackgroundInfo::HasBackgroundPage(extension));
EXPECT_EQ(std::string("/") +
extension_filenames::kGeneratedBackgroundPageFilename,
- extension->GetBackgroundURL().path());
+ BackgroundInfo::GetBackgroundURL(extension).path());
manifest->SetString("background_page", "monkey.html");
LoadAndExpectError(Manifest(manifest.get(), ""),
errors::kInvalidBackgroundCombination);
}
-TEST_F(ExtensionManifestTest, BackgroundPage) {
+TEST_F(ExtensionManifestBackgroundTest, BackgroundPage) {
scoped_refptr<Extension> extension(
LoadAndExpectSuccess("background_page.json"));
ASSERT_TRUE(extension);
- EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path());
- EXPECT_TRUE(extension->allow_background_js_access());
+ EXPECT_EQ("/foo.html", BackgroundInfo::GetBackgroundURL(extension).path());
+ EXPECT_TRUE(BackgroundInfo::AllowJSAccess(extension));
std::string error;
scoped_ptr<base::DictionaryValue> manifest(
@@ -61,7 +72,7 @@ TEST_F(ExtensionManifestTest, BackgroundPage) {
ASSERT_TRUE(manifest.get());
extension = LoadAndExpectSuccess(Manifest(manifest.get(), ""));
ASSERT_TRUE(extension);
- EXPECT_EQ("/foo.html", extension->GetBackgroundURL().path());
+ EXPECT_EQ("/foo.html", BackgroundInfo::GetBackgroundURL(extension).path());
manifest->SetInteger(keys::kManifestVersion, 2);
LoadAndExpectWarning(
@@ -69,18 +80,18 @@ TEST_F(ExtensionManifestTest, BackgroundPage) {
"'background_page' requires manifest version of 1 or lower.");
}
-TEST_F(ExtensionManifestTest, BackgroundAllowNoJsAccess) {
+TEST_F(ExtensionManifestBackgroundTest, BackgroundAllowNoJsAccess) {
scoped_refptr<Extension> extension;
extension = LoadAndExpectSuccess("background_allow_no_js_access.json");
ASSERT_TRUE(extension);
- EXPECT_FALSE(extension->allow_background_js_access());
+ EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension));
extension = LoadAndExpectSuccess("background_allow_no_js_access2.json");
ASSERT_TRUE(extension);
- EXPECT_FALSE(extension->allow_background_js_access());
+ EXPECT_FALSE(BackgroundInfo::AllowJSAccess(extension));
}
-TEST_F(ExtensionManifestTest, BackgroundPageWebRequest) {
+TEST_F(ExtensionManifestBackgroundTest, BackgroundPageWebRequest) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
Feature::ScopedCurrentChannel current_channel(
@@ -95,7 +106,7 @@ TEST_F(ExtensionManifestTest, BackgroundPageWebRequest) {
scoped_refptr<Extension> extension(
LoadAndExpectSuccess(Manifest(manifest.get(), "")));
ASSERT_TRUE(extension);
- EXPECT_TRUE(extension->has_lazy_background_page());
+ EXPECT_TRUE(BackgroundInfo::HasLazyBackgroundPage(extension));
base::ListValue* permissions = new base::ListValue();
permissions->Append(new base::StringValue("webRequest"));
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_contentsecuritypolicy_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_contentsecuritypolicy_unittest.cc
index a7bf6ff..b6de930 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_contentsecuritypolicy_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_contentsecuritypolicy_unittest.cc
@@ -13,10 +13,7 @@ namespace errors = extension_manifest_errors;
class ContentSecurityPolicyManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kContentSecurityPolicy,
- make_linked_ptr(new extensions::CSPHandler(false))); // not platform
- // app.
+ (new extensions::CSPHandler(false))->Register(); // not platform app.
}
};
@@ -29,6 +26,5 @@ TEST_F(ContentSecurityPolicyManifestTest, InsecureContentSecurityPolicy) {
Testcase("insecure_contentsecuritypolicy_3.json",
errors::kInsecureContentSecurityPolicy),
};
- RunTestcases(testcases, arraysize(testcases),
- EXPECT_TYPE_ERROR);
+ RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR);
}
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc
index d6ebc78..d06413f 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc
@@ -4,7 +4,6 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -12,9 +11,7 @@
class DevToolsPageManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kDevToolsPage,
- make_linked_ptr(new extensions::DevToolsPageHandler));
+ (new extensions::DevToolsPageHandler)->Register();
}
};
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc
index e3b7bad..6308e2f 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc
@@ -4,7 +4,6 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,12 +14,8 @@ namespace errors = extension_manifest_errors;
class HomepageURLManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kHomepageURL,
- make_linked_ptr(new extensions::HomepageURLHandler));
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kUpdateURL,
- make_linked_ptr(new extensions::UpdateURLHandler));
+ (new extensions::HomepageURLHandler)->Register();
+ (new extensions::UpdateURLHandler)->Register();
}
};
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc
index 1efc029..9dc40e4 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc
@@ -30,19 +30,10 @@ class InitValueManifestTest : public ExtensionManifestTest {
protected:
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- ManifestHandler::Register(extension_manifest_keys::kIcons,
- make_linked_ptr(new IconsHandler));
- extensions::ManifestHandler::Register(
- keys::kOptionsPage,
- make_linked_ptr(new extensions::OptionsPageHandler));
- extensions::ManifestHandler::Register(
- keys::kDefaultLocale,
- make_linked_ptr(new extensions::DefaultLocaleHandler));
- linked_ptr<extensions::PageActionHandler> page_action_handler(
- new extensions::PageActionHandler);
- extensions::ManifestHandler::Register(keys::kPageAction, page_action_handler);
- extensions::ManifestHandler::Register(
- keys::kPageActions, page_action_handler);
+ (new extensions::DefaultLocaleHandler)->Register();
+ (new extensions::IconsHandler)->Register();
+ (new extensions::OptionsPageHandler)->Register();
+ (new extensions::PageActionHandler)->Register();
}
};
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_offline_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_offline_unittest.cc
index 14384f8..64906e4 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_offline_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_offline_unittest.cc
@@ -2,17 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
-
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "testing/gtest/include/gtest/gtest.h"
using extensions::Extension;
namespace errors = extension_manifest_errors;
-TEST_F(ExtensionManifestTest, OfflineEnabled) {
+namespace extensions {
+
+class ExtensionManifestOfflineEnabledTest : public ExtensionManifestTest {
+ virtual void SetUp() OVERRIDE {
+ ExtensionManifestTest::SetUp();
+ (new BackgroundManifestHandler)->Register();
+ }
+};
+
+TEST_F(ExtensionManifestOfflineEnabledTest, OfflineEnabled) {
LoadAndExpectError("offline_enabled_invalid.json",
errors::kInvalidOfflineEnabled);
scoped_refptr<Extension> extension_0(
@@ -34,3 +43,5 @@ TEST_F(ExtensionManifestTest, OfflineEnabled) {
LoadAndExpectSuccess("offline_default_platform_app.json"));
EXPECT_TRUE(extension_5->offline_enabled());
}
+
+} // namespace extensions
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc
index f90d361..6d2728e 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -13,9 +12,7 @@ namespace errors = extension_manifest_errors;
class OptionsPageManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kOptionsPage,
- make_linked_ptr(new extensions::OptionsPageHandler));
+ (new extensions::OptionsPageHandler)->Register();
}
};
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc
index ac235c2..78f077a 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -13,9 +12,7 @@ namespace errors = extension_manifest_errors;
class URLOverridesManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kChromeURLOverrides,
- make_linked_ptr(new extensions::URLOverridesHandler));
+ (new extensions::URLOverridesHandler)->Register();
}
};
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
index b3a9a4c9..fc0d158 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
@@ -6,6 +6,7 @@
#include "base/json/json_file_value_serializer.h"
#include "base/memory/linked_ptr.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/csp_handler.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
@@ -13,12 +14,12 @@
namespace errors = extension_manifest_errors;
+namespace extensions {
+
class PlatformAppsManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
- ExtensionManifestTest::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kPlatformAppContentSecurityPolicy,
- make_linked_ptr(new extensions::CSPHandler(true))); // platform app.
+ (new BackgroundManifestHandler)->Register();
+ (new CSPHandler(true))->Register(); // platform app.
}
};
@@ -141,3 +142,5 @@ TEST_F(PlatformAppsManifestTest, CertainApisRequirePlatformApps) {
LoadAndExpectSuccess(Manifest(manifests[i].get(), ""));
}
}
+
+} // namespace extensions
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc
index 87e7dd1..eaa4593 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_sandboxed_unittest.cc
@@ -15,10 +15,7 @@ namespace errors = extension_manifest_errors;
class SandboxedPagesManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kContentSecurityPolicy,
- make_linked_ptr(new extensions::CSPHandler(false))); // not platform
- // app.
+ (new extensions::CSPHandler(false))->Register(); // Not platform app.
}
};
@@ -78,5 +75,3 @@ TEST_F(SandboxedPagesManifestTest, SandboxedPages) {
RunTestcases(testcases, arraysize(testcases),
EXPECT_TYPE_ERROR);
}
-
-
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_ui_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_ui_unittest.cc
index 3cb9e90..48381fc 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_ui_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_ui_unittest.cc
@@ -5,7 +5,6 @@
#include "chrome/common/extensions/api/extension_action/browser_action_handler.h"
#include "chrome/common/extensions/api/extension_action/page_action_handler.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -14,14 +13,8 @@ namespace extensions {
class UIManifestTest : public ExtensionManifestTest {
protected:
virtual void SetUp() OVERRIDE {
- ManifestHandler::Register(extension_manifest_keys::kBrowserAction,
- make_linked_ptr(new BrowserActionHandler));
- linked_ptr<extensions::PageActionHandler> page_action_handler(
- new extensions::PageActionHandler);
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kPageAction, page_action_handler);
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kPageActions, page_action_handler);
+ (new BrowserActionHandler)->Register();
+ (new extensions::PageActionHandler)->Register();
}
};
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_update_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_update_unittest.cc
index b2e5440..2eb3ffd 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_update_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_update_unittest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,9 +14,7 @@ namespace errors = extension_manifest_errors;
class UpdateURLManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kUpdateURL,
- make_linked_ptr(new extensions::UpdateURLHandler));
+ (new extensions::UpdateURLHandler)->Register();
}
};
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc
index bcdb9c9..692fc7f 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "chrome/common/extensions/web_accessible_resources_handler.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -14,9 +13,7 @@ using extensions::WebAccessibleResourcesInfo;
class WebAccessibleResourcesManifestTest : public ExtensionManifestTest {
virtual void SetUp() OVERRIDE {
ExtensionManifestTest::SetUp();
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kWebAccessibleResources,
- make_linked_ptr(new extensions::WebAccessibleResourcesHandler));
+ (new extensions::WebAccessibleResourcesHandler)->Register();
}
};
diff --git a/chrome/common/extensions/manifest_unittest.cc b/chrome/common/extensions/manifest_unittest.cc
index 5fd0f02..3f5be68 100644
--- a/chrome/common/extensions/manifest_unittest.cc
+++ b/chrome/common/extensions/manifest_unittest.cc
@@ -181,7 +181,7 @@ TEST_F(ManifestTest, RestrictedKeys) {
MutateManifest(
&manifest, keys::kPageAction, new base::DictionaryValue());
AssertType(manifest.get(), Manifest::TYPE_EXTENSION);
- base::Value* output = NULL;
+ const base::Value* output = NULL;
EXPECT_TRUE(manifest->HasKey(keys::kPageAction));
EXPECT_TRUE(manifest->Get(keys::kPageAction, &output));
diff --git a/chrome/common/extensions/manifest_url_handler.cc b/chrome/common/extensions/manifest_url_handler.cc
index e1f158c..1d3d14c 100644
--- a/chrome/common/extensions/manifest_url_handler.cc
+++ b/chrome/common/extensions/manifest_url_handler.cc
@@ -103,6 +103,10 @@ bool DevToolsPageHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> DevToolsPageHandler::Keys() const {
+ return SingleKey(keys::kDevToolsPage);
+}
+
HomepageURLHandler::HomepageURLHandler() {
}
@@ -130,6 +134,10 @@ bool HomepageURLHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> HomepageURLHandler::Keys() const {
+ return SingleKey(keys::kHomepageURL);
+}
+
UpdateURLHandler::UpdateURLHandler() {
}
@@ -158,6 +166,10 @@ bool UpdateURLHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> UpdateURLHandler::Keys() const {
+ return SingleKey(keys::kUpdateURL);
+}
+
OptionsPageHandler::OptionsPageHandler() {
}
@@ -198,6 +210,10 @@ bool OptionsPageHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> OptionsPageHandler::Keys() const {
+ return SingleKey(keys::kOptionsPage);
+}
+
URLOverridesHandler::URLOverridesHandler() {
}
@@ -263,4 +279,8 @@ bool URLOverridesHandler::Parse(Extension* extension, string16* error) {
return true;
}
+const std::vector<std::string> URLOverridesHandler::Keys() const {
+ return SingleKey(keys::kChromeURLOverrides);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/manifest_url_handler.h b/chrome/common/extensions/manifest_url_handler.h
index 249542b..37cc4ae 100644
--- a/chrome/common/extensions/manifest_url_handler.h
+++ b/chrome/common/extensions/manifest_url_handler.h
@@ -60,6 +60,11 @@ class DevToolsPageHandler : public ManifestHandler {
virtual ~DevToolsPageHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsPageHandler);
};
// Parses the "homepage_url" manifest key.
@@ -69,6 +74,11 @@ class HomepageURLHandler : public ManifestHandler {
virtual ~HomepageURLHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(HomepageURLHandler);
};
// Parses the "update_url" manifest key.
@@ -78,6 +88,11 @@ class UpdateURLHandler : public ManifestHandler {
virtual ~UpdateURLHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(UpdateURLHandler);
};
// Parses the "options_page" manifest key.
@@ -87,6 +102,11 @@ class OptionsPageHandler : public ManifestHandler {
virtual ~OptionsPageHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(OptionsPageHandler);
};
// Parses the "chrome_url_overrides" manifest key.
@@ -96,6 +116,11 @@ class URLOverridesHandler : public ManifestHandler {
virtual ~URLOverridesHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(URLOverridesHandler);
};
} // namespace extensions
diff --git a/chrome/common/extensions/permissions/permission_set_unittest.cc b/chrome/common/extensions/permissions/permission_set_unittest.cc
index 72d39a9..695f89a9 100644
--- a/chrome/common/extensions/permissions/permission_set_unittest.cc
+++ b/chrome/common/extensions/permissions/permission_set_unittest.cc
@@ -9,6 +9,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/features/feature.h"
@@ -81,10 +82,13 @@ bool Contains(const std::vector<string16>& warnings,
class PermissionsTest : public testing::Test {
+ virtual void SetUp() OVERRIDE {
+ (new BackgroundManifestHandler)->Register();
+ }
};
// Tests GetByID.
-TEST(PermissionsTest, GetByID) {
+TEST_F(PermissionsTest, GetByID) {
PermissionsInfo* info = PermissionsInfo::GetInstance();
APIPermissionSet apis = info->GetAll();
for (APIPermissionSet::const_iterator i = apis.begin();
@@ -94,7 +98,7 @@ TEST(PermissionsTest, GetByID) {
}
// Tests that GetByName works with normal permission names and aliases.
-TEST(PermissionsTest, GetByName) {
+TEST_F(PermissionsTest, GetByName) {
PermissionsInfo* info = PermissionsInfo::GetInstance();
EXPECT_EQ(APIPermission::kTab, info->GetByName("tabs")->id());
EXPECT_EQ(APIPermission::kManagement,
@@ -102,7 +106,7 @@ TEST(PermissionsTest, GetByName) {
EXPECT_FALSE(info->GetByName("alsdkfjasldkfj"));
}
-TEST(PermissionsTest, GetAll) {
+TEST_F(PermissionsTest, GetAll) {
size_t count = 0;
PermissionsInfo* info = PermissionsInfo::GetInstance();
APIPermissionSet apis = info->GetAll();
@@ -116,7 +120,7 @@ TEST(PermissionsTest, GetAll) {
EXPECT_EQ(count, info->get_permission_count());
}
-TEST(PermissionsTest, GetAllByName) {
+TEST_F(PermissionsTest, GetAllByName) {
std::set<std::string> names;
names.insert("background");
names.insert("management");
@@ -137,7 +141,7 @@ TEST(PermissionsTest, GetAllByName) {
}
// Tests that the aliases are properly mapped.
-TEST(PermissionsTest, Aliases) {
+TEST_F(PermissionsTest, Aliases) {
PermissionsInfo* info = PermissionsInfo::GetInstance();
// tabs: tabs, windows
std::string tabs_name = "tabs";
@@ -155,7 +159,7 @@ TEST(PermissionsTest, Aliases) {
info->GetByName("unlimited_storage")->id());
}
-TEST(PermissionsTest, EffectiveHostPermissions) {
+TEST_F(PermissionsTest, EffectiveHostPermissions) {
scoped_refptr<Extension> extension;
scoped_refptr<const PermissionSet> permissions;
@@ -231,7 +235,7 @@ TEST(PermissionsTest, EffectiveHostPermissions) {
EXPECT_TRUE(permissions->HasEffectiveAccessToAllHosts());
}
-TEST(PermissionsTest, ExplicitAccessToOrigin) {
+TEST_F(PermissionsTest, ExplicitAccessToOrigin) {
APIPermissionSet apis;
URLPatternSet explicit_hosts;
URLPatternSet scriptable_hosts;
@@ -254,7 +258,7 @@ TEST(PermissionsTest, ExplicitAccessToOrigin) {
GURL("http://test.example.com")));
}
-TEST(PermissionsTest, CreateUnion) {
+TEST_F(PermissionsTest, CreateUnion) {
APIPermission* permission = NULL;
APIPermissionSet apis1;
@@ -378,7 +382,7 @@ TEST(PermissionsTest, CreateUnion) {
EXPECT_EQ(effective_hosts, union_set->effective_hosts());
}
-TEST(PermissionsTest, CreateIntersection) {
+TEST_F(PermissionsTest, CreateIntersection) {
APIPermission* permission = NULL;
APIPermissionSet apis1;
@@ -492,7 +496,7 @@ TEST(PermissionsTest, CreateIntersection) {
EXPECT_EQ(effective_hosts, new_set->effective_hosts());
}
-TEST(PermissionsTest, CreateDifference) {
+TEST_F(PermissionsTest, CreateDifference) {
APIPermission* permission = NULL;
APIPermissionSet apis1;
@@ -593,7 +597,7 @@ TEST(PermissionsTest, CreateDifference) {
EXPECT_TRUE(set1->IsEmpty());
}
-TEST(PermissionsTest, HasLessPrivilegesThan) {
+TEST_F(PermissionsTest, HasLessPrivilegesThan) {
const struct {
const char* base_name;
bool expect_increase;
@@ -644,7 +648,7 @@ TEST(PermissionsTest, HasLessPrivilegesThan) {
}
}
-TEST(PermissionsTest, PermissionMessages) {
+TEST_F(PermissionsTest, PermissionMessages) {
// Ensure that all permissions that needs to show install UI actually have
// strings associated with them.
APIPermissionSet skip;
@@ -763,7 +767,7 @@ TEST(PermissionsTest, PermissionMessages) {
}
// Tests the default permissions (empty API permission set).
-TEST(PermissionsTest, DefaultFunctionAccess) {
+TEST_F(PermissionsTest, DefaultFunctionAccess) {
const struct {
const char* permission_name;
bool expect_success;
@@ -802,7 +806,7 @@ TEST(PermissionsTest, DefaultFunctionAccess) {
}
// Tests the default permissions (empty API permission set).
-TEST(PermissionsTest, DefaultAnyAPIAccess) {
+TEST_F(PermissionsTest, DefaultAnyAPIAccess) {
const struct {
const char* api_name;
bool expect_success;
@@ -833,7 +837,7 @@ TEST(PermissionsTest, DefaultAnyAPIAccess) {
}
}
-TEST(PermissionsTest, GetWarningMessages_ManyHosts) {
+TEST_F(PermissionsTest, GetWarningMessages_ManyHosts) {
scoped_refptr<Extension> extension;
extension = LoadManifest("permissions", "many-hosts.json");
@@ -843,7 +847,7 @@ TEST(PermissionsTest, GetWarningMessages_ManyHosts) {
UTF16ToUTF8(warnings[0]));
}
-TEST(PermissionsTest, GetWarningMessages_Plugins) {
+TEST_F(PermissionsTest, GetWarningMessages_Plugins) {
scoped_refptr<Extension> extension;
scoped_refptr<PermissionSet> permissions;
@@ -860,7 +864,7 @@ TEST(PermissionsTest, GetWarningMessages_Plugins) {
#endif
}
-TEST(PermissionsTest, GetWarningMessages_AudioVideo) {
+TEST_F(PermissionsTest, GetWarningMessages_AudioVideo) {
// Both audio and video present.
scoped_refptr<Extension> extension =
LoadManifest("permissions", "audio-video.json");
@@ -893,7 +897,7 @@ TEST(PermissionsTest, GetWarningMessages_AudioVideo) {
EXPECT_TRUE(Contains(warnings, "Use your camera"));
}
-TEST(PermissionsTest, GetWarningMessages_Serial) {
+TEST_F(PermissionsTest, GetWarningMessages_Serial) {
scoped_refptr<Extension> extension =
LoadManifest("permissions", "serial.json");
@@ -905,7 +909,7 @@ TEST(PermissionsTest, GetWarningMessages_Serial) {
ASSERT_EQ(1u, warnings.size());
}
-TEST(PermissionsTest, GetWarningMessages_Socket_AnyHost) {
+TEST_F(PermissionsTest, GetWarningMessages_Socket_AnyHost) {
extensions::Feature::ScopedCurrentChannel channel(
chrome::VersionInfo::CHANNEL_DEV);
@@ -919,7 +923,7 @@ TEST(PermissionsTest, GetWarningMessages_Socket_AnyHost) {
"on the local network or internet"));
}
-TEST(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) {
+TEST_F(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) {
extensions::Feature::ScopedCurrentChannel channel(
chrome::VersionInfo::CHANNEL_DEV);
@@ -945,7 +949,7 @@ TEST(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) {
// "\xC3\xA5" = UTF-8 for lowercase A with ring above
}
-TEST(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) {
+TEST_F(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) {
extensions::Feature::ScopedCurrentChannel channel(
chrome::VersionInfo::CHANNEL_DEV);
@@ -969,7 +973,7 @@ TEST(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) {
"bar.example.org"));
}
-TEST(PermissionsTest, GetWarningMessages_PlatformApppHosts) {
+TEST_F(PermissionsTest, GetWarningMessages_PlatformApppHosts) {
scoped_refptr<Extension> extension;
extension = LoadManifest("permissions", "platform_app_hosts.json");
@@ -983,7 +987,7 @@ TEST(PermissionsTest, GetWarningMessages_PlatformApppHosts) {
ASSERT_EQ(0u, warnings.size());
}
-TEST(PermissionsTest, GetDistinctHostsForDisplay) {
+TEST_F(PermissionsTest, GetDistinctHostsForDisplay) {
scoped_refptr<PermissionSet> perm_set;
APIPermissionSet empty_perms;
std::set<std::string> expected;
@@ -1139,7 +1143,7 @@ TEST(PermissionsTest, GetDistinctHostsForDisplay) {
}
}
-TEST(PermissionsTest, GetDistinctHostsForDisplay_ComIsBestRcd) {
+TEST_F(PermissionsTest, GetDistinctHostsForDisplay_ComIsBestRcd) {
scoped_refptr<PermissionSet> perm_set;
APIPermissionSet empty_perms;
URLPatternSet explicit_hosts;
@@ -1164,7 +1168,7 @@ TEST(PermissionsTest, GetDistinctHostsForDisplay_ComIsBestRcd) {
EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
}
-TEST(PermissionsTest, GetDistinctHostsForDisplay_NetIs2ndBestRcd) {
+TEST_F(PermissionsTest, GetDistinctHostsForDisplay_NetIs2ndBestRcd) {
scoped_refptr<PermissionSet> perm_set;
APIPermissionSet empty_perms;
URLPatternSet explicit_hosts;
@@ -1188,7 +1192,7 @@ TEST(PermissionsTest, GetDistinctHostsForDisplay_NetIs2ndBestRcd) {
EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
}
-TEST(PermissionsTest,
+TEST_F(PermissionsTest,
GetDistinctHostsForDisplay_OrgIs3rdBestRcd) {
scoped_refptr<PermissionSet> perm_set;
APIPermissionSet empty_perms;
@@ -1212,7 +1216,7 @@ TEST(PermissionsTest,
EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
}
-TEST(PermissionsTest,
+TEST_F(PermissionsTest,
GetDistinctHostsForDisplay_FirstInListIs4thBestRcd) {
scoped_refptr<PermissionSet> perm_set;
APIPermissionSet empty_perms;
@@ -1235,7 +1239,7 @@ TEST(PermissionsTest,
EXPECT_EQ(expected, perm_set->GetDistinctHostsForDisplay());
}
-TEST(PermissionsTest, HasLessHostPrivilegesThan) {
+TEST_F(PermissionsTest, HasLessHostPrivilegesThan) {
URLPatternSet elist1;
URLPatternSet elist2;
URLPatternSet slist1;
@@ -1304,7 +1308,7 @@ TEST(PermissionsTest, HasLessHostPrivilegesThan) {
EXPECT_TRUE(set2->HasLessHostPrivilegesThan(set1.get()));
}
-TEST(PermissionsTest, GetAPIsAsStrings) {
+TEST_F(PermissionsTest, GetAPIsAsStrings) {
APIPermissionSet apis;
URLPatternSet empty_set;
@@ -1324,7 +1328,7 @@ TEST(PermissionsTest, GetAPIsAsStrings) {
PermissionsInfo::GetInstance()->GetAllByName(api_names));
}
-TEST(PermissionsTest, IsEmpty) {
+TEST_F(PermissionsTest, IsEmpty) {
APIPermissionSet empty_apis;
URLPatternSet empty_extent;
@@ -1354,7 +1358,7 @@ TEST(PermissionsTest, IsEmpty) {
EXPECT_FALSE(perm_set->IsEmpty());
}
-TEST(PermissionsTest, ImpliedPermissions) {
+TEST_F(PermissionsTest, ImpliedPermissions) {
URLPatternSet empty_extent;
APIPermissionSet apis;
apis.insert(APIPermission::kWebRequest);
diff --git a/chrome/common/extensions/unpacker_unittest.cc b/chrome/common/extensions/unpacker_unittest.cc
index 327088f..a2d6092 100644
--- a/chrome/common/extensions/unpacker_unittest.cc
+++ b/chrome/common/extensions/unpacker_unittest.cc
@@ -35,12 +35,12 @@ public:
virtual void SetUp() OVERRIDE {
testing::Test::SetUp();
- extensions::ManifestHandler::Register(
- keys::kDefaultLocale,
- make_linked_ptr(new extensions::DefaultLocaleHandler));
- extensions::ManifestHandler::Register(
- keys::kTheme,
- make_linked_ptr(new extensions::ThemeHandler));
+ (new DefaultLocaleHandler)->Register();
+ (new ThemeHandler)->Register();
+ }
+
+ virtual void TearDown() OVERRIDE {
+ ManifestHandler::ClearRegistryForTesting();
}
void SetupUnpacker(const std::string& crx_name) {
diff --git a/chrome/common/extensions/web_accessible_resources_handler.cc b/chrome/common/extensions/web_accessible_resources_handler.cc
index fede033..ab39798 100644
--- a/chrome/common/extensions/web_accessible_resources_handler.cc
+++ b/chrome/common/extensions/web_accessible_resources_handler.cc
@@ -92,4 +92,8 @@ bool WebAccessibleResourcesHandler::Parse(Extension* extension,
return true;
}
+const std::vector<std::string> WebAccessibleResourcesHandler::Keys() const {
+ return SingleKey(keys::kWebAccessibleResources);
+}
+
} // namespace extensions
diff --git a/chrome/common/extensions/web_accessible_resources_handler.h b/chrome/common/extensions/web_accessible_resources_handler.h
index 377ffbc..4a12089 100644
--- a/chrome/common/extensions/web_accessible_resources_handler.h
+++ b/chrome/common/extensions/web_accessible_resources_handler.h
@@ -38,6 +38,11 @@ class WebAccessibleResourcesHandler : public ManifestHandler {
virtual ~WebAccessibleResourcesHandler();
virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(WebAccessibleResourcesHandler);
};
} // namespace extensions
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 0a28d0f..ffdb474 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -19,6 +19,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/content_settings_pattern.h"
#include "chrome/common/extensions/api/extension_action/page_action_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/csp_handler.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -130,24 +131,12 @@ namespace {
// Explicitly register all extension ManifestHandlers needed to parse
// fields used in the renderer.
void RegisterExtensionManifestHandlers() {
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kDevToolsPage,
- make_linked_ptr(new extensions::DevToolsPageHandler));
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kWebAccessibleResources,
- make_linked_ptr(new extensions::WebAccessibleResourcesHandler));
- linked_ptr<extensions::PageActionHandler> page_action_handler(
- new extensions::PageActionHandler);
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kPageAction, page_action_handler);
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kPageActions, page_action_handler);
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kContentSecurityPolicy,
- make_linked_ptr(new extensions::CSPHandler(false))); // not platform app.
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kPlatformAppContentSecurityPolicy,
- make_linked_ptr(new extensions::CSPHandler(true))); // platform app.
+ (new extensions::BackgroundManifestHandler)->Register();
+ (new extensions::DevToolsPageHandler)->Register();
+ (new extensions::WebAccessibleResourcesHandler)->Register();
+ (new extensions::PageActionHandler)->Register();
+ (new extensions::CSPHandler(false))->Register(); // not platform app.
+ (new extensions::CSPHandler(true))->Register(); // platform app.
}
static void AppendParams(const std::vector<string16>& additional_names,
diff --git a/chrome/renderer/extensions/dispatcher.cc b/chrome/renderer/extensions/dispatcher.cc
index 930cb5d..ea7a76b 100644
--- a/chrome/renderer/extensions/dispatcher.cc
+++ b/chrome/renderer/extensions/dispatcher.cc
@@ -12,6 +12,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/api/extension_api.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/manifest.h"
@@ -168,7 +169,7 @@ class LazyBackgroundPageNativeHandler : public ChromeV8Extension {
return false;
ExtensionHelper* helper = ExtensionHelper::Get(render_view);
- return (extension && extension->has_lazy_background_page() &&
+ return (extension && BackgroundInfo::HasLazyBackgroundPage(extension) &&
helper->view_type() == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
}
};
@@ -447,7 +448,7 @@ void Dispatcher::OnMessageInvoke(const std::string& extension_id,
// Tell the browser process when an event has been dispatched with a lazy
// background page active.
const Extension* extension = extensions_.GetByID(extension_id);
- if (extension && extension->has_lazy_background_page() &&
+ if (extension && BackgroundInfo::HasLazyBackgroundPage(extension) &&
function_name == kEventDispatchFunction) {
RenderView* background_view =
ExtensionHelper::GetBackgroundPage(extension_id);
@@ -784,7 +785,7 @@ void Dispatcher::DidCreateScriptContext(
int manifest_version = extension ? extension->manifest_version() : 1;
bool send_request_disabled =
(extension && Manifest::IsUnpackedLocation(extension->location()) &&
- extension->has_lazy_background_page());
+ BackgroundInfo::HasLazyBackgroundPage(extension));
module_system->RegisterNativeHandler("process",
scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler(
this, context->GetExtensionID(),
diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc
index 01b84a1..12435a5 100644
--- a/chrome/renderer/extensions/event_bindings.cc
+++ b/chrome/renderer/extensions/event_bindings.cc
@@ -11,6 +11,8 @@
#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
+#include "chrome/common/extensions/background_info.h"
+#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/extensions/value_counter.h"
@@ -40,7 +42,6 @@ using WebKit::WebFrame;
using WebKit::WebSecurityOrigin;
using WebKit::WebURL;
using content::RenderThread;
-using extensions::Extension;
namespace extensions {
@@ -59,15 +60,14 @@ base::LazyInstance<std::map<std::string, EventListenerCounts> >
// track of which filters are in effect for which events.
// We notify the browser about filtered event listeners when we transition
// between 0 and 1.
-typedef std::map<std::string, linked_ptr<extensions::ValueCounter> >
+typedef std::map<std::string, linked_ptr<ValueCounter> >
FilteredEventListenerCounts;
// A map of extension IDs to filtered listener counts for that extension.
base::LazyInstance<std::map<std::string, FilteredEventListenerCounts> >
g_filtered_listener_counts = LAZY_INSTANCE_INITIALIZER;
-base::LazyInstance<extensions::EventFilter> g_event_filter =
- LAZY_INSTANCE_INITIALIZER;
+base::LazyInstance<EventFilter> g_event_filter = LAZY_INSTANCE_INITIALIZER;
// TODO(koz): Merge this into EventBindings.
class ExtensionImpl : public ChromeV8Extension {
@@ -198,7 +198,7 @@ class ExtensionImpl : public ChromeV8Extension {
}
filter.reset(filter_dict);
- extensions::EventFilter& event_filter = g_event_filter.Get();
+ EventFilter& event_filter = g_event_filter.Get();
int id = event_filter.AddEventMatcher(event_name, ParseEventMatcher(
filter.get()));
@@ -222,7 +222,7 @@ class ExtensionImpl : public ChromeV8Extension {
g_filtered_listener_counts.Get()[extension_id];
FilteredEventListenerCounts::iterator it = counts.find(event_name);
if (it == counts.end())
- counts[event_name].reset(new extensions::ValueCounter);
+ counts[event_name].reset(new ValueCounter);
int result = counts[event_name]->Add(*filter);
return 1 == result;
@@ -262,8 +262,8 @@ class ExtensionImpl : public ChromeV8Extension {
return v8::Undefined();
int matcher_id = args[0]->Int32Value();
- extensions::EventFilter& event_filter = g_event_filter.Get();
- extensions::EventMatcher* event_matcher =
+ EventFilter& event_filter = g_event_filter.Get();
+ EventMatcher* event_matcher =
event_filter.GetEventMatcher(matcher_id);
const std::string& event_name = event_filter.GetEventName(matcher_id);
@@ -284,11 +284,11 @@ class ExtensionImpl : public ChromeV8Extension {
static v8::Handle<v8::Value> MatchAgainstEventFilter(
const v8::Arguments& args) {
- typedef std::set<extensions::EventFilter::MatcherID> MatcherIDs;
+ typedef std::set<EventFilter::MatcherID> MatcherIDs;
- extensions::EventFilter& event_filter = g_event_filter.Get();
+ EventFilter& event_filter = g_event_filter.Get();
std::string event_name = *v8::String::AsciiValue(args[0]->ToString());
- extensions::EventFilteringInfo info = ParseFromObject(args[1]->ToObject());
+ EventFilteringInfo info = ParseFromObject(args[1]->ToObject());
MatcherIDs matched_event_filters = event_filter.MatchEvent(
event_name, info);
v8::Handle<v8::Array> array(v8::Array::New(matched_event_filters.size()));
@@ -300,9 +300,8 @@ class ExtensionImpl : public ChromeV8Extension {
return array;
}
- static extensions::EventFilteringInfo ParseFromObject(
- v8::Handle<v8::Object> object) {
- extensions::EventFilteringInfo info;
+ static EventFilteringInfo ParseFromObject(v8::Handle<v8::Object> object) {
+ EventFilteringInfo info;
v8::Handle<v8::String> url(v8::String::New("url"));
if (object->Has(url)) {
v8::Handle<v8::Value> url_value(object->Get(url));
@@ -318,13 +317,13 @@ class ExtensionImpl : public ChromeV8Extension {
return false;
ExtensionHelper* helper = ExtensionHelper::Get(render_view);
- return (extension && extension->has_lazy_background_page() &&
+ return (extension && BackgroundInfo::HasLazyBackgroundPage(extension) &&
helper->view_type() == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
}
- static scoped_ptr<extensions::EventMatcher> ParseEventMatcher(
+ static scoped_ptr<EventMatcher> ParseEventMatcher(
base::DictionaryValue* filter_dict) {
- return scoped_ptr<extensions::EventMatcher>(new extensions::EventMatcher(
+ return scoped_ptr<EventMatcher>(new EventMatcher(
scoped_ptr<base::DictionaryValue>(filter_dict->DeepCopy())));
}
};
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc
index d2287b7..c135677 100644
--- a/chrome/utility/chrome_content_utility_client.cc
+++ b/chrome/utility/chrome_content_utility_client.cc
@@ -22,11 +22,10 @@
#include "chrome/common/extensions/api/i18n/default_locale_handler.h"
#include "chrome/common/extensions/api/icons/icons_handler.h"
#include "chrome/common/extensions/api/themes/theme_handler.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_l10n_util.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/manifest.h"
-#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/unpacker.h"
#include "chrome/common/extensions/update_manifest.h"
#include "chrome/common/safe_browsing/zip_analyzer.h"
@@ -55,24 +54,12 @@ namespace {
// Explicitly register all ManifestHandlers needed in the utility process.
void RegisterExtensionManifestHandlers() {
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kBrowserAction,
- make_linked_ptr(new extensions::BrowserActionHandler));
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kDefaultLocale,
- make_linked_ptr(new extensions::DefaultLocaleHandler));
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kIcons,
- make_linked_ptr(new extensions::IconsHandler));
- linked_ptr<extensions::PageActionHandler> page_action_handler(
- new extensions::PageActionHandler);
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kPageAction, page_action_handler);
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kPageActions, page_action_handler);
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kTheme,
- make_linked_ptr(new extensions::ThemeHandler));
+ (new extensions::BackgroundManifestHandler)->Register();
+ (new extensions::BrowserActionHandler)->Register();
+ (new extensions::DefaultLocaleHandler)->Register();
+ (new extensions::IconsHandler)->Register();
+ (new extensions::PageActionHandler)->Register();
+ (new extensions::ThemeHandler)->Register();
}
} // namespace