| 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 "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/strings/nullable_string16.h" | 8 #include "base/strings/nullable_string16.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "content/public/common/manifest.h" | 14 #include "content/public/common/manifest.h" |
| 15 #include "content/renderer/manifest/manifest_uma_util.h" | 15 #include "content/renderer/manifest/manifest_uma_util.h" |
| 16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Helper function that returns whether the given |str| is a valid width or | 22 // Helper function that returns whether the given |str| is a valid width or |
| 23 // height value for an icon sizes per: | 23 // height value for an icon sizes per: |
| 24 // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes | 24 // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes |
| 25 bool IsValidIconWidthOrHeight(const std::string& str) { | 25 bool IsValidIconWidthOrHeight(const std::string& str) { |
| 26 if (str.empty() || str[0] == '0') | 26 if (str.empty() || str[0] == '0') |
| 27 return false; | 27 return false; |
| 28 for (size_t i = 0; i < str.size(); ++i) | 28 for (size_t i = 0; i < str.size(); ++i) |
| 29 if (!IsAsciiDigit(str[i])) | 29 if (!base::IsAsciiDigit(str[i])) |
| 30 return false; | 30 return false; |
| 31 return true; | 31 return true; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Parses the 'sizes' attribute of an icon as described in the HTML spec: | 34 // Parses the 'sizes' attribute of an icon as described in the HTML spec: |
| 35 // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes | 35 // https://html.spec.whatwg.org/multipage/semantics.html#attr-link-sizes |
| 36 // Return a vector of gfx::Size that contains the valid sizes found. "Any" is | 36 // Return a vector of gfx::Size that contains the valid sizes found. "Any" is |
| 37 // represented by gfx::Size(0, 0). | 37 // represented by gfx::Size(0, 0). |
| 38 // TODO(mlamouri): this is implemented as a separate function because it should | 38 // TODO(mlamouri): this is implemented as a separate function because it should |
| 39 // be refactored with the other icon sizes parsing implementations, see | 39 // be refactored with the other icon sizes parsing implementations, see |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 const base::DictionaryValue& dictionary) { | 406 const base::DictionaryValue& dictionary) { |
| 407 return ParseBoolean(dictionary, "prefer_related_applications", false); | 407 return ParseBoolean(dictionary, "prefer_related_applications", false); |
| 408 } | 408 } |
| 409 | 409 |
| 410 base::NullableString16 ManifestParser::ParseGCMSenderID( | 410 base::NullableString16 ManifestParser::ParseGCMSenderID( |
| 411 const base::DictionaryValue& dictionary) { | 411 const base::DictionaryValue& dictionary) { |
| 412 return ParseString(dictionary, "gcm_sender_id", Trim); | 412 return ParseString(dictionary, "gcm_sender_id", Trim); |
| 413 } | 413 } |
| 414 | 414 |
| 415 } // namespace content | 415 } // namespace content |
| OLD | NEW |