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 442e0d8e1be88bcc619c213290ded27fa4faf3c9..71b3a30bfebcf5b409bc6664c01d386ee4592f11 100644 |
| --- a/content/renderer/manifest/manifest_parser.cc |
| +++ b/content/renderer/manifest/manifest_parser.cc |
| @@ -276,6 +276,34 @@ std::vector<gfx::Size> ManifestParser::ParseIconSizes( |
| return sizes; |
| } |
| +std::vector<Manifest::Icon::IconPurpose> ManifestParser::ParseIconPurpose( |
| + const base::DictionaryValue& icon) { |
| + base::NullableString16 purpose_str = ParseString(icon, "purpose", NoTrim); |
| + std::vector<Manifest::Icon::IconPurpose> purposes; |
| + |
| + if (purpose_str.is_null()) |
| + return purposes; |
|
mlamouri (slow - plz ping)
2016/11/02 14:44:59
can you return the array with Manifest::Icon::Icon
F
2016/12/09 19:07:23
Done.
|
| + |
| + std::vector<base::string16> keywords = base::SplitString( |
| + purpose_str.string(), base::ASCIIToUTF16(" "), |
| + base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| + for (const base::string16& keyword : keywords) { |
| + if (base::LowerCaseEqualsASCII(keyword, "any")) { |
| + purposes.push_back(Manifest::Icon::IconPurpose::ANY); |
| + } else if (base::LowerCaseEqualsASCII(keyword, "badge")) { |
| + purposes.push_back(Manifest::Icon::IconPurpose::BADGE); |
| + } else { |
| + AddErrorInfo("found icon with invalid purpose."); |
|
mlamouri (slow - plz ping)
2016/10/25 11:12:22
Can you put the keyword that isn't valid in the er
F
2016/12/09 19:07:23
Unfortunately the keyword is of type string16, whi
|
| + } |
| + } |
| + |
| + if (purposes.empty()) { |
| + purposes.push_back(Manifest::Icon::IconPurpose::ANY); |
| + } |
|
mlamouri (slow - plz ping)
2016/10/25 11:12:22
That looks odd. Not sure why we need to differenti
F
2016/12/09 19:07:23
Done.
|
| + |
| + return purposes; |
| +} |
| + |
| std::vector<Manifest::Icon> ManifestParser::ParseIcons( |
| const base::DictionaryValue& dictionary) { |
| std::vector<Manifest::Icon> icons; |
| @@ -300,6 +328,7 @@ std::vector<Manifest::Icon> ManifestParser::ParseIcons( |
| continue; |
| icon.type = ParseIconType(*icon_dictionary); |
| icon.sizes = ParseIconSizes(*icon_dictionary); |
| + icon.purpose = ParseIconPurpose(*icon_dictionary); |
| icons.push_back(icon); |
| } |