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

Unified Diff: chrome/common/extensions/manifest_handlers/externally_connectable.cc

Issue 16464004: Turn disallowed URL patterns such as <all_urls> for externally_connectable into (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test that warnings also imply failure Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/manifest_handlers/externally_connectable.cc
diff --git a/chrome/common/extensions/manifest_handlers/externally_connectable.cc b/chrome/common/extensions/manifest_handlers/externally_connectable.cc
index ab811688d17260e21b2a07226ffda0f0b2573ee7..c95080dce36f74e0e438a5565f78d21227b9fb8b 100644
--- a/chrome/common/extensions/manifest_handlers/externally_connectable.cc
+++ b/chrome/common/extensions/manifest_handlers/externally_connectable.cc
@@ -58,14 +58,18 @@ bool ExternallyConnectableHandler::Parse(Extension* extension,
const base::Value* externally_connectable = NULL;
CHECK(extension->manifest()->Get(keys::kExternallyConnectable,
&externally_connectable));
+ std::vector<InstallWarning> install_warnings;
scoped_ptr<ExternallyConnectableInfo> info =
- ExternallyConnectableInfo::FromValue(*externally_connectable, error);
+ ExternallyConnectableInfo::FromValue(*externally_connectable,
+ &install_warnings,
+ error);
if (!info)
return false;
if (!info->matches.is_empty()) {
PermissionsData::GetInitialAPIPermissions(extension)->insert(
APIPermission::kWebConnectable);
}
+ extension->AddInstallWarnings(install_warnings);
extension->SetManifestData(keys::kExternallyConnectable, info.release());
return true;
}
@@ -84,6 +88,7 @@ ExternallyConnectableInfo* ExternallyConnectableInfo::Get(
// static
scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue(
const base::Value& value,
+ std::vector<InstallWarning>* install_warnings,
string16* error) {
scoped_ptr<ExternallyConnectable> externally_connectable =
ExternallyConnectable::FromValue(value);
@@ -109,9 +114,11 @@ scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue(
// Wildcard hosts are not allowed.
if (pattern.host().empty()) {
- *error = ErrorUtils::FormatErrorMessageUTF16(
- errors::kErrorWildcardHostsNotAllowed, *it);
- return scoped_ptr<ExternallyConnectableInfo>();
+ // Warning not error for forwards compatibility.
+ install_warnings->push_back(
+ InstallWarning::Text(ErrorUtils::FormatErrorMessage(
+ errors::kErrorWildcardHostsNotAllowed, *it)));
+ continue;
}
// Wildcards on subdomains of a TLD are not allowed.
@@ -135,11 +142,13 @@ scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue(
// Broad match patterns like "*.com", "*.co.uk", and even "*.appspot.com"
// are not allowed. However just "appspot.com" is ok.
if (registry_length == 0 && pattern.match_subdomains()) {
- *error = ErrorUtils::FormatErrorMessageUTF16(
- errors::kErrorTopLevelDomainsNotAllowed,
- pattern.host().c_str(),
- *it);
- return scoped_ptr<ExternallyConnectableInfo>();
+ // Warning not error for forwards compatibility.
+ install_warnings->push_back(InstallWarning::Text(
+ ErrorUtils::FormatErrorMessage(
+ errors::kErrorTopLevelDomainsNotAllowed,
+ pattern.host().c_str(),
+ *it)));
+ continue;
}
matches.AddPattern(pattern);

Powered by Google App Engine
This is Rietveld 408576698