| 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 19 matching lines...) Expand all Loading... |
| 30 // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes | 30 // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes |
| 31 bool IsValidIconWidthOrHeight(const std::string& str) { | 31 bool IsValidIconWidthOrHeight(const std::string& str) { |
| 32 if (str.empty() || str[0] == '0') | 32 if (str.empty() || str[0] == '0') |
| 33 return false; | 33 return false; |
| 34 for (size_t i = 0; i < str.size(); ++i) | 34 for (size_t i = 0; i < str.size(); ++i) |
| 35 if (!base::IsAsciiDigit(str[i])) | 35 if (!base::IsAsciiDigit(str[i])) |
| 36 return false; | 36 return false; |
| 37 return true; | 37 return true; |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // anonymous namespace |
| 41 |
| 40 // Parses the 'sizes' attribute of an icon as described in the HTML spec: | 42 // Parses the 'sizes' attribute of an icon as described in the HTML spec: |
| 41 // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes | 43 // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes |
| 42 // Return a vector of gfx::Size that contains the valid sizes found. "Any" is | 44 // Return a vector of gfx::Size that contains the valid sizes found. "Any" is |
| 43 // represented by gfx::Size(0, 0). | 45 // represented by gfx::Size(0, 0). |
| 44 // TODO(mlamouri): this is implemented as a separate function because it should | 46 // TODO(mlamouri): this is implemented as a separate function because it should |
| 45 // be refactored with the other icon sizes parsing implementations, see | 47 // be refactored with the other icon sizes parsing implementations, see |
| 46 // http://crbug.com/416477 | 48 // http://crbug.com/416477 |
| 47 std::vector<gfx::Size> ParseIconSizesHTML(const base::string16& sizes_str16) { | 49 std::vector<gfx::Size> ParseIconSizesHTML(const base::string16& sizes_str16) { |
| 48 if (!base::IsStringASCII(sizes_str16)) | 50 if (!base::IsStringASCII(sizes_str16)) |
| 49 return std::vector<gfx::Size>(); | 51 return std::vector<gfx::Size>(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 77 !base::StringToInt(size_list[1], &height)) { | 79 !base::StringToInt(size_list[1], &height)) { |
| 78 continue; | 80 continue; |
| 79 } | 81 } |
| 80 | 82 |
| 81 sizes.push_back(gfx::Size(width, height)); | 83 sizes.push_back(gfx::Size(width, height)); |
| 82 } | 84 } |
| 83 | 85 |
| 84 return sizes; | 86 return sizes; |
| 85 } | 87 } |
| 86 | 88 |
| 87 } // anonymous namespace | |
| 88 | |
| 89 | |
| 90 ManifestParser::ManifestParser(const base::StringPiece& data, | 89 ManifestParser::ManifestParser(const base::StringPiece& data, |
| 91 const GURL& manifest_url, | 90 const GURL& manifest_url, |
| 92 const GURL& document_url) | 91 const GURL& document_url) |
| 93 : data_(data), | 92 : data_(data), |
| 94 manifest_url_(manifest_url), | 93 manifest_url_(manifest_url), |
| 95 document_url_(document_url), | 94 document_url_(document_url), |
| 96 failed_(false) { | 95 failed_(false) { |
| 97 } | 96 } |
| 98 | 97 |
| 99 ManifestParser::~ManifestParser() { | 98 ManifestParser::~ManifestParser() { |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 } | 433 } |
| 435 | 434 |
| 436 void ManifestParser::AddErrorInfo(const std::string& error_msg, | 435 void ManifestParser::AddErrorInfo(const std::string& error_msg, |
| 437 bool critical, | 436 bool critical, |
| 438 int error_line, | 437 int error_line, |
| 439 int error_column) { | 438 int error_column) { |
| 440 errors_.push_back({error_msg, critical, error_line, error_column}); | 439 errors_.push_back({error_msg, critical, error_line, error_column}); |
| 441 } | 440 } |
| 442 | 441 |
| 443 } // namespace content | 442 } // namespace content |
| OLD | NEW |