Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: content/renderer/manifest/manifest_parser.cc

Issue 2537953003: WebString: makes string16 conversions explicit (part 1: blink, content) (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 int64_t ManifestParser::ParseColor( 131 int64_t ManifestParser::ParseColor(
132 const base::DictionaryValue& dictionary, 132 const base::DictionaryValue& dictionary,
133 const std::string& key) { 133 const std::string& key) {
134 base::NullableString16 parsed_color = ParseString(dictionary, key, Trim); 134 base::NullableString16 parsed_color = ParseString(dictionary, key, Trim);
135 if (parsed_color.is_null()) 135 if (parsed_color.is_null())
136 return Manifest::kInvalidOrMissingColor; 136 return Manifest::kInvalidOrMissingColor;
137 137
138 blink::WebColor color; 138 blink::WebColor color;
139 if (!blink::WebCSSParser::parseColor(&color, parsed_color.string())) { 139 if (!blink::WebCSSParser::parseColor(
140 &color, blink::WebString::fromUTF16(parsed_color.string()))) {
140 AddErrorInfo("property '" + key + "' ignored, '" + 141 AddErrorInfo("property '" + key + "' ignored, '" +
141 base::UTF16ToUTF8(parsed_color.string()) + "' is not a " + 142 base::UTF16ToUTF8(parsed_color.string()) + "' is not a " +
142 "valid color."); 143 "valid color.");
143 return Manifest::kInvalidOrMissingColor; 144 return Manifest::kInvalidOrMissingColor;
144 } 145 }
145 146
146 // We do this here because Java does not have an unsigned int32_t type so 147 // We do this here because Java does not have an unsigned int32_t type so
147 // colors with high alpha values will be negative. Instead of doing the 148 // colors with high alpha values will be negative. Instead of doing the
148 // conversion after we pass over to Java, we do it here as it is easier and 149 // conversion after we pass over to Java, we do it here as it is easier and
149 // clearer. 150 // clearer.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 260
260 std::vector<gfx::Size> ManifestParser::ParseIconSizes( 261 std::vector<gfx::Size> ManifestParser::ParseIconSizes(
261 const base::DictionaryValue& icon) { 262 const base::DictionaryValue& icon) {
262 base::NullableString16 sizes_str = ParseString(icon, "sizes", NoTrim); 263 base::NullableString16 sizes_str = ParseString(icon, "sizes", NoTrim);
263 std::vector<gfx::Size> sizes; 264 std::vector<gfx::Size> sizes;
264 265
265 if (sizes_str.is_null()) 266 if (sizes_str.is_null())
266 return sizes; 267 return sizes;
267 268
268 blink::WebVector<blink::WebSize> web_sizes = 269 blink::WebVector<blink::WebSize> web_sizes =
269 blink::WebIconSizesParser::parseIconSizes(sizes_str.string()); 270 blink::WebIconSizesParser::parseIconSizes(
271 blink::WebString::fromUTF16(sizes_str.string()));
270 sizes.resize(web_sizes.size()); 272 sizes.resize(web_sizes.size());
271 for (size_t i = 0; i < web_sizes.size(); ++i) 273 for (size_t i = 0; i < web_sizes.size(); ++i)
272 sizes[i] = web_sizes[i]; 274 sizes[i] = web_sizes[i];
273 if (sizes.empty()) { 275 if (sizes.empty()) {
274 AddErrorInfo("found icon with no valid size."); 276 AddErrorInfo("found icon with no valid size.");
275 } 277 }
276 return sizes; 278 return sizes;
277 } 279 }
278 280
279 std::vector<Manifest::Icon> ManifestParser::ParseIcons( 281 std::vector<Manifest::Icon> ManifestParser::ParseIcons(
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 390 }
389 391
390 void ManifestParser::AddErrorInfo(const std::string& error_msg, 392 void ManifestParser::AddErrorInfo(const std::string& error_msg,
391 bool critical, 393 bool critical,
392 int error_line, 394 int error_line,
393 int error_column) { 395 int error_column) {
394 errors_.push_back({error_msg, critical, error_line, error_column}); 396 errors_.push_back({error_msg, critical, error_line, error_column});
395 } 397 }
396 398
397 } // namespace content 399 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/history_serialization.cc ('k') | content/renderer/media/canvas_capture_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698