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

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

Issue 770023002: Push registration should read a "gcm_user_visible_only" key from the Manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment fix Created 6 years 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 961ab3742cd32e27340a779b734701429778156b..981d5f1dfe81dae88300d05937644d83e9581abe 100644
--- a/content/renderer/manifest/manifest_parser.cc
+++ b/content/renderer/manifest/manifest_parser.cc
@@ -128,6 +128,7 @@ void ManifestParser::Parse() {
manifest_.orientation = ParseOrientation(*dictionary);
manifest_.icons = ParseIcons(*dictionary);
manifest_.gcm_sender_id = ParseGCMSenderID(*dictionary);
+ manifest_.gcm_user_visible_only = ParseGCMUserVisibleOnly(*dictionary);
ManifestUmaUtil::ParseSucceeded(manifest_);
}
@@ -163,6 +164,22 @@ base::NullableString16 ManifestParser::ParseString(
return base::NullableString16(value, false);
}
+bool ManifestParser::ParseBoolean(const base::DictionaryValue& dictionary,
mlamouri (slow - plz ping) 2014/12/01 21:05:09 Could you get ::ParseBoolean() on top, around Pars
Peter Beverloo 2014/12/03 15:01:59 Done.
+ const std::string& key,
+ bool default_value) {
+ if (!dictionary.HasKey(key))
+ return default_value;
+
+ bool value;
+ if (!dictionary.GetBoolean(key, &value)) {
+ errors_.push_back(GetErrorPrefix() +
+ "property '" + key + "' ignored, type boolean expected.");
+ return default_value;
+ }
+
+ return value;
+}
+
GURL ManifestParser::ParseURL(const base::DictionaryValue& dictionary,
const std::string& key,
const GURL& base_url) {
@@ -322,4 +339,9 @@ base::NullableString16 ManifestParser::ParseGCMSenderID(
return ParseString(dictionary, "gcm_sender_id", Trim);
}
+bool ManifestParser::ParseGCMUserVisibleOnly(
+ const base::DictionaryValue& dictionary) {
+ return ParseBoolean(dictionary, "gcm_user_visible_only", false);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698