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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/manifest/manifest_parser.h" 5 #include "content/renderer/manifest/manifest_parser.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/strings/nullable_string16.h" 8 #include "base/strings/nullable_string16.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 DCHECK(dictionary); 122 DCHECK(dictionary);
123 123
124 manifest_.name = ParseName(*dictionary); 124 manifest_.name = ParseName(*dictionary);
125 manifest_.short_name = ParseShortName(*dictionary); 125 manifest_.short_name = ParseShortName(*dictionary);
126 manifest_.start_url = ParseStartURL(*dictionary); 126 manifest_.start_url = ParseStartURL(*dictionary);
127 manifest_.display = ParseDisplay(*dictionary); 127 manifest_.display = ParseDisplay(*dictionary);
128 manifest_.orientation = ParseOrientation(*dictionary); 128 manifest_.orientation = ParseOrientation(*dictionary);
129 manifest_.icons = ParseIcons(*dictionary); 129 manifest_.icons = ParseIcons(*dictionary);
130 manifest_.gcm_sender_id = ParseGCMSenderID(*dictionary); 130 manifest_.gcm_sender_id = ParseGCMSenderID(*dictionary);
131 manifest_.gcm_user_visible_only = ParseGCMUserVisibleOnly(*dictionary);
131 132
132 ManifestUmaUtil::ParseSucceeded(manifest_); 133 ManifestUmaUtil::ParseSucceeded(manifest_);
133 } 134 }
134 135
135 const Manifest& ManifestParser::manifest() const { 136 const Manifest& ManifestParser::manifest() const {
136 return manifest_; 137 return manifest_;
137 } 138 }
138 139
139 const std::vector<std::string>& ManifestParser::errors() const { 140 const std::vector<std::string>& ManifestParser::errors() const {
140 return errors_; 141 return errors_;
141 } 142 }
142 143
143 bool ManifestParser::failed() const { 144 bool ManifestParser::failed() const {
144 return failed_; 145 return failed_;
145 } 146 }
146 147
148 bool ManifestParser::ParseBoolean(const base::DictionaryValue& dictionary,
149 const std::string& key,
150 bool default_value) {
151 if (!dictionary.HasKey(key))
152 return default_value;
153
154 bool value;
155 if (!dictionary.GetBoolean(key, &value)) {
156 errors_.push_back(GetErrorPrefix() +
157 "property '" + key + "' ignored, type boolean expected.");
158 return default_value;
159 }
160
161 return value;
162 }
163
147 base::NullableString16 ManifestParser::ParseString( 164 base::NullableString16 ManifestParser::ParseString(
148 const base::DictionaryValue& dictionary, 165 const base::DictionaryValue& dictionary,
149 const std::string& key, 166 const std::string& key,
150 TrimType trim) { 167 TrimType trim) {
151 if (!dictionary.HasKey(key)) 168 if (!dictionary.HasKey(key))
152 return base::NullableString16(); 169 return base::NullableString16();
153 170
154 base::string16 value; 171 base::string16 value;
155 if (!dictionary.GetString(key, &value)) { 172 if (!dictionary.GetString(key, &value)) {
156 errors_.push_back(GetErrorPrefix() + 173 errors_.push_back(GetErrorPrefix() +
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 332 }
316 333
317 return icons; 334 return icons;
318 } 335 }
319 336
320 base::NullableString16 ManifestParser::ParseGCMSenderID( 337 base::NullableString16 ManifestParser::ParseGCMSenderID(
321 const base::DictionaryValue& dictionary) { 338 const base::DictionaryValue& dictionary) {
322 return ParseString(dictionary, "gcm_sender_id", Trim); 339 return ParseString(dictionary, "gcm_sender_id", Trim);
323 } 340 }
324 341
342 bool ManifestParser::ParseGCMUserVisibleOnly(
343 const base::DictionaryValue& dictionary) {
344 return ParseBoolean(dictionary, "gcm_user_visible_only", false);
345 }
346
325 } // namespace content 347 } // namespace content
OLDNEW
« 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