OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/renderer/pepper/pepper_ext_crx_file_system_renderer_host.h" |
| 6 |
| 7 #include "chrome/common/extensions/extension.h" |
| 8 #include "content/public/renderer/renderer_ppapi_host.h" |
| 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/host/dispatch_host_message.h" |
| 11 #include "ppapi/host/ppapi_host.h" |
| 12 #include "ppapi/proxy/ppapi_messages.h" |
| 13 #include "webkit/fileapi/file_system_util.h" |
| 14 |
| 15 namespace chrome { |
| 16 |
| 17 namespace { |
| 18 |
| 19 GURL MakeIsolatedFileSystemUrl(const std::string& origin, |
| 20 const std::string& fsid) { |
| 21 return GURL(fileapi::GetIsolatedFileSystemRootURIString( |
| 22 extensions::Extension::GetBaseURLFromExtensionId(origin), fsid, "crxfs")); |
| 23 } |
| 24 |
| 25 } // namespace |
| 26 |
| 27 PepperExtCrxFileSystemRendererHost::PepperExtCrxFileSystemRendererHost( |
| 28 content::RendererPpapiHost* host, |
| 29 PP_Instance instance, |
| 30 PP_Resource resource) |
| 31 : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource), |
| 32 opened_(false) { |
| 33 } |
| 34 |
| 35 PepperExtCrxFileSystemRendererHost::~PepperExtCrxFileSystemRendererHost() { |
| 36 ppapi::host::FileSystemRegistry::GetInstance()->Unregister(pp_instance(), |
| 37 pp_resource()); |
| 38 } |
| 39 |
| 40 int32_t PepperExtCrxFileSystemRendererHost::OnResourceMessageReceived( |
| 41 const IPC::Message& msg, |
| 42 ppapi::host::HostMessageContext* context) { |
| 43 IPC_BEGIN_MESSAGE_MAP(PepperExtCrxFileSystemRendererHost, msg) |
| 44 PPAPI_DISPATCH_HOST_RESOURCE_CALL( |
| 45 PpapiHostMsg_Ext_CrxFileSystem_RendererOpen, |
| 46 OnOpenFileSystem) |
| 47 IPC_END_MESSAGE_MAP() |
| 48 return PP_ERROR_FAILED; |
| 49 } |
| 50 |
| 51 PP_FileSystemType PepperExtCrxFileSystemRendererHost::GetType() const { |
| 52 return PP_FILESYSTEMTYPE_ISOLATED; |
| 53 } |
| 54 |
| 55 bool PepperExtCrxFileSystemRendererHost::IsOpened() const { |
| 56 return opened_; |
| 57 } |
| 58 |
| 59 const GURL& PepperExtCrxFileSystemRendererHost::GetRootUrl() const { |
| 60 return root_url_; |
| 61 } |
| 62 |
| 63 int32_t PepperExtCrxFileSystemRendererHost::OnOpenFileSystem( |
| 64 ppapi::host::HostMessageContext* context, |
| 65 const std::string& origin, |
| 66 const std::string& fsid) { |
| 67 ppapi::host::FileSystemRegistry::GetInstance()->Register(pp_instance(), |
| 68 pp_resource(), |
| 69 this); |
| 70 opened_ = true; |
| 71 root_url_ = MakeIsolatedFileSystemUrl(origin, fsid); |
| 72 |
| 73 context->reply_msg = |
| 74 PpapiPluginMsg_Ext_CrxFileSystem_RendererOpenReply(); |
| 75 return PP_OK; |
| 76 } |
| 77 |
| 78 } // namespace chrome |
OLD | NEW |