| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // TODO(mlamouri): this is implemented as a separate function because it should | 41 // TODO(mlamouri): this is implemented as a separate function because it should |
| 42 // be refactored with the other icon sizes parsing implementations, see | 42 // be refactored with the other icon sizes parsing implementations, see |
| 43 // http://crbug.com/416477 | 43 // http://crbug.com/416477 |
| 44 std::vector<gfx::Size> ParseIconSizesHTML(const base::string16& sizes_str16) { | 44 std::vector<gfx::Size> ParseIconSizesHTML(const base::string16& sizes_str16) { |
| 45 if (!base::IsStringASCII(sizes_str16)) | 45 if (!base::IsStringASCII(sizes_str16)) |
| 46 return std::vector<gfx::Size>(); | 46 return std::vector<gfx::Size>(); |
| 47 | 47 |
| 48 std::vector<gfx::Size> sizes; | 48 std::vector<gfx::Size> sizes; |
| 49 std::string sizes_str = | 49 std::string sizes_str = |
| 50 base::StringToLowerASCII(base::UTF16ToUTF8(sizes_str16)); | 50 base::StringToLowerASCII(base::UTF16ToUTF8(sizes_str16)); |
| 51 std::vector<std::string> sizes_str_list; | 51 std::vector<std::string> sizes_str_list = base::SplitString( |
| 52 base::SplitStringAlongWhitespace(sizes_str, &sizes_str_list); | 52 sizes_str, base::kWhitespaceASCII, base::KEEP_WHITESPACE, |
| 53 base::SPLIT_WANT_NONEMPTY); |
| 53 | 54 |
| 54 for (size_t i = 0; i < sizes_str_list.size(); ++i) { | 55 for (size_t i = 0; i < sizes_str_list.size(); ++i) { |
| 55 std::string& size_str = sizes_str_list[i]; | 56 std::string& size_str = sizes_str_list[i]; |
| 56 if (size_str == "any") { | 57 if (size_str == "any") { |
| 57 sizes.push_back(gfx::Size(0, 0)); | 58 sizes.push_back(gfx::Size(0, 0)); |
| 58 continue; | 59 continue; |
| 59 } | 60 } |
| 60 | 61 |
| 61 // It is expected that [0] => width and [1] => height after the split. | 62 // It is expected that [0] => width and [1] => height after the split. |
| 62 std::vector<std::string> size_list; | 63 std::vector<std::string> size_list = base::SplitString( |
| 63 base::SplitStringDontTrim(size_str, L'x', &size_list); | 64 size_str, "x", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); |
| 64 if (size_list.size() != 2) | 65 if (size_list.size() != 2) |
| 65 continue; | 66 continue; |
| 66 if (!IsValidIconWidthOrHeight(size_list[0]) || | 67 if (!IsValidIconWidthOrHeight(size_list[0]) || |
| 67 !IsValidIconWidthOrHeight(size_list[1])) { | 68 !IsValidIconWidthOrHeight(size_list[1])) { |
| 68 continue; | 69 continue; |
| 69 } | 70 } |
| 70 | 71 |
| 71 int width, height; | 72 int width, height; |
| 72 if (!base::StringToInt(size_list[0], &width) || | 73 if (!base::StringToInt(size_list[0], &width) || |
| 73 !base::StringToInt(size_list[1], &height)) { | 74 !base::StringToInt(size_list[1], &height)) { |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 430 |
| 430 return static_cast<int64_t>(color); | 431 return static_cast<int64_t>(color); |
| 431 } | 432 } |
| 432 | 433 |
| 433 base::NullableString16 ManifestParser::ParseGCMSenderID( | 434 base::NullableString16 ManifestParser::ParseGCMSenderID( |
| 434 const base::DictionaryValue& dictionary) { | 435 const base::DictionaryValue& dictionary) { |
| 435 return ParseString(dictionary, "gcm_sender_id", Trim); | 436 return ParseString(dictionary, "gcm_sender_id", Trim); |
| 436 } | 437 } |
| 437 | 438 |
| 438 } // namespace content | 439 } // namespace content |
| OLD | NEW |