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

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: review 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 466 // key must be one of kProgramKey or kFileKey '/' file-section-key
Mark Seaborn 2015/04/16 18:47:47 Update this comment (see my comment below)
Yusuke Sato 2015/04/16 20:37:20 Done. I guess we can remove the comment.
467 if (full_url == NULL || pnacl_options == NULL) 467 if (full_url == NULL || pnacl_options == NULL)
468 return false; 468 return false;
469 469
470 if (key == kProgramKey) 470 if (key == kProgramKey)
Mark Seaborn 2015/04/16 18:47:47 Doesn't this case need to be removed now? Otherwi
Yusuke Sato 2015/04/16 20:37:20 Done.
471 return GetKeyUrl(dictionary_, key, full_url, pnacl_options); 471 return GetKeyUrl(dictionary_, key, full_url, pnacl_options);
472 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? 473 // generalize to permit other sections?
Mark Seaborn 2015/04/16 18:47:47 You can remove this since comment it's clear we do
Yusuke Sato 2015/04/16 20:37:20 Done.
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]; 474 const Json::Value& files = dictionary_[kFilesKey];
487 if (!files.isObject()) { 475 if (!files.isObject()) {
488 VLOG(1) << "ResolveKey failed: no \"files\" dictionary"; 476 VLOG(1) << "ResolveKey failed: no \"files\" dictionary";
489 return false; 477 return false;
490 } 478 }
491 479
492 std::string rest(p + 1, key.end()); 480 if (!files.isMember(key)) {
493 if (!files.isMember(rest)) {
494 VLOG(1) << "ResolveKey failed: no such \"files\" entry: " << key; 481 VLOG(1) << "ResolveKey failed: no such \"files\" entry: " << key;
495 return false; 482 return false;
496 } 483 }
497 return GetKeyUrl(files, rest, full_url, pnacl_options); 484 return GetKeyUrl(files, key, full_url, pnacl_options);
498 } 485 }
499 486
500 bool JsonManifest::MatchesSchema(ErrorInfo* error_info) { 487 bool JsonManifest::MatchesSchema(ErrorInfo* error_info) {
501 if (!dictionary_.isObject()) { 488 if (!dictionary_.isObject()) {
502 error_info->error = PP_NACL_ERROR_MANIFEST_SCHEMA_VALIDATE; 489 error_info->error = PP_NACL_ERROR_MANIFEST_SCHEMA_VALIDATE;
503 error_info->string = "manifest: is not a json dictionary."; 490 error_info->string = "manifest: is not a json dictionary.";
504 return false; 491 return false;
505 } 492 }
506 Json::Value::Members members = dictionary_.getMemberNames(); 493 Json::Value::Members members = dictionary_.getMemberNames();
507 for (size_t i = 0; i < members.size(); ++i) { 494 for (size_t i = 0; i < members.size(); ++i) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 } else { 650 } else {
664 // NaCl 651 // NaCl
665 *url = isa_spec[kUrlKey].asString(); 652 *url = isa_spec[kUrlKey].asString();
666 pnacl_options->translate = PP_FALSE; 653 pnacl_options->translate = PP_FALSE;
667 } 654 }
668 655
669 return true; 656 return true;
670 } 657 }
671 658
672 } // namespace nacl 659 } // 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