| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ppapi/native_client/src/trusted/plugin/json_manifest.h" | 9 #include "ppapi/native_client/src/trusted/plugin/json_manifest.h" |
| 10 | 10 |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 const Json::Value& isa_dict = dictionary[key]; | 573 const Json::Value& isa_dict = dictionary[key]; |
| 574 nacl::string relative_url; | 574 nacl::string relative_url; |
| 575 bool uses_nonsfi_mode; | 575 bool uses_nonsfi_mode; |
| 576 if (!GetURLFromISADictionary(isa_dict, key, &relative_url, | 576 if (!GetURLFromISADictionary(isa_dict, key, &relative_url, |
| 577 pnacl_options, &uses_nonsfi_mode, error_info)) { | 577 pnacl_options, &uses_nonsfi_mode, error_info)) { |
| 578 return false; | 578 return false; |
| 579 } | 579 } |
| 580 return ResolveURL(relative_url, full_url, error_info); | 580 return ResolveURL(relative_url, full_url, error_info); |
| 581 } | 581 } |
| 582 | 582 |
| 583 bool JsonManifest::ResolveURL(const nacl::string& relative_url, | |
| 584 nacl::string* full_url, | |
| 585 ErrorInfo* error_info) const { | |
| 586 // The contents of the manifest are resolved relative to the manifest URL. | |
| 587 CHECK(url_util_ != NULL); | |
| 588 pp::Var resolved_url = | |
| 589 url_util_->ResolveRelativeToURL(pp::Var(manifest_base_url_), | |
| 590 relative_url); | |
| 591 if (!resolved_url.is_string()) { | |
| 592 error_info->SetReport( | |
| 593 PP_NACL_ERROR_MANIFEST_RESOLVE_URL, | |
| 594 "could not resolve url '" + relative_url + | |
| 595 "' relative to manifest base url '" + manifest_base_url_.c_str() + | |
| 596 "'."); | |
| 597 return false; | |
| 598 } | |
| 599 *full_url = resolved_url.AsString(); | |
| 600 return true; | |
| 601 } | |
| 602 | |
| 603 bool JsonManifest::GetProgramURL(nacl::string* full_url, | 583 bool JsonManifest::GetProgramURL(nacl::string* full_url, |
| 604 PnaclOptions* pnacl_options, | 584 PnaclOptions* pnacl_options, |
| 605 bool* uses_nonsfi_mode, | 585 bool* uses_nonsfi_mode, |
| 606 ErrorInfo* error_info) const { | 586 ErrorInfo* error_info) const { |
| 607 if (full_url == NULL || pnacl_options == NULL || error_info == NULL) | 587 if (full_url == NULL || pnacl_options == NULL || error_info == NULL) |
| 608 return false; | 588 return false; |
| 609 | 589 |
| 610 const Json::Value& program = dictionary_[kProgramKey]; | 590 const Json::Value& program = dictionary_[kProgramKey]; |
| 611 | 591 |
| 612 nacl::string nexe_url; | 592 nacl::string nexe_url; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 } | 659 } |
| 680 if (!files.isMember(rest)) { | 660 if (!files.isMember(rest)) { |
| 681 error_info->SetReport( | 661 error_info->SetReport( |
| 682 PP_NACL_ERROR_MANIFEST_RESOLVE_URL, | 662 PP_NACL_ERROR_MANIFEST_RESOLVE_URL, |
| 683 nacl::string("ResolveKey: no such \"files\" entry: ") + key); | 663 nacl::string("ResolveKey: no such \"files\" entry: ") + key); |
| 684 return false; | 664 return false; |
| 685 } | 665 } |
| 686 return GetKeyUrl(files, rest, full_url, pnacl_options, error_info); | 666 return GetKeyUrl(files, rest, full_url, pnacl_options, error_info); |
| 687 } | 667 } |
| 688 | 668 |
| 669 bool JsonManifest::ResolveURL(const nacl::string& relative_url, |
| 670 nacl::string* full_url, |
| 671 ErrorInfo* error_info) const { |
| 672 // The contents of the manifest are resolved relative to the manifest URL. |
| 673 CHECK(url_util_ != NULL); |
| 674 pp::Var resolved_url = |
| 675 url_util_->ResolveRelativeToURL(pp::Var(manifest_base_url_), |
| 676 relative_url); |
| 677 if (!resolved_url.is_string()) { |
| 678 error_info->SetReport( |
| 679 PP_NACL_ERROR_MANIFEST_RESOLVE_URL, |
| 680 "could not resolve url '" + relative_url + |
| 681 "' relative to manifest base url '" + manifest_base_url_.c_str() + |
| 682 "'."); |
| 683 return false; |
| 684 } |
| 685 *full_url = resolved_url.AsString(); |
| 686 return true; |
| 687 } |
| 688 |
| 689 } // namespace plugin | 689 } // namespace plugin |
| OLD | NEW |