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

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: Add comments 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
« 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 44ac56f60b695a04ab6f1d6c1de02719fb1b42c6..6b021d2a7a30286f1cbd292e161a3c5e5f495f71 100644
--- a/content/renderer/manifest/manifest_parser.cc
+++ b/content/renderer/manifest/manifest_parser.cc
@@ -13,6 +13,9 @@
#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 "ui/gfx/geometry/size.h"
namespace content {
@@ -129,6 +132,7 @@ void ManifestParser::Parse() {
manifest_.related_applications = ParseRelatedApplications(*dictionary);
manifest_.prefer_related_applications =
ParsePreferRelatedApplications(*dictionary);
+ manifest_.theme_color = ParseThemeColor(*dictionary);
manifest_.gcm_sender_id = ParseGCMSenderID(*dictionary);
ManifestUmaUtil::ParseSucceeded(manifest_);
@@ -407,6 +411,25 @@ bool ManifestParser::ParsePreferRelatedApplications(
return ParseBoolean(dictionary, "prefer_related_applications", false);
}
+int64_t ManifestParser::ParseThemeColor(
+ const base::DictionaryValue& dictionary) {
+ base::NullableString16 theme_color = ParseString(
+ dictionary, "theme_color", Trim);
+ if (theme_color.is_null())
+ return Manifest::kInvalidOrMissingThemeColor;
+
+ blink::WebColor color;
+ if (!blink::WebCSSParser::parseColor(&color, theme_color.string())) {
+ errors_.push_back(GetErrorPrefix() +
+ "property 'theme_color' ignored, '" +
+ base::UTF16ToUTF8(theme_color.string()) +
+ "' is not a valid color.");
+ return Manifest::kInvalidOrMissingThemeColor;
+ }
+
+ return static_cast<int64_t>(color);
+}
+
base::NullableString16 ManifestParser::ParseGCMSenderID(
const base::DictionaryValue& dictionary) {
return ParseString(dictionary, "gcm_sender_id", Trim);
« 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