Commit c70eae7d authored by teravest@chromium.org's avatar teravest@chromium.org

Pepper: Make ManifestResolveKey resuable.

I'd like to simplify the OpenResource implementation for the Non-SFI case. I
think that this can all stop using the trusted plugin now; this change makes
the ManifestResolveKey method easier to use from within
ppb_nacl_private_impl.cc.

BUG=239656

Review URL: https://codereview.chromium.org/329593002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276802 0039d316-1c4b-4281-b951-d872f2087c98
parent b9e9992a
...@@ -1000,39 +1000,48 @@ PP_Bool ManifestGetProgramURL(PP_Instance instance, ...@@ -1000,39 +1000,48 @@ PP_Bool ManifestGetProgramURL(PP_Instance instance,
return PP_FALSE; return PP_FALSE;
} }
PP_Bool ManifestResolveKey(PP_Instance instance, bool ManifestResolveKey(PP_Instance instance,
PP_Bool is_helper_process, bool is_helper_process,
const char* key, const std::string& key,
PP_Var* pp_full_url, std::string* full_url,
PP_PNaClOptions* pnacl_options) { PP_PNaClOptions* pnacl_options) {
// For "helper" processes (llc and ld), we resolve keys manually as there is // For "helper" processes (llc and ld), we resolve keys manually as there is
// no existing .nmf file to parse. // no existing .nmf file to parse.
if (PP_ToBool(is_helper_process)) { if (is_helper_process) {
pnacl_options->translate = PP_FALSE; pnacl_options->translate = PP_FALSE;
// We can only resolve keys in the files/ namespace. // We can only resolve keys in the files/ namespace.
const std::string kFilesPrefix = "files/"; const std::string kFilesPrefix = "files/";
std::string key_string(key); if (key.find(kFilesPrefix) == std::string::npos) {
if (key_string.find(kFilesPrefix) == std::string::npos) {
nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
if (load_manager) if (load_manager)
load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL,
"key did not start with files/"); "key did not start with files/");
return PP_FALSE; return false;
} }
std::string key_basename = key_string.substr(kFilesPrefix.length()); std::string key_basename = key.substr(kFilesPrefix.length());
std::string pnacl_url = *full_url = std::string(kPNaClTranslatorBaseUrl) + GetSandboxArch() + "/" +
std::string(kPNaClTranslatorBaseUrl) + GetSandboxArch() + "/" + key_basename;
key_basename; return true;
*pp_full_url = ppapi::StringVar::StringToPPVar(pnacl_url);
return PP_TRUE;
} }
JsonManifest* manifest = GetJsonManifest(instance); JsonManifest* manifest = GetJsonManifest(instance);
if (manifest == NULL) if (manifest == NULL)
return PP_FALSE; return false;
return manifest->ResolveKey(key, full_url, pnacl_options);
}
PP_Bool ExternalManifestResolveKey(PP_Instance instance,
PP_Bool is_helper_process,
const char* key,
PP_Var* pp_full_url,
PP_PNaClOptions* pnacl_options) {
std::string full_url; std::string full_url;
bool ok = manifest->ResolveKey(key, &full_url, pnacl_options); bool ok = ManifestResolveKey(instance,
PP_ToBool(is_helper_process),
std::string(key),
&full_url,
pnacl_options);
if (ok) if (ok)
*pp_full_url = ppapi::StringVar::StringToPPVar(full_url); *pp_full_url = ppapi::StringVar::StringToPPVar(full_url);
return PP_FromBool(ok); return PP_FromBool(ok);
...@@ -1499,7 +1508,7 @@ const PPB_NaCl_Private nacl_interface = { ...@@ -1499,7 +1508,7 @@ const PPB_NaCl_Private nacl_interface = {
&ProcessNaClManifest, &ProcessNaClManifest,
&DevInterfacesEnabled, &DevInterfacesEnabled,
&ManifestGetProgramURL, &ManifestGetProgramURL,
&ManifestResolveKey, &ExternalManifestResolveKey,
&GetPNaClResourceInfo, &GetPNaClResourceInfo,
&GetCpuFeatureAttrs, &GetCpuFeatureAttrs,
&PostMessageToJavaScript, &PostMessageToJavaScript,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment