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

Unified Diff: content/renderer/manifest/manifest_parser.cc

Issue 2036803002: [WIP] Use Optional<SkColor> instead of int64 for colors in Manifest. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: with unit tests Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/manifest/manifest_parser.h ('k') | content/renderer/manifest/manifest_parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/manifest/manifest_parser.cc
diff --git a/content/renderer/manifest/manifest_parser.cc b/content/renderer/manifest/manifest_parser.cc
index 23dca88bb9baf247d8b8e2f6762718a9e41bd136..ed2d8b2c06ea3f2fd796c860f8a18fd9d2985083 100644
--- a/content/renderer/manifest/manifest_parser.cc
+++ b/content/renderer/manifest/manifest_parser.cc
@@ -127,27 +127,22 @@ base::NullableString16 ManifestParser::ParseString(
return base::NullableString16(value, false);
}
-int64_t ManifestParser::ParseColor(
+base::Optional<SkColor> ManifestParser::ParseColor(
const base::DictionaryValue& dictionary,
const std::string& key) {
base::NullableString16 parsed_color = ParseString(dictionary, key, Trim);
if (parsed_color.is_null())
- return Manifest::kInvalidOrMissingColor;
+ return base::nullopt;
blink::WebColor color;
if (!blink::WebCSSParser::parseColor(&color, parsed_color.string())) {
AddErrorInfo("property '" + key + "' ignored, '" +
base::UTF16ToUTF8(parsed_color.string()) + "' is not a " +
"valid color.");
- return Manifest::kInvalidOrMissingColor;
+ return base::nullopt;
}
- // We do this here because Java does not have an unsigned int32_t type so
- // colors with high alpha values will be negative. Instead of doing the
- // conversion after we pass over to Java, we do it here as it is easier and
- // clearer.
- int32_t signed_color = reinterpret_cast<int32_t&>(color);
- return static_cast<int64_t>(signed_color);
+ return color;
}
GURL ManifestParser::ParseURL(const base::DictionaryValue& dictionary,
@@ -393,12 +388,12 @@ bool ManifestParser::ParsePreferRelatedApplications(
return ParseBoolean(dictionary, "prefer_related_applications", false);
}
-int64_t ManifestParser::ParseThemeColor(
+base::Optional<SkColor> ManifestParser::ParseThemeColor(
const base::DictionaryValue& dictionary) {
return ParseColor(dictionary, "theme_color");
}
-int64_t ManifestParser::ParseBackgroundColor(
+base::Optional<SkColor> ManifestParser::ParseBackgroundColor(
const base::DictionaryValue& dictionary) {
return ParseColor(dictionary, "background_color");
}
« no previous file with comments | « content/renderer/manifest/manifest_parser.h ('k') | content/renderer/manifest/manifest_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698