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

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: 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 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_;
(...skipping 15 matching lines...) Expand all
156 errors_.push_back(GetErrorPrefix() + 157 errors_.push_back(GetErrorPrefix() +
157 "property '" + key + "' ignored, type string expected."); 158 "property '" + key + "' ignored, type string expected.");
158 return base::NullableString16(); 159 return base::NullableString16();
159 } 160 }
160 161
161 if (trim == Trim) 162 if (trim == Trim)
162 base::TrimWhitespace(value, base::TRIM_ALL, &value); 163 base::TrimWhitespace(value, base::TRIM_ALL, &value);
163 return base::NullableString16(value, false); 164 return base::NullableString16(value, false);
164 } 165 }
165 166
167 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.
168 const std::string& key,
169 bool default_value) {
170 if (!dictionary.HasKey(key))
171 return default_value;
172
173 bool value;
174 if (!dictionary.GetBoolean(key, &value)) {
175 errors_.push_back(GetErrorPrefix() +
176 "property '" + key + "' ignored, type boolean expected.");
177 return default_value;
178 }
179
180 return value;
181 }
182
166 GURL ManifestParser::ParseURL(const base::DictionaryValue& dictionary, 183 GURL ManifestParser::ParseURL(const base::DictionaryValue& dictionary,
167 const std::string& key, 184 const std::string& key,
168 const GURL& base_url) { 185 const GURL& base_url) {
169 base::NullableString16 url_str = ParseString(dictionary, key, NoTrim); 186 base::NullableString16 url_str = ParseString(dictionary, key, NoTrim);
170 if (url_str.is_null()) 187 if (url_str.is_null())
171 return GURL(); 188 return GURL();
172 189
173 return base_url.Resolve(url_str.string()); 190 return base_url.Resolve(url_str.string());
174 } 191 }
175 192
(...skipping 139 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

Powered by Google App Engine
This is Rietveld 408576698