OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 DCHECK(dictionary); | 63 DCHECK(dictionary); |
64 | 64 |
65 manifest_.name = ParseName(*dictionary); | 65 manifest_.name = ParseName(*dictionary); |
66 manifest_.short_name = ParseShortName(*dictionary); | 66 manifest_.short_name = ParseShortName(*dictionary); |
67 manifest_.start_url = ParseStartURL(*dictionary); | 67 manifest_.start_url = ParseStartURL(*dictionary); |
68 manifest_.scope = ParseScope(*dictionary, manifest_.start_url); | 68 manifest_.scope = ParseScope(*dictionary, manifest_.start_url); |
69 manifest_.display = ParseDisplay(*dictionary); | 69 manifest_.display = ParseDisplay(*dictionary); |
70 manifest_.orientation = ParseOrientation(*dictionary); | 70 manifest_.orientation = ParseOrientation(*dictionary); |
71 manifest_.icons = ParseIcons(*dictionary); | 71 manifest_.icons = ParseIcons(*dictionary); |
| 72 manifest_.share_target = ParseShareTarget(*dictionary); |
72 manifest_.related_applications = ParseRelatedApplications(*dictionary); | 73 manifest_.related_applications = ParseRelatedApplications(*dictionary); |
73 manifest_.prefer_related_applications = | 74 manifest_.prefer_related_applications = |
74 ParsePreferRelatedApplications(*dictionary); | 75 ParsePreferRelatedApplications(*dictionary); |
75 manifest_.theme_color = ParseThemeColor(*dictionary); | 76 manifest_.theme_color = ParseThemeColor(*dictionary); |
76 manifest_.background_color = ParseBackgroundColor(*dictionary); | 77 manifest_.background_color = ParseBackgroundColor(*dictionary); |
77 manifest_.gcm_sender_id = ParseGCMSenderID(*dictionary); | 78 manifest_.gcm_sender_id = ParseGCMSenderID(*dictionary); |
78 | 79 |
79 ManifestUmaUtil::ParseSucceeded(manifest_); | 80 ManifestUmaUtil::ParseSucceeded(manifest_); |
80 } | 81 } |
81 | 82 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 icon.type = ParseIconType(*icon_dictionary); | 334 icon.type = ParseIconType(*icon_dictionary); |
334 icon.sizes = ParseIconSizes(*icon_dictionary); | 335 icon.sizes = ParseIconSizes(*icon_dictionary); |
335 icon.purpose = ParseIconPurpose(*icon_dictionary); | 336 icon.purpose = ParseIconPurpose(*icon_dictionary); |
336 | 337 |
337 icons.push_back(icon); | 338 icons.push_back(icon); |
338 } | 339 } |
339 | 340 |
340 return icons; | 341 return icons; |
341 } | 342 } |
342 | 343 |
| 344 base::NullableString16 ManifestParser::ParseShareTargetURLTemplate( |
| 345 const base::DictionaryValue& share_target) { |
| 346 return ParseString(share_target, "url_template", Trim); |
| 347 } |
| 348 |
| 349 base::Optional<Manifest::ShareTarget> ManifestParser::ParseShareTarget( |
| 350 const base::DictionaryValue& dictionary) { |
| 351 if (!dictionary.HasKey("share_target")) |
| 352 return base::nullopt; |
| 353 |
| 354 Manifest::ShareTarget share_target; |
| 355 const base::DictionaryValue* share_target_dict = nullptr; |
| 356 dictionary.GetDictionary("share_target", &share_target_dict); |
| 357 share_target.url_template = ParseShareTargetURLTemplate(*share_target_dict); |
| 358 |
| 359 if (share_target.url_template.is_null()) { |
| 360 return base::nullopt; |
| 361 } |
| 362 return base::Optional<Manifest::ShareTarget>(share_target); |
| 363 } |
| 364 |
343 base::NullableString16 ManifestParser::ParseRelatedApplicationPlatform( | 365 base::NullableString16 ManifestParser::ParseRelatedApplicationPlatform( |
344 const base::DictionaryValue& application) { | 366 const base::DictionaryValue& application) { |
345 return ParseString(application, "platform", Trim); | 367 return ParseString(application, "platform", Trim); |
346 } | 368 } |
347 | 369 |
348 GURL ManifestParser::ParseRelatedApplicationURL( | 370 GURL ManifestParser::ParseRelatedApplicationURL( |
349 const base::DictionaryValue& application) { | 371 const base::DictionaryValue& application) { |
350 return ParseURL(application, "url", manifest_url_); | 372 return ParseURL(application, "url", manifest_url_); |
351 } | 373 } |
352 | 374 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 } | 443 } |
422 | 444 |
423 void ManifestParser::AddErrorInfo(const std::string& error_msg, | 445 void ManifestParser::AddErrorInfo(const std::string& error_msg, |
424 bool critical, | 446 bool critical, |
425 int error_line, | 447 int error_line, |
426 int error_column) { | 448 int error_column) { |
427 errors_.push_back({error_msg, critical, error_line, error_column}); | 449 errors_.push_back({error_msg, critical, error_line, error_column}); |
428 } | 450 } |
429 | 451 |
430 } // namespace content | 452 } // namespace content |
OLD | NEW |