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> |
| 8 |
7 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
8 #include "base/strings/nullable_string16.h" | 10 #include "base/strings/nullable_string16.h" |
9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
11 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 #include "content/public/common/manifest.h" | 16 #include "content/public/common/manifest.h" |
15 #include "content/renderer/manifest/manifest_uma_util.h" | 17 #include "content/renderer/manifest/manifest_uma_util.h" |
16 #include "third_party/WebKit/public/platform/WebColor.h" | 18 #include "third_party/WebKit/public/platform/WebColor.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 198 |
197 blink::WebColor color; | 199 blink::WebColor color; |
198 if (!blink::WebCSSParser::parseColor(&color, parsed_color.string())) { | 200 if (!blink::WebCSSParser::parseColor(&color, parsed_color.string())) { |
199 errors_.push_back(GetErrorPrefix() + | 201 errors_.push_back(GetErrorPrefix() + |
200 "property '" + key + "' ignored, '" + | 202 "property '" + key + "' ignored, '" + |
201 base::UTF16ToUTF8(parsed_color.string()) + | 203 base::UTF16ToUTF8(parsed_color.string()) + |
202 "' is not a valid color."); | 204 "' is not a valid color."); |
203 return Manifest::kInvalidOrMissingColor; | 205 return Manifest::kInvalidOrMissingColor; |
204 } | 206 } |
205 | 207 |
206 // We do this here because Java does not have an unsigned int32 type so colors | 208 // We do this here because Java does not have an unsigned int32_t type so |
207 // with high alpha values will be negative. Instead of doing the conversion | 209 // colors with high alpha values will be negative. Instead of doing the |
208 // after we pass over to Java, we do it here as it is easier and clearer. | 210 // conversion after we pass over to Java, we do it here as it is easier and |
| 211 // clearer. |
209 int32_t signed_color = reinterpret_cast<int32_t&>(color); | 212 int32_t signed_color = reinterpret_cast<int32_t&>(color); |
210 return static_cast<int64_t>(signed_color); | 213 return static_cast<int64_t>(signed_color); |
211 } | 214 } |
212 | 215 |
213 GURL ManifestParser::ParseURL(const base::DictionaryValue& dictionary, | 216 GURL ManifestParser::ParseURL(const base::DictionaryValue& dictionary, |
214 const std::string& key, | 217 const std::string& key, |
215 const GURL& base_url) { | 218 const GURL& base_url) { |
216 base::NullableString16 url_str = ParseString(dictionary, key, NoTrim); | 219 base::NullableString16 url_str = ParseString(dictionary, key, NoTrim); |
217 if (url_str.is_null()) | 220 if (url_str.is_null()) |
218 return GURL(); | 221 return GURL(); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 const base::DictionaryValue& dictionary) { | 448 const base::DictionaryValue& dictionary) { |
446 return ParseColor(dictionary, "background_color"); | 449 return ParseColor(dictionary, "background_color"); |
447 } | 450 } |
448 | 451 |
449 base::NullableString16 ManifestParser::ParseGCMSenderID( | 452 base::NullableString16 ManifestParser::ParseGCMSenderID( |
450 const base::DictionaryValue& dictionary) { | 453 const base::DictionaryValue& dictionary) { |
451 return ParseString(dictionary, "gcm_sender_id", Trim); | 454 return ParseString(dictionary, "gcm_sender_id", Trim); |
452 } | 455 } |
453 | 456 |
454 } // namespace content | 457 } // namespace content |
OLD | NEW |