Skip to content

Commit

Permalink
Allow PPB_NaCl_Private::OpenNaClExecutable to work for shared module …
Browse files Browse the repository at this point in the history
…paths.

This adds logic similar to how URL requests are resolved for
shared module paths in chrome/browser/extensions/extension_protocols.cc.

BUG=237248

Review URL: https://chromiumcodereview.appspot.com/14785009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198240 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
elijahtaylor@chromium.org committed May 3, 2013
1 parent 4ac0d68 commit 4f254f6
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions chrome/browser/nacl_host/nacl_file_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_file_util.h"
#include "chrome/common/extensions/manifest_handlers/shared_module_info.h"
#include "chrome/common/render_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
#include "ipc/ipc_platform_file.h"

using content::BrowserThread;
using extensions::SharedModuleInfo;

namespace {

Expand Down Expand Up @@ -142,9 +144,31 @@ bool GetExtensionFilePath(
if (!extension)
return false;

// Check that the URL references a resource in the extension.
extensions::ExtensionResource resource =
extension->GetResource(file_url.path());
std::string path = file_url.path();
extensions::ExtensionResource resource;

if (SharedModuleInfo::IsImportedPath(path)) {
// Check if this is a valid path that is imported for this extension.
std::string new_extension_id;
std::string new_relative_path;
SharedModuleInfo::ParseImportedPath(path, &new_extension_id,
&new_relative_path);
const extensions::Extension* new_extension =
extension_info_map->extensions().GetByID(new_extension_id);
if (!new_extension)
return false;

if (!SharedModuleInfo::ImportsExtensionById(extension, new_extension_id) ||
!SharedModuleInfo::IsExportAllowed(new_extension, new_relative_path)) {
return false;
}

resource = new_extension->GetResource(new_relative_path);
} else {
// Check that the URL references a resource in the extension.
resource = extension->GetResource(path);
}

if (resource.empty())
return false;

Expand Down

0 comments on commit 4f254f6

Please sign in to comment.