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

Unified Diff: content/renderer/pepper/pepper_file_io_host.cc

Issue 18063005: Do PPB_FileIO Query and Read in the plugin process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tighten up ReadValidated. Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/pepper/pepper_file_io_host.h ('k') | ppapi/proxy/file_io_resource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/pepper_file_io_host.cc
diff --git a/content/renderer/pepper/pepper_file_io_host.cc b/content/renderer/pepper/pepper_file_io_host.cc
index 5a6d40ce5c9193ad6aeec494bc0ee45217bcaed6..52b5f285b2e0dd2daa6a4dd481a1b662883856ed 100644
--- a/content/renderer/pepper/pepper_file_io_host.cc
+++ b/content/renderer/pepper/pepper_file_io_host.cc
@@ -22,6 +22,7 @@
#include "content/renderer/pepper/quota_file_io.h"
#include "content/renderer/render_thread_impl.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_file_io.h"
#include "ppapi/host/dispatch_host_message.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/proxy/ppapi_messages.h"
@@ -142,6 +143,7 @@ PepperFileIOHost::PepperFileIOHost(RendererPpapiHost* host,
PP_Instance instance,
PP_Resource resource)
: ResourceHost(host->GetPpapiHost(), instance, resource),
+ renderer_ppapi_host_(host),
file_(base::kInvalidPlatformFileValue),
file_system_type_(PP_FILESYSTEMTYPE_INVALID),
quota_policy_(quota::kQuotaLimitTypeUnknown),
@@ -520,16 +522,13 @@ int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle(
quota_policy_ != quota::kQuotaLimitTypeUnlimited)
return PP_ERROR_FAILED;
- RendererPpapiHost* renderer_ppapi_host =
- RendererPpapiHost::GetForPPInstance(pp_instance());
-
// Whitelist to make it privately accessible.
if (!GetContentClient()->renderer()->IsPluginAllowedToCallRequestOSFileHandle(
- renderer_ppapi_host->GetContainerForInstance(pp_instance())))
+ renderer_ppapi_host_->GetContainerForInstance(pp_instance())))
return PP_ERROR_NOACCESS;
IPC::PlatformFileForTransit file =
- renderer_ppapi_host->ShareHandleWithRemote(file_, false);
+ renderer_ppapi_host_->ShareHandleWithRemote(file_, false);
if (file == IPC::InvalidPlatformFileForTransit())
return PP_ERROR_FAILED;
ppapi::host::ReplyMessageContext reply_context =
@@ -582,11 +581,26 @@ void PepperFileIOHost::ExecutePlatformOpenFileCallback(
file_ = file.ReleaseValue();
DCHECK(!quota_file_io_.get());
- if (file_ != base::kInvalidPlatformFileValue &&
- (file_system_type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ||
- file_system_type_ == PP_FILESYSTEMTYPE_LOCALPERSISTENT)) {
- quota_file_io_.reset(new QuotaFileIO(
- new QuotaFileIODelegate, file_, file_system_url_, file_system_type_));
+ if (file_ != base::kInvalidPlatformFileValue) {
+ if (file_system_type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ||
+ file_system_type_ == PP_FILESYSTEMTYPE_LOCALPERSISTENT) {
+ quota_file_io_.reset(new QuotaFileIO(
+ new QuotaFileIODelegate, file_, file_system_url_, file_system_type_));
+ }
+
+ IPC::PlatformFileForTransit file_for_transit =
+ renderer_ppapi_host_->ShareHandleWithRemote(file_, false);
+ if (!(file_for_transit == IPC::InvalidPlatformFileForTransit())) {
+ // Send the file descriptor to the plugin process. This is used in the
+ // plugin for any file operations that can be done there.
+ // IMPORTANT: Clear PP_FILEOPENFLAG_WRITE and PP_FILEOPENFLAG_APPEND so
+ // the plugin can't write and so bypass our quota checks.
+ int32_t no_write_flags =
+ open_flags_ & ~(PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_APPEND);
+ ppapi::proxy::SerializedHandle file_handle;
+ file_handle.set_file_handle(file_for_transit, no_write_flags);
+ reply_context.params.AppendHandle(file_handle);
+ }
}
reply_context.params.set_result(pp_error);
« no previous file with comments | « content/renderer/pepper/pepper_file_io_host.h ('k') | ppapi/proxy/file_io_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698