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..36050cad49321edbaeaeae9f94f953f383044858 |
| --- /dev/null |
| +++ b/chrome/renderer/pepper/pepper_ext_crx_file_system_renderer_host.cc |
| @@ -0,0 +1,84 @@ |
| +// 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 "chrome/common/extensions/extension.h" |
| +#include "content/public/renderer/renderer_ppapi_host.h" |
| +#include "googleurl/src/gurl.h" |
|
yzshen1
2013/04/30 19:31:19
you already include this in .h.
victorhsieh
2013/04/30 22:04:32
Done.
|
| +#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" |
|
yzshen1
2013/04/30 19:31:19
ditto.
victorhsieh
2013/04/30 22:04:32
Done.
|
| +#include "webkit/fileapi/file_system_util.h" |
| + |
| +namespace chrome { |
| + |
| +namespace { |
| + |
| +GURL MakeIsolatedFileSystemUrl(const std::string& origin, |
| + const std::string& fsid) { |
| + return GURL(fileapi::GetIsolatedFileSystemRootURIString( |
| + extensions::Extension::GetBaseURLFromExtensionId(origin), fsid, "crxfs")); |
| +} |
| + |
| +} // 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_; |
| +} |
| + |
| +const 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; |
|
yzshen1
2013/04/30 19:31:19
You could set the context->reply_msg and directly
victorhsieh
2013/04/30 22:04:32
Done.
|
| +} |
| + |
| +} // namespace chrome |