Chromium Code Reviews| Index: chrome/renderer/pepper/pepper_ext_crx_file_system_renderer_host.cc |
| diff --git a/chrome/renderer/pepper/pepper_ext_crx_file_system_renderer_host.cc b/chrome/renderer/pepper/pepper_ext_crx_file_system_renderer_host.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cd2981e3dc7c26696318c22ba9474101d05927c7 |
| --- /dev/null |
| +++ b/chrome/renderer/pepper/pepper_ext_crx_file_system_renderer_host.cc |
| @@ -0,0 +1,82 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/renderer/pepper/pepper_ext_crx_file_system_renderer_host.h" |
| + |
| +#include "content/public/renderer/renderer_ppapi_host.h" |
| +#include "googleurl/src/gurl.h" |
| +#include "ppapi/c/pp_errors.h" |
| +#include "ppapi/host/dispatch_host_message.h" |
| +#include "ppapi/host/ppapi_host.h" |
| +#include "ppapi/proxy/ppapi_messages.h" |
| +#include "ppapi/proxy/resource_message_params.h" |
| + |
| +namespace chrome { |
| + |
| +namespace { |
| + |
| +GURL MakeIsolatedFileSystemUrl(const std::string& origin, |
| + const std::string& fsid) { |
| + return GURL("filesystem:chrome-extension://" + origin + "/isolated/" + fsid + |
|
kinuko
2013/04/18 13:45:03
I think you'd better use extensions::Extension::G
victorhsieh
2013/04/18 19:28:38
Done.
|
| + "/crxfs/"); |
|
kinuko
2013/04/18 13:45:03
Can we instead use fileapi::GetIsolatedFileSystemR
victorhsieh
2013/04/18 19:28:38
Done.
|
| +} |
| + |
| +} // namespace |
| + |
| +PepperExtCrxFileSystemRendererHost::PepperExtCrxFileSystemRendererHost( |
| + content::RendererPpapiHost* host, |
| + PP_Instance instance, |
| + PP_Resource resource) |
| + : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource), |
| + opened_(false) { |
| +} |
| + |
| +PepperExtCrxFileSystemRendererHost::~PepperExtCrxFileSystemRendererHost() { |
| + ppapi::host::FileSystemRegistry::GetInstance()->Unregister(pp_instance(), |
| + pp_resource()); |
| +} |
| + |
| +int32_t PepperExtCrxFileSystemRendererHost::OnResourceMessageReceived( |
| + const IPC::Message& msg, |
| + ppapi::host::HostMessageContext* context) { |
| + IPC_BEGIN_MESSAGE_MAP(PepperExtCrxFileSystemRendererHost, msg) |
| + PPAPI_DISPATCH_HOST_RESOURCE_CALL( |
| + PpapiRendererHostMsg_Ext_CrxFileSystem_Open, |
| + OnOpenFileSystem) |
| + IPC_END_MESSAGE_MAP() |
| + return PP_ERROR_FAILED; |
| +} |
| + |
| +PP_FileSystemType PepperExtCrxFileSystemRendererHost::GetType() const { |
| + return PP_FILESYSTEMTYPE_ISOLATED; |
| +} |
| + |
| +bool PepperExtCrxFileSystemRendererHost::IsOpened() const { |
| + return opened_; |
| +} |
| + |
| +GURL PepperExtCrxFileSystemRendererHost::GetRootUrl() const { |
| + return root_url_; |
| +} |
| + |
| +int32_t PepperExtCrxFileSystemRendererHost::OnOpenFileSystem( |
| + ppapi::host::HostMessageContext* context, |
| + const std::string& origin, |
| + const std::string& fsid) { |
| + ppapi::host::FileSystemRegistry::GetInstance()->Register(pp_instance(), |
| + pp_resource(), |
| + this); |
| + opened_ = true; |
| + root_url_ = MakeIsolatedFileSystemUrl(origin, fsid); |
| + |
| + ppapi::host::ReplyMessageContext reply_context = |
| + context->MakeReplyMessageContext(); |
| + reply_context.params.set_result(PP_OK); |
| + host()->SendReply( |
| + reply_context, |
| + PpapiPluginMsg_Ext_CrxFileSystem_RendererOpenReply()); |
| + return PP_OK_COMPLETIONPENDING; |
| +} |
| + |
| +} // namespace chrome |