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 "components/nacl/renderer/json_manifest.h" | 5 #include "components/nacl/renderer/json_manifest.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/containers/scoped_ptr_hash_map.h" | 9 #include "base/containers/scoped_ptr_hash_map.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 error_info->string = | 452 error_info->string = |
453 "could not resolve url '" + nexe_url + | 453 "could not resolve url '" + nexe_url + |
454 "' relative to manifest base url '" + manifest_base_url_.c_str() + | 454 "' relative to manifest base url '" + manifest_base_url_.c_str() + |
455 "'."; | 455 "'."; |
456 return false; | 456 return false; |
457 } | 457 } |
458 *full_url = resolved_gurl.possibly_invalid_spec(); | 458 *full_url = resolved_gurl.possibly_invalid_spec(); |
459 return true; | 459 return true; |
460 } | 460 } |
461 | 461 |
| 462 bool JsonManifest::GetFilesUrl(std::vector<std::string>* full_urls, |
| 463 std::vector<std::string>* out_keys) const { |
| 464 if (full_urls == NULL || out_keys == NULL) |
| 465 return false; |
| 466 |
| 467 const Json::Value& files = dictionary_[kFilesKey]; |
| 468 if (!files.isObject()) { |
| 469 VLOG(1) << "ResolveKey failed: no \"files\" dictionary"; |
| 470 return false; |
| 471 } |
| 472 |
| 473 const std::vector<std::string>& keys = files.getMemberNames(); |
| 474 for (size_t i = 0; i < keys.size(); ++i) { |
| 475 std::string full_url; |
| 476 PP_PNaClOptions pnacl_options; |
| 477 if (!GetKeyUrl(files, keys[i], &full_url, &pnacl_options)) |
| 478 return false; |
| 479 full_urls->push_back(full_url); |
| 480 out_keys->push_back(keys[i]); |
| 481 } |
| 482 return true; |
| 483 } |
| 484 |
462 bool JsonManifest::ResolveKey(const std::string& key, | 485 bool JsonManifest::ResolveKey(const std::string& key, |
463 std::string* full_url, | 486 std::string* full_url, |
464 PP_PNaClOptions* pnacl_options) const { | 487 PP_PNaClOptions* pnacl_options) const { |
465 // key must be one of kProgramKey or kFileKey '/' file-section-key | 488 // key must be one of kProgramKey or kFileKey '/' file-section-key |
466 if (full_url == NULL || pnacl_options == NULL) | 489 if (full_url == NULL || pnacl_options == NULL) |
467 return false; | 490 return false; |
468 | 491 |
469 if (key == kProgramKey) | 492 if (key == kProgramKey) |
470 return GetKeyUrl(dictionary_, key, full_url, pnacl_options); | 493 return GetKeyUrl(dictionary_, key, full_url, pnacl_options); |
471 | 494 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 } else { | 685 } else { |
663 // NaCl | 686 // NaCl |
664 *url = isa_spec[kUrlKey].asString(); | 687 *url = isa_spec[kUrlKey].asString(); |
665 pnacl_options->translate = PP_FALSE; | 688 pnacl_options->translate = PP_FALSE; |
666 } | 689 } |
667 | 690 |
668 return true; | 691 return true; |
669 } | 692 } |
670 | 693 |
671 } // namespace nacl | 694 } // namespace nacl |
OLD | NEW |