diff options
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/extensions/extension.cc | 29 | ||||
-rw-r--r-- | chrome/common/extensions/extension_constants.cc | 16 | ||||
-rw-r--r-- | chrome/common/extensions/extension_constants.h | 10 | ||||
-rw-r--r-- | chrome/common/extensions/extension_manifests_unittest.cc | 13 |
4 files changed, 50 insertions, 18 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 2c1cfc5..00a2e5f 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -1357,14 +1357,31 @@ bool Extension::LoadWebIntentServices(string16* error) { return false; } + std::string href; if (one_service->HasKey(keys::kIntentPath)) { - if (!one_service->GetString(keys::kIntentPath, &value)) { - *error = ASCIIToUTF16(errors::kInvalidIntentPath); + if (!one_service->GetString(keys::kIntentPath, &href)) { + *error = ASCIIToUTF16(errors::kInvalidIntentHref); return false; } + } + + if (one_service->HasKey(keys::kIntentHref)) { + if (!href.empty()) { + *error = ExtensionErrorUtils::FormatErrorMessageUTF16( + errors::kInvalidIntentHrefOldAndNewKey, *iter, + keys::kIntentPath, keys::kIntentHref); + return false; + } + if (!one_service->GetString(keys::kIntentHref, &href)) { + *error = ASCIIToUTF16(errors::kInvalidIntentHref); + return false; + } + } + + if (!href.empty()) { + GURL service_url(href); if (is_hosted_app()) { // Hosted apps require an absolute URL for intents. - GURL service_url(value); if (!service_url.is_valid() || !(web_extent().MatchesURL(service_url))) { *error = ExtensionErrorUtils::FormatErrorMessageUTF16( @@ -1374,12 +1391,12 @@ bool Extension::LoadWebIntentServices(string16* error) { service.service_url = service_url; } else { // We do not allow absolute intent URLs in non-hosted apps. - if (GURL(value).is_valid()) { + if (service_url.is_valid()) { *error =ExtensionErrorUtils::FormatErrorMessageUTF16( - errors::kCannotAccessPage, value.c_str()); + errors::kCannotAccessPage, href); return false; } - service.service_url = GetResourceURL(value); + service.service_url = GetResourceURL(href); } } diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc index 868dc3c..0065870 100644 --- a/chrome/common/extensions/extension_constants.cc +++ b/chrome/common/extensions/extension_constants.cc @@ -44,11 +44,12 @@ const char kId[] = "id"; const char kIncognito[] = "incognito"; const char kIncludeGlobs[] = "include_globs"; const char kInputComponents[] = "input_components"; -const char kIntents[] = "intents"; -const char kIntentType[] = "type"; +const char kIntentDisposition[] = "disposition"; +const char kIntentHref[] = "href"; const char kIntentPath[] = "path"; +const char kIntents[] = "intents"; const char kIntentTitle[] = "title"; -const char kIntentDisposition[] = "disposition"; +const char kIntentType[] = "type"; const char kIsolation[] = "app.isolation"; const char kJs[] = "js"; const char kKey[] = "key"; @@ -264,10 +265,13 @@ const char kInvalidIntent[] = "Invalid value for intents[*]"; const char kInvalidIntentDisposition[] = "Invalid value for intents[*].disposition"; -const char kInvalidIntentPath[] = - "Invalid value for intents[*].path"; +const char kInvalidIntentHref[] = + "Invalid value for intents[*].href"; +const char kInvalidIntentHrefOldAndNewKey[] = + "intents[*]: Key \"*\" is deprecated. Key \"*\" has the same meaning. " + "You can not use both."; const char kInvalidIntentPageInHostedApp[] = - "Invalid value for intents[*].path. Hosted apps must specify an " + "Invalid value for intents[*].href. Hosted apps must specify an " "absolute URL within app.urls[]."; const char kInvalidIntents[] = "Invalid value for intents"; diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h index 4ceb45e..068f144 100644 --- a/chrome/common/extensions/extension_constants.h +++ b/chrome/common/extensions/extension_constants.h @@ -46,11 +46,12 @@ namespace extension_manifest_keys { extern const char kIncognito[]; extern const char kIncludeGlobs[]; extern const char kInputComponents[]; - extern const char kIntents[]; - extern const char kIntentType[]; + extern const char kIntentDisposition[]; + extern const char kIntentHref[]; extern const char kIntentPath[]; + extern const char kIntents[]; extern const char kIntentTitle[]; - extern const char kIntentDisposition[]; + extern const char kIntentType[]; extern const char kIsolation[]; extern const char kJs[]; extern const char kKey[]; @@ -205,7 +206,8 @@ namespace extension_manifest_errors { extern const char kInvalidInputComponentType[]; extern const char kInvalidIntent[]; extern const char kInvalidIntentDisposition[]; - extern const char kInvalidIntentPath[]; + extern const char kInvalidIntentHref[]; + extern const char kInvalidIntentHrefOldAndNewKey[]; extern const char kInvalidIntentPageInHostedApp[]; extern const char kInvalidIntents[]; extern const char kInvalidIntentType[]; diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc index 23e3847..6c170d3 100644 --- a/chrome/common/extensions/extension_manifests_unittest.cc +++ b/chrome/common/extensions/extension_manifests_unittest.cc @@ -784,11 +784,13 @@ TEST_F(ExtensionManifestTest, WebIntents) { Testcase testcases[] = { {"intent_invalid_1.json", errors::kInvalidIntents}, {"intent_invalid_2.json", errors::kInvalidIntent}, - {"intent_invalid_3.json", errors::kInvalidIntentPath}, + {"intent_invalid_3.json", errors::kInvalidIntentHref}, {"intent_invalid_4.json", errors::kInvalidIntentDisposition}, {"intent_invalid_5.json", errors::kInvalidIntentType}, {"intent_invalid_6.json", errors::kInvalidIntentTitle}, - {"intent_invalid_packaged_app.json", errors::kCannotAccessPage} + {"intent_invalid_packaged_app.json", errors::kCannotAccessPage}, + {"intent_invalid_href_and_path.json", + errors::kInvalidIntentHrefOldAndNewKey} }; RunTestcases(testcases, arraysize(testcases)); @@ -821,6 +823,13 @@ TEST_F(ExtensionManifestTest, WebIntents) { EXPECT_EQ("", UTF16ToUTF8(extension->intents_services()[0].title)); EXPECT_EQ(webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW, extension->intents_services()[0].disposition); + + // Make sure we support href instead of path. + extension = LoadAndExpectSuccess("intent_valid_using_href.json"); + ASSERT_TRUE(extension.get() != NULL); + ASSERT_EQ(1u, extension->intents_services().size()); + EXPECT_EQ("//services/share", + extension->intents_services()[0].service_url.path()); } TEST_F(ExtensionManifestTest, WebIntentsWithMultipleMimeTypes) { |