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

Side by Side Diff: components/nacl/renderer/json_manifest.cc

Issue 1070233007: Stop adding the "files/" prefix when sending open_resource IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 8 months 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
« no previous file with comments | « no previous file | components/nacl/renderer/ppb_nacl_private_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 if (GetKeyUrl(files, keys[i], &full_url, &unused_pnacl_options)) { 456 if (GetKeyUrl(files, keys[i], &full_url, &unused_pnacl_options)) {
457 if (GURL(full_url).SchemeIs("chrome-extension")) 457 if (GURL(full_url).SchemeIs("chrome-extension"))
458 out_files->push_back(std::make_pair(keys[i], full_url)); 458 out_files->push_back(std::make_pair(keys[i], full_url));
459 } 459 }
460 } 460 }
461 } 461 }
462 462
463 bool JsonManifest::ResolveKey(const std::string& key, 463 bool JsonManifest::ResolveKey(const std::string& key,
464 std::string* full_url, 464 std::string* full_url,
465 PP_PNaClOptions* pnacl_options) const { 465 PP_PNaClOptions* pnacl_options) const {
466 // key must be one of kProgramKey or kFileKey '/' file-section-key
467 if (full_url == NULL || pnacl_options == NULL) 466 if (full_url == NULL || pnacl_options == NULL)
468 return false; 467 return false;
469 468
470 if (key == kProgramKey)
Mark Seaborn 2015/04/16 20:45:14 In the commit message, can you comment that kProgr
471 return GetKeyUrl(dictionary_, key, full_url, pnacl_options);
472
473 std::string::const_iterator p = std::find(key.begin(), key.end(), '/');
474 if (p == key.end()) {
475 VLOG(1) << "ResolveKey failed: invalid key, no slash: " << key;
476 return false;
477 }
478
479 // generalize to permit other sections?
480 std::string prefix(key.begin(), p);
481 if (prefix != kFilesKey) {
482 VLOG(1) << "ResolveKey failed: invalid key, no \"files\" prefix: " << key;
483 return false;
484 }
485
486 const Json::Value& files = dictionary_[kFilesKey]; 469 const Json::Value& files = dictionary_[kFilesKey];
487 if (!files.isObject()) { 470 if (!files.isObject()) {
488 VLOG(1) << "ResolveKey failed: no \"files\" dictionary"; 471 VLOG(1) << "ResolveKey failed: no \"files\" dictionary";
489 return false; 472 return false;
490 } 473 }
491 474
492 std::string rest(p + 1, key.end()); 475 if (!files.isMember(key)) {
493 if (!files.isMember(rest)) {
494 VLOG(1) << "ResolveKey failed: no such \"files\" entry: " << key; 476 VLOG(1) << "ResolveKey failed: no such \"files\" entry: " << key;
495 return false; 477 return false;
496 } 478 }
497 return GetKeyUrl(files, rest, full_url, pnacl_options); 479 return GetKeyUrl(files, key, full_url, pnacl_options);
498 } 480 }
499 481
500 bool JsonManifest::MatchesSchema(ErrorInfo* error_info) { 482 bool JsonManifest::MatchesSchema(ErrorInfo* error_info) {
501 if (!dictionary_.isObject()) { 483 if (!dictionary_.isObject()) {
502 error_info->error = PP_NACL_ERROR_MANIFEST_SCHEMA_VALIDATE; 484 error_info->error = PP_NACL_ERROR_MANIFEST_SCHEMA_VALIDATE;
503 error_info->string = "manifest: is not a json dictionary."; 485 error_info->string = "manifest: is not a json dictionary.";
504 return false; 486 return false;
505 } 487 }
506 Json::Value::Members members = dictionary_.getMemberNames(); 488 Json::Value::Members members = dictionary_.getMemberNames();
507 for (size_t i = 0; i < members.size(); ++i) { 489 for (size_t i = 0; i < members.size(); ++i) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 } else { 645 } else {
664 // NaCl 646 // NaCl
665 *url = isa_spec[kUrlKey].asString(); 647 *url = isa_spec[kUrlKey].asString();
666 pnacl_options->translate = PP_FALSE; 648 pnacl_options->translate = PP_FALSE;
667 } 649 }
668 650
669 return true; 651 return true;
670 } 652 }
671 653
672 } // namespace nacl 654 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | components/nacl/renderer/ppb_nacl_private_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698