| 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 Manifest::ShareTarget ManifestParser::ParseShareTarget( |
| 350 const base::DictionaryValue& dictionary) { |
| 351 Manifest::ShareTarget share_target; |
| 352 if (!dictionary.HasKey("share_target")) |
| 353 return share_target; |
| 354 |
| 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 return share_target; |
| 359 } |
| 360 |
| 343 base::NullableString16 ManifestParser::ParseRelatedApplicationPlatform( | 361 base::NullableString16 ManifestParser::ParseRelatedApplicationPlatform( |
| 344 const base::DictionaryValue& application) { | 362 const base::DictionaryValue& application) { |
| 345 return ParseString(application, "platform", Trim); | 363 return ParseString(application, "platform", Trim); |
| 346 } | 364 } |
| 347 | 365 |
| 348 GURL ManifestParser::ParseRelatedApplicationURL( | 366 GURL ManifestParser::ParseRelatedApplicationURL( |
| 349 const base::DictionaryValue& application) { | 367 const base::DictionaryValue& application) { |
| 350 return ParseURL(application, "url", manifest_url_); | 368 return ParseURL(application, "url", manifest_url_); |
| 351 } | 369 } |
| 352 | 370 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 } | 439 } |
| 422 | 440 |
| 423 void ManifestParser::AddErrorInfo(const std::string& error_msg, | 441 void ManifestParser::AddErrorInfo(const std::string& error_msg, |
| 424 bool critical, | 442 bool critical, |
| 425 int error_line, | 443 int error_line, |
| 426 int error_column) { | 444 int error_column) { |
| 427 errors_.push_back({error_msg, critical, error_line, error_column}); | 445 errors_.push_back({error_msg, critical, error_line, error_column}); |
| 428 } | 446 } |
| 429 | 447 |
| 430 } // namespace content | 448 } // namespace content |
| OLD | NEW |