| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/manifest/manifest_parser.h" | 5 #include "content/renderer/manifest/manifest_parser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 130 } |
| 131 | 131 |
| 132 int64_t ManifestParser::ParseColor( | 132 int64_t ManifestParser::ParseColor( |
| 133 const base::DictionaryValue& dictionary, | 133 const base::DictionaryValue& dictionary, |
| 134 const std::string& key) { | 134 const std::string& key) { |
| 135 base::NullableString16 parsed_color = ParseString(dictionary, key, Trim); | 135 base::NullableString16 parsed_color = ParseString(dictionary, key, Trim); |
| 136 if (parsed_color.is_null()) | 136 if (parsed_color.is_null()) |
| 137 return Manifest::kInvalidOrMissingColor; | 137 return Manifest::kInvalidOrMissingColor; |
| 138 | 138 |
| 139 blink::WebColor color; | 139 blink::WebColor color; |
| 140 if (!blink::WebCSSParser::parseColor(&color, parsed_color.string())) { | 140 if (!blink::WebCSSParser::parseColor( |
| 141 &color, blink::WebString::fromUTF16(parsed_color.string()))) { |
| 141 AddErrorInfo("property '" + key + "' ignored, '" + | 142 AddErrorInfo("property '" + key + "' ignored, '" + |
| 142 base::UTF16ToUTF8(parsed_color.string()) + "' is not a " + | 143 base::UTF16ToUTF8(parsed_color.string()) + "' is not a " + |
| 143 "valid color."); | 144 "valid color."); |
| 144 return Manifest::kInvalidOrMissingColor; | 145 return Manifest::kInvalidOrMissingColor; |
| 145 } | 146 } |
| 146 | 147 |
| 147 // We do this here because Java does not have an unsigned int32_t type so | 148 // We do this here because Java does not have an unsigned int32_t type so |
| 148 // colors with high alpha values will be negative. Instead of doing the | 149 // colors with high alpha values will be negative. Instead of doing the |
| 149 // conversion after we pass over to Java, we do it here as it is easier and | 150 // conversion after we pass over to Java, we do it here as it is easier and |
| 150 // clearer. | 151 // clearer. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 261 |
| 261 std::vector<gfx::Size> ManifestParser::ParseIconSizes( | 262 std::vector<gfx::Size> ManifestParser::ParseIconSizes( |
| 262 const base::DictionaryValue& icon) { | 263 const base::DictionaryValue& icon) { |
| 263 base::NullableString16 sizes_str = ParseString(icon, "sizes", NoTrim); | 264 base::NullableString16 sizes_str = ParseString(icon, "sizes", NoTrim); |
| 264 std::vector<gfx::Size> sizes; | 265 std::vector<gfx::Size> sizes; |
| 265 | 266 |
| 266 if (sizes_str.is_null()) | 267 if (sizes_str.is_null()) |
| 267 return sizes; | 268 return sizes; |
| 268 | 269 |
| 269 blink::WebVector<blink::WebSize> web_sizes = | 270 blink::WebVector<blink::WebSize> web_sizes = |
| 270 blink::WebIconSizesParser::parseIconSizes(sizes_str.string()); | 271 blink::WebIconSizesParser::parseIconSizes( |
| 272 blink::WebString::fromUTF16(sizes_str.string())); |
| 271 sizes.resize(web_sizes.size()); | 273 sizes.resize(web_sizes.size()); |
| 272 for (size_t i = 0; i < web_sizes.size(); ++i) | 274 for (size_t i = 0; i < web_sizes.size(); ++i) |
| 273 sizes[i] = web_sizes[i]; | 275 sizes[i] = web_sizes[i]; |
| 274 if (sizes.empty()) { | 276 if (sizes.empty()) { |
| 275 AddErrorInfo("found icon with no valid size."); | 277 AddErrorInfo("found icon with no valid size."); |
| 276 } | 278 } |
| 277 return sizes; | 279 return sizes; |
| 278 } | 280 } |
| 279 | 281 |
| 280 std::vector<Manifest::Icon::IconPurpose> ManifestParser::ParseIconPurpose( | 282 std::vector<Manifest::Icon::IconPurpose> ManifestParser::ParseIconPurpose( |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 } | 445 } |
| 444 | 446 |
| 445 void ManifestParser::AddErrorInfo(const std::string& error_msg, | 447 void ManifestParser::AddErrorInfo(const std::string& error_msg, |
| 446 bool critical, | 448 bool critical, |
| 447 int error_line, | 449 int error_line, |
| 448 int error_column) { | 450 int error_column) { |
| 449 errors_.push_back({error_msg, critical, error_line, error_column}); | 451 errors_.push_back({error_msg, critical, error_line, error_column}); |
| 450 } | 452 } |
| 451 | 453 |
| 452 } // namespace content | 454 } // namespace content |
| OLD | NEW |