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

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

Issue 1246953002: content: make theme_color more resilient to casting issues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address avi@'s comment Created 5 years, 4 months 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 "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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 blink::WebColor color; 421 blink::WebColor color;
422 if (!blink::WebCSSParser::parseColor(&color, theme_color.string())) { 422 if (!blink::WebCSSParser::parseColor(&color, theme_color.string())) {
423 errors_.push_back(GetErrorPrefix() + 423 errors_.push_back(GetErrorPrefix() +
424 "property 'theme_color' ignored, '" + 424 "property 'theme_color' ignored, '" +
425 base::UTF16ToUTF8(theme_color.string()) + 425 base::UTF16ToUTF8(theme_color.string()) +
426 "' is not a valid color."); 426 "' is not a valid color.");
427 return Manifest::kInvalidOrMissingThemeColor; 427 return Manifest::kInvalidOrMissingThemeColor;
428 } 428 }
429 429
430 return static_cast<int64_t>(color); 430 // We do this here because Java does not have an unsigned int32 type so colors
431 // with high alpha values will be negative. Instead of doing the conversion
432 // after we pass over to Java, we do it here as it is easier and clearer.
433 int32_t signed_color = reinterpret_cast<int32_t&>(color);
434 return static_cast<int64_t>(signed_color);
431 } 435 }
432 436
433 base::NullableString16 ManifestParser::ParseGCMSenderID( 437 base::NullableString16 ManifestParser::ParseGCMSenderID(
434 const base::DictionaryValue& dictionary) { 438 const base::DictionaryValue& dictionary) {
435 return ParseString(dictionary, "gcm_sender_id", Trim); 439 return ParseString(dictionary, "gcm_sender_id", Trim);
436 } 440 }
437 441
438 } // namespace content 442 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/manifest.cc ('k') | content/renderer/manifest/manifest_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698