Chromium Code Reviews| 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; |
| } |