| Index: components/nacl/renderer/ppb_nacl_private_impl.cc
|
| diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
|
| index 7986cf021b0ef47bcd87888aa24834560e521415..2a4bd3890a7b7f074d5fe2f799bff0399e5ac85f 100644
|
| --- a/components/nacl/renderer/ppb_nacl_private_impl.cc
|
| +++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
|
| @@ -40,6 +40,8 @@
|
| #include "ppapi/shared_impl/ppapi_preferences.h"
|
| #include "ppapi/shared_impl/var.h"
|
| #include "ppapi/thunk/enter.h"
|
| +#include "third_party/jsoncpp/source/include/json/reader.h"
|
| +#include "third_party/jsoncpp/source/include/json/value.h"
|
| #include "third_party/WebKit/public/platform/WebURLLoader.h"
|
| #include "third_party/WebKit/public/web/WebDocument.h"
|
| #include "third_party/WebKit/public/web/WebElement.h"
|
| @@ -961,6 +963,71 @@ void DownloadManifestToBufferCompletion(PP_Instance instance,
|
| callback.func(callback.user_data, pp_error);
|
| }
|
|
|
| +PP_Bool GetPNaClResourceInfo(PP_Instance instance,
|
| + const char* filename,
|
| + PP_Var* llc_tool_name,
|
| + PP_Var* ld_tool_name) {
|
| + NexeLoadManager* load_manager = GetNexeLoadManager(instance);
|
| + DCHECK(load_manager);
|
| + if (!load_manager)
|
| + return PP_FALSE;
|
| +
|
| + base::PlatformFile file = GetReadonlyPnaclFD(filename);
|
| + if (file == base::kInvalidPlatformFileValue) {
|
| + load_manager->ReportLoadError(
|
| + PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
|
| + "The Portable Native Client (pnacl) component is not "
|
| + "installed. Please consult chrome://components for more "
|
| + "information.");
|
| + return PP_FALSE;
|
| + }
|
| +
|
| + const int kBufferSize = 1 << 20;
|
| + scoped_ptr<char> buffer(new char[kBufferSize]);
|
| + if (base::ReadPlatformFile(file, 0, buffer.get(), kBufferSize) < 0) {
|
| + load_manager->ReportLoadError(
|
| + PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
|
| + std::string("PnaclResources::ReadResourceInfo reading failed for: ") +
|
| + filename);
|
| + return PP_FALSE;
|
| + }
|
| +
|
| + // Expect the JSON file to contain a top-level object (dictionary).
|
| + Json::Reader json_reader;
|
| + Json::Value json_data;
|
| + if (!json_reader.parse(buffer.get(), json_data)) {
|
| + load_manager->ReportLoadError(
|
| + PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
|
| + std::string("Parsing resource info failed: JSON parse error: ") +
|
| + json_reader.getFormattedErrorMessages());
|
| + return PP_FALSE;
|
| + }
|
| +
|
| + if (!json_data.isObject()) {
|
| + load_manager->ReportLoadError(
|
| + PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
|
| + "Parsing resource info failed: Malformed JSON dictionary");
|
| + return PP_FALSE;
|
| + }
|
| +
|
| + if (json_data.isMember("pnacl-llc-name")) {
|
| + Json::Value json_name = json_data["pnacl-llc-name"];
|
| + if (json_name.isString()) {
|
| + std::string llc_tool_name_str = json_name.asString();
|
| + *llc_tool_name = ppapi::StringVar::StringToPPVar(llc_tool_name_str);
|
| + }
|
| + }
|
| +
|
| + if (json_data.isMember("pnacl-ld-name")) {
|
| + Json::Value json_name = json_data["pnacl-ld-name"];
|
| + if (json_name.isString()) {
|
| + std::string ld_tool_name_str = json_name.asString();
|
| + *ld_tool_name = ppapi::StringVar::StringToPPVar(ld_tool_name_str);
|
| + }
|
| + }
|
| + return PP_TRUE;
|
| +}
|
| +
|
| const PPB_NaCl_Private nacl_interface = {
|
| &LaunchSelLdr,
|
| &StartPpapiProxy,
|
| @@ -1000,7 +1067,8 @@ const PPB_NaCl_Private nacl_interface = {
|
| &GetManifestURLArgument,
|
| &IsPNaCl,
|
| &DevInterfacesEnabled,
|
| - &DownloadManifestToBuffer
|
| + &DownloadManifestToBuffer,
|
| + &GetPNaClResourceInfo
|
| };
|
|
|
| } // namespace
|
|
|