Chromium Code Reviews| Index: content/renderer/manifest/manifest_parser.cc |
| diff --git a/content/renderer/manifest/manifest_parser.cc b/content/renderer/manifest/manifest_parser.cc |
| index 8be16c8b0055d59b49e2c9175008bb864e9ca4de..eedf144adb80de1679ad39d22d54928a8afda63d 100644 |
| --- a/content/renderer/manifest/manifest_parser.cc |
| +++ b/content/renderer/manifest/manifest_parser.cc |
| @@ -64,6 +64,7 @@ void ManifestParser::Parse() { |
| manifest_.name = ParseName(*dictionary); |
| manifest_.short_name = ParseShortName(*dictionary); |
| manifest_.start_url = ParseStartURL(*dictionary); |
| + manifest_.scope = ParseScope(*dictionary, manifest_.start_url); |
| manifest_.display = ParseDisplay(*dictionary); |
| manifest_.orientation = ParseOrientation(*dictionary); |
| manifest_.icons = ParseIcons(*dictionary); |
| @@ -183,6 +184,35 @@ GURL ManifestParser::ParseStartURL(const base::DictionaryValue& dictionary) { |
| return start_url; |
| } |
| +GURL ManifestParser::ParseScope(const base::DictionaryValue& dictionary, |
| + const GURL& start_url) { |
| + GURL scope = ParseURL(dictionary, "scope", manifest_url_); |
| + if (!scope.is_valid()) { |
| + // TODO(pkotwicz): Emit developer warning when URL is invalid. |
|
mlamouri (slow - plz ping)
2016/06/21 13:48:54
I would prefer if you could do this in this CL. It
|
| + return GURL(); |
| + } |
| + |
| + if (scope.GetOrigin() != document_url_.GetOrigin()) { |
| + AddErrorInfo("property 'scope' ignored, should be " |
| + "same origin as document."); |
| + return GURL(); |
| + } |
| + |
| + // According to the spec, if the start_url cannot be parsed, the document URL |
| + // should be used as the start URL. If the start_url could not be parsed, |
| + // check that the document URL is within scope. |
| + GURL check_in_scope = start_url.is_empty() ? document_url_ : start_url; |
| + if (check_in_scope.GetOrigin() != scope.GetOrigin() || |
| + !base::StartsWith(check_in_scope.path(), scope.path(), |
| + base::CompareCase::SENSITIVE)) { |
| + AddErrorInfo( |
| + "property 'scope' ignored. Start url should be within scope " |
| + "of scope URL."); |
| + return GURL(); |
| + } |
| + return scope; |
| +} |
| + |
| blink::WebDisplayMode ManifestParser::ParseDisplay( |
| const base::DictionaryValue& dictionary) { |
| base::NullableString16 display = ParseString(dictionary, "display", Trim); |