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 9a3e8520932cc7d18b6054066deda1d8f0a65c29..d00ef673acd2ae82a36d5cf768b75ba2bd71da35 100644 |
| --- a/content/renderer/manifest/manifest_parser.cc |
| +++ b/content/renderer/manifest/manifest_parser.cc |
| @@ -129,6 +129,8 @@ void ManifestParser::Parse() { |
| manifest_.icons = ParseIcons(*dictionary); |
| manifest_.gcm_sender_id = ParseGCMSenderID(*dictionary); |
| manifest_.gcm_user_visible_only = ParseGCMUserVisibleOnly(*dictionary); |
| + manifest_.chrome_related_applications = |
| + ParseChromeRelatedApplications(*dictionary); |
| ManifestUmaUtil::ParseSucceeded(manifest_); |
| } |
| @@ -344,4 +346,62 @@ bool ManifestParser::ParseGCMUserVisibleOnly( |
| return ParseBoolean(dictionary, "gcm_user_visible_only", false); |
| } |
| +Manifest::RelatedApplicationPlatform |
| +ManifestParser::ParseRelatedApplicationPlatform( |
| + const base::DictionaryValue& application) { |
| + base::NullableString16 display = ParseString(application, "platform", Trim); |
|
mlamouri (slow - plz ping)
2015/02/16 20:20:40
s/display/platform/
benwells
2015/02/16 23:58:43
Done.
|
| + if (display.is_null()) |
| + return Manifest::RELATED_APPLICATION_PLATFORM_UNSPECIFIED; |
|
mlamouri (slow - plz ping)
2015/02/16 20:20:39
Could you add an error in that case? It seems that
benwells
2015/02/16 23:58:43
Done.
|
| + |
| + if (LowerCaseEqualsASCII(display.string(), "web")) |
| + return Manifest::RELATED_APPLICATION_PLATFORM_WEB; |
| + else if (LowerCaseEqualsASCII(display.string(), "android")) |
| + return Manifest::RELATED_APPLICATION_PLATFORM_ANDROID; |
| + else { |
| + errors_.push_back(GetErrorPrefix() + "unknown 'platform' value ignored."); |
| + return Manifest::RELATED_APPLICATION_PLATFORM_UNSPECIFIED; |
| + } |
| +} |
| + |
| +base::NullableString16 ManifestParser::ParseRelatedApplicationId( |
| + const base::DictionaryValue& application) { |
| + return ParseString(application, "id", Trim); |
| +} |
| + |
| +std::vector<Manifest::RelatedApplication> |
| +ManifestParser::ParseChromeRelatedApplications( |
| + const base::DictionaryValue& dictionary) { |
| + std::vector<Manifest::RelatedApplication> applications; |
| + if (!dictionary.HasKey("chrome_related_applications")) |
| + return applications; |
| + |
| + const base::ListValue* applications_list = nullptr; |
| + if (!dictionary.GetList("chrome_related_applications", &applications_list)) { |
| + errors_.push_back( |
| + GetErrorPrefix() + |
| + "property 'chrome_related_applications' ignored, type array expected."); |
| + return applications; |
| + } |
| + |
| + for (size_t i = 0; i < applications_list->GetSize(); ++i) { |
| + const base::DictionaryValue* application_dictionary = nullptr; |
| + if (!applications_list->GetDictionary(i, &application_dictionary)) |
| + continue; |
| + |
| + Manifest::RelatedApplication application; |
| + application.platform = |
| + ParseRelatedApplicationPlatform(*application_dictionary); |
| + // An application MUST have a valid platform. If it does not, it MUST be |
| + // ignored. |
| + if (application.platform == |
| + Manifest::RELATED_APPLICATION_PLATFORM_UNSPECIFIED) |
| + continue; |
|
mlamouri (slow - plz ping)
2015/02/16 20:20:40
Could you add a comment pointing that no error is
|
| + application.id = ParseRelatedApplicationId(*application_dictionary); |
| + |
| + applications.push_back(application); |
| + } |
| + |
| + return applications; |
| +} |
| + |
| } // namespace content |