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

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

Issue 580513002: Add support for gcm_sender_id in Manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@manifest_start_url
Patch Set: add gcm_sender_id to ipc traits Created 6 years, 3 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 19b69a540278b1782cda702ed986fbe0e91f453b..13a65be8e98ebe071a61c4d18be47728b39b8b2e 100644
--- a/content/renderer/manifest/manifest_parser.cc
+++ b/content/renderer/manifest/manifest_parser.cc
@@ -10,6 +10,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "content/public/common/manifest.h"
+#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
namespace {
@@ -75,6 +76,25 @@ GURL ParseStartURL(const base::DictionaryValue& dictionary,
return start_url;
}
+// Parses the 'gcm_sender_id' field of the manifest.
+// This is a proprietary extension that we only use when PushMessaging is
+// enabled in Blink.
+// Returns the parsed string if any, a null string if the parsing failed.
+base::NullableString16 ParseGCMSenderID(
+ const base::DictionaryValue& dictionary) {
Mike West 2014/09/17 04:20:52 Can you add an ASSERT that the runtime flag isn't
mlamouri (slow - plz ping) 2014/09/17 08:35:41 Done.
+ if (!dictionary.HasKey("gcm_sender_id"))
+ return base::NullableString16();
+
+ base::string16 gcm_sender_id;
+ if (!dictionary.GetString("gcm_sender_id", &gcm_sender_id)) {
+ // TODO(mlamouri): provide a custom message to the developer console.
+ return base::NullableString16();
+ }
+
+ base::TrimWhitespace(gcm_sender_id, base::TRIM_ALL, &gcm_sender_id);
+ return base::NullableString16(gcm_sender_id, false);
+}
+
} // anonymous namespace
namespace content {
@@ -107,6 +127,9 @@ Manifest ManifestParser::Parse(const base::StringPiece& json,
manifest.short_name = ParseShortName(*dictionary);
manifest.start_url = ParseStartURL(*dictionary, manifest_url, document_url);
+ if (blink::WebRuntimeFeatures::isPushMessagingEnabled())
+ manifest.gcm_sender_id = ParseGCMSenderID(*dictionary);
+
return manifest;
}
« no previous file with comments | « content/renderer/manifest/manifest_manager.cc ('k') | content/renderer/manifest/manifest_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698