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

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

Issue 1235883007: manifest: add theme_color value to the manifest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reflect change in Blink patch Created 5 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
Index: content/renderer/manifest/manifest_parser.cc
diff --git a/content/renderer/manifest/manifest_parser.cc b/content/renderer/manifest/manifest_parser.cc
index 44ac56f60b695a04ab6f1d6c1de02719fb1b42c6..af2ea7f415e0825019bbc69cf3a95f546d074d4c 100644
--- a/content/renderer/manifest/manifest_parser.cc
+++ b/content/renderer/manifest/manifest_parser.cc
@@ -4,6 +4,8 @@
#include "content/renderer/manifest/manifest_parser.h"
+#include <inttypes.h>
+
#include "base/json/json_reader.h"
#include "base/strings/nullable_string16.h"
#include "base/strings/string_number_conversions.h"
@@ -13,6 +15,10 @@
#include "base/values.h"
#include "content/public/common/manifest.h"
#include "content/renderer/manifest/manifest_uma_util.h"
+#include "third_party/WebKit/public/platform/WebColor.h"
+#include "third_party/WebKit/public/platform/WebString.h"
+#include "third_party/WebKit/public/web/WebCSSParser.h"
+#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/size.h"
namespace content {
@@ -124,6 +130,7 @@ void ManifestParser::Parse() {
manifest_.short_name = ParseShortName(*dictionary);
manifest_.start_url = ParseStartURL(*dictionary);
manifest_.display = ParseDisplay(*dictionary);
+ manifest_.theme_color = ParseThemeColor(*dictionary);
manifest_.orientation = ParseOrientation(*dictionary);
manifest_.icons = ParseIcons(*dictionary);
manifest_.related_applications = ParseRelatedApplications(*dictionary);
@@ -215,6 +222,25 @@ GURL ManifestParser::ParseStartURL(const base::DictionaryValue& dictionary) {
return start_url;
}
+int64_t ManifestParser::ParseThemeColor(
+ const base::DictionaryValue& dictionary) {
+ base::NullableString16 display = ParseString(dictionary, "theme_color", Trim);
+ if (display.is_null())
mlamouri (slow - plz ping) 2015/07/16 12:35:41 s/display/theme_color/g
Lalit Maganti 2015/07/16 14:49:02 Done.
+ return Manifest::kInvalidThemeColor;
+
+ blink::WebColor color = SK_ColorTRANSPARENT;
mlamouri (slow - plz ping) 2015/07/16 12:35:41 I don't think you need to initialize that.
Lalit Maganti 2015/07/16 14:49:02 Done.
+
+ bool success = blink::WebCSSParser::parseColor(&color, display.string());
+ if (!success) {
mlamouri (slow - plz ping) 2015/07/16 12:35:40 You don't need the |success| variable.
Lalit Maganti 2015/07/16 14:49:01 Done.
+ errors_.push_back(GetErrorPrefix() +
+ "unable to parse 'theme_color' as color.");
mlamouri (slow - plz ping) 2015/07/16 12:35:40 nit: follow the same language as the other errors:
Lalit Maganti 2015/07/16 14:49:02 Almost done - the concatenation of the strings did
+ return Manifest::kInvalidThemeColor;
+ }
+
+ int64_t int_color = color;
+ return int_color;
mlamouri (slow - plz ping) 2015/07/16 12:35:41 return static_cast<int64>(color);
Lalit Maganti 2015/07/16 14:49:01 Done.
+}
+
Manifest::DisplayMode ManifestParser::ParseDisplay(
const base::DictionaryValue& dictionary) {
base::NullableString16 display = ParseString(dictionary, "display", Trim);

Powered by Google App Engine
This is Rietveld 408576698