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

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

Issue 261143002: Pepper: Remove file_utils from trusted plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/api/private/ppb_nacl_private.idl » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ppb_nacl_private_impl.h" 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/containers/scoped_ptr_hash_map.h" 10 #include "base/containers/scoped_ptr_hash_map.h"
(...skipping 30 matching lines...) Expand all
41 #include "ppapi/shared_impl/ppapi_preferences.h" 41 #include "ppapi/shared_impl/ppapi_preferences.h"
42 #include "ppapi/shared_impl/var.h" 42 #include "ppapi/shared_impl/var.h"
43 #include "ppapi/thunk/enter.h" 43 #include "ppapi/thunk/enter.h"
44 #include "third_party/WebKit/public/platform/WebURLLoader.h" 44 #include "third_party/WebKit/public/platform/WebURLLoader.h"
45 #include "third_party/WebKit/public/web/WebDocument.h" 45 #include "third_party/WebKit/public/web/WebDocument.h"
46 #include "third_party/WebKit/public/web/WebElement.h" 46 #include "third_party/WebKit/public/web/WebElement.h"
47 #include "third_party/WebKit/public/web/WebLocalFrame.h" 47 #include "third_party/WebKit/public/web/WebLocalFrame.h"
48 #include "third_party/WebKit/public/web/WebPluginContainer.h" 48 #include "third_party/WebKit/public/web/WebPluginContainer.h"
49 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 49 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
50 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" 50 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h"
51 #include "third_party/jsoncpp/source/include/json/reader.h"
52 #include "third_party/jsoncpp/source/include/json/value.h"
51 53
52 namespace nacl { 54 namespace nacl {
53 namespace { 55 namespace {
54 56
55 base::LazyInstance<scoped_refptr<PnaclTranslationResourceHost> > 57 base::LazyInstance<scoped_refptr<PnaclTranslationResourceHost> >
56 g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER; 58 g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER;
57 59
58 bool InitializePnaclResourceHost() { 60 bool InitializePnaclResourceHost() {
59 // Must run on the main thread. 61 // Must run on the main thread.
60 content::RenderThread* render_thread = content::RenderThread::Get(); 62 content::RenderThread* render_thread = content::RenderThread::Get();
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 if (it == g_manifest_map.Get().end()) 1105 if (it == g_manifest_map.Get().end())
1104 return PP_FALSE; 1106 return PP_FALSE;
1105 1107
1106 std::string full_url; 1108 std::string full_url;
1107 bool ok = it->second->ResolveKey(key, &full_url, pnacl_options); 1109 bool ok = it->second->ResolveKey(key, &full_url, pnacl_options);
1108 if (ok) 1110 if (ok)
1109 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url); 1111 *pp_full_url = ppapi::StringVar::StringToPPVar(full_url);
1110 return PP_FromBool(ok); 1112 return PP_FromBool(ok);
1111 } 1113 }
1112 1114
1115 PP_Bool GetPNaClResourceInfo(PP_Instance instance,
1116 const char* filename,
1117 PP_Var* llc_tool_name,
1118 PP_Var* ld_tool_name) {
1119 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
1120 DCHECK(load_manager);
1121 if (!load_manager)
1122 return PP_FALSE;
1123
1124 base::PlatformFile file = GetReadonlyPnaclFD(filename);
1125 if (file == base::kInvalidPlatformFileValue) {
1126 load_manager->ReportLoadError(
1127 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1128 "The Portable Native Client (pnacl) component is not "
1129 "installed. Please consult chrome://components for more "
1130 "information.");
1131 return PP_FALSE;
1132 }
1133
1134 const int kBufferSize = 1 << 20;
1135 scoped_ptr<char[]> buffer(new char[kBufferSize]);
1136 if (base::ReadPlatformFile(file, 0, buffer.get(), kBufferSize) < 0) {
1137 load_manager->ReportLoadError(
1138 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1139 std::string("PnaclResources::ReadResourceInfo reading failed for: ") +
1140 filename);
1141 return PP_FALSE;
1142 }
1143
1144 // Expect the JSON file to contain a top-level object (dictionary).
1145 Json::Reader json_reader;
1146 Json::Value json_data;
1147 if (!json_reader.parse(buffer.get(), json_data)) {
1148 load_manager->ReportLoadError(
1149 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1150 std::string("Parsing resource info failed: JSON parse error: ") +
1151 json_reader.getFormattedErrorMessages());
1152 return PP_FALSE;
1153 }
1154
1155 if (!json_data.isObject()) {
1156 load_manager->ReportLoadError(
1157 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1158 "Parsing resource info failed: Malformed JSON dictionary");
1159 return PP_FALSE;
1160 }
1161
1162 if (json_data.isMember("pnacl-llc-name")) {
1163 Json::Value json_name = json_data["pnacl-llc-name"];
1164 if (json_name.isString()) {
1165 std::string llc_tool_name_str = json_name.asString();
1166 *llc_tool_name = ppapi::StringVar::StringToPPVar(llc_tool_name_str);
1167 }
1168 }
1169
1170 if (json_data.isMember("pnacl-ld-name")) {
1171 Json::Value json_name = json_data["pnacl-ld-name"];
1172 if (json_name.isString()) {
1173 std::string ld_tool_name_str = json_name.asString();
1174 *ld_tool_name = ppapi::StringVar::StringToPPVar(ld_tool_name_str);
1175 }
1176 }
1177 return PP_TRUE;
1178 }
1179
1113 const PPB_NaCl_Private nacl_interface = { 1180 const PPB_NaCl_Private nacl_interface = {
1114 &LaunchSelLdr, 1181 &LaunchSelLdr,
1115 &StartPpapiProxy, 1182 &StartPpapiProxy,
1116 &UrandomFD, 1183 &UrandomFD,
1117 &Are3DInterfacesDisabled, 1184 &Are3DInterfacesDisabled,
1118 &BrokerDuplicateHandle, 1185 &BrokerDuplicateHandle,
1119 &GetReadonlyPnaclFD, 1186 &GetReadonlyPnaclFD,
1120 &CreateTemporaryFile, 1187 &CreateTemporaryFile,
1121 &GetNumberOfProcessors, 1188 &GetNumberOfProcessors,
1122 &IsNonSFIModeEnabled, 1189 &IsNonSFIModeEnabled,
(...skipping 24 matching lines...) Expand all
1147 &ParseDataURL, 1214 &ParseDataURL,
1148 &ProcessNaClManifest, 1215 &ProcessNaClManifest,
1149 &GetManifestURLArgument, 1216 &GetManifestURLArgument,
1150 &IsPNaCl, 1217 &IsPNaCl,
1151 &DevInterfacesEnabled, 1218 &DevInterfacesEnabled,
1152 &DownloadManifestToBuffer, 1219 &DownloadManifestToBuffer,
1153 &CreatePNaClManifest, 1220 &CreatePNaClManifest,
1154 &CreateJsonManifest, 1221 &CreateJsonManifest,
1155 &DestroyManifest, 1222 &DestroyManifest,
1156 &ManifestGetProgramURL, 1223 &ManifestGetProgramURL,
1157 &ManifestResolveKey 1224 &ManifestResolveKey,
1225 &GetPNaClResourceInfo
1158 }; 1226 };
1159 1227
1160 } // namespace 1228 } // namespace
1161 1229
1162 const PPB_NaCl_Private* GetNaClPrivateInterface() { 1230 const PPB_NaCl_Private* GetNaClPrivateInterface() {
1163 return &nacl_interface; 1231 return &nacl_interface;
1164 } 1232 }
1165 1233
1166 } // namespace nacl 1234 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | ppapi/api/private/ppb_nacl_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698