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 = base::SplitString( | 51 std::vector<std::string> sizes_str_list; |
52 sizes_str, base::kWhitespaceASCII, base::KEEP_WHITESPACE, | 52 base::SplitStringAlongWhitespace(sizes_str, &sizes_str_list); |
53 base::SPLIT_WANT_NONEMPTY); | |
54 | 53 |
55 for (size_t i = 0; i < sizes_str_list.size(); ++i) { | 54 for (size_t i = 0; i < sizes_str_list.size(); ++i) { |
56 std::string& size_str = sizes_str_list[i]; | 55 std::string& size_str = sizes_str_list[i]; |
57 if (size_str == "any") { | 56 if (size_str == "any") { |
58 sizes.push_back(gfx::Size(0, 0)); | 57 sizes.push_back(gfx::Size(0, 0)); |
59 continue; | 58 continue; |
60 } | 59 } |
61 | 60 |
62 // It is expected that [0] => width and [1] => height after the split. | 61 // It is expected that [0] => width and [1] => height after the split. |
63 std::vector<std::string> size_list = base::SplitString( | 62 std::vector<std::string> size_list; |
64 size_str, "x", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); | 63 base::SplitStringDontTrim(size_str, L'x', &size_list); |
65 if (size_list.size() != 2) | 64 if (size_list.size() != 2) |
66 continue; | 65 continue; |
67 if (!IsValidIconWidthOrHeight(size_list[0]) || | 66 if (!IsValidIconWidthOrHeight(size_list[0]) || |
68 !IsValidIconWidthOrHeight(size_list[1])) { | 67 !IsValidIconWidthOrHeight(size_list[1])) { |
69 continue; | 68 continue; |
70 } | 69 } |
71 | 70 |
72 int width, height; | 71 int width, height; |
73 if (!base::StringToInt(size_list[0], &width) || | 72 if (!base::StringToInt(size_list[0], &width) || |
74 !base::StringToInt(size_list[1], &height)) { | 73 !base::StringToInt(size_list[1], &height)) { |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 | 429 |
431 return static_cast<int64_t>(color); | 430 return static_cast<int64_t>(color); |
432 } | 431 } |
433 | 432 |
434 base::NullableString16 ManifestParser::ParseGCMSenderID( | 433 base::NullableString16 ManifestParser::ParseGCMSenderID( |
435 const base::DictionaryValue& dictionary) { | 434 const base::DictionaryValue& dictionary) { |
436 return ParseString(dictionary, "gcm_sender_id", Trim); | 435 return ParseString(dictionary, "gcm_sender_id", Trim); |
437 } | 436 } |
438 | 437 |
439 } // namespace content | 438 } // namespace content |
OLD | NEW |