Chromium Code Reviews| 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 "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.
| |
| 10 #include "ppapi/c/pp_errors.h" | |
| 11 #include "ppapi/host/dispatch_host_message.h" | |
| 12 #include "ppapi/host/ppapi_host.h" | |
| 13 #include "ppapi/proxy/ppapi_messages.h" | |
| 14 #include "ppapi/proxy/resource_message_params.h" | |
|
yzshen1
2013/04/30 19:31:19
ditto.
victorhsieh
2013/04/30 22:04:32
Done.
| |
| 15 #include "webkit/fileapi/file_system_util.h" | |
| 16 | |
| 17 namespace chrome { | |
| 18 | |
| 19 namespace { | |
| 20 | |
| 21 GURL MakeIsolatedFileSystemUrl(const std::string& origin, | |
| 22 const std::string& fsid) { | |
| 23 return GURL(fileapi::GetIsolatedFileSystemRootURIString( | |
| 24 extensions::Extension::GetBaseURLFromExtensionId(origin), fsid, "crxfs")); | |
| 25 } | |
| 26 | |
| 27 } // namespace | |
| 28 | |
| 29 PepperExtCrxFileSystemRendererHost::PepperExtCrxFileSystemRendererHost( | |
| 30 content::RendererPpapiHost* host, | |
| 31 PP_Instance instance, | |
| 32 PP_Resource resource) | |
| 33 : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource), | |
| 34 opened_(false) { | |
| 35 } | |
| 36 | |
| 37 PepperExtCrxFileSystemRendererHost::~PepperExtCrxFileSystemRendererHost() { | |
| 38 ppapi::host::FileSystemRegistry::GetInstance()->Unregister(pp_instance(), | |
| 39 pp_resource()); | |
| 40 } | |
| 41 | |
| 42 int32_t PepperExtCrxFileSystemRendererHost::OnResourceMessageReceived( | |
| 43 const IPC::Message& msg, | |
| 44 ppapi::host::HostMessageContext* context) { | |
| 45 IPC_BEGIN_MESSAGE_MAP(PepperExtCrxFileSystemRendererHost, msg) | |
| 46 PPAPI_DISPATCH_HOST_RESOURCE_CALL( | |
| 47 PpapiRendererHostMsg_Ext_CrxFileSystem_Open, | |
| 48 OnOpenFileSystem) | |
| 49 IPC_END_MESSAGE_MAP() | |
| 50 return PP_ERROR_FAILED; | |
| 51 } | |
| 52 | |
| 53 PP_FileSystemType PepperExtCrxFileSystemRendererHost::GetType() const { | |
| 54 return PP_FILESYSTEMTYPE_ISOLATED; | |
| 55 } | |
| 56 | |
| 57 bool PepperExtCrxFileSystemRendererHost::IsOpened() const { | |
| 58 return opened_; | |
| 59 } | |
| 60 | |
| 61 const GURL& PepperExtCrxFileSystemRendererHost::GetRootUrl() const { | |
| 62 return root_url_; | |
| 63 } | |
| 64 | |
| 65 int32_t PepperExtCrxFileSystemRendererHost::OnOpenFileSystem( | |
| 66 ppapi::host::HostMessageContext* context, | |
| 67 const std::string& origin, | |
| 68 const std::string& fsid) { | |
| 69 ppapi::host::FileSystemRegistry::GetInstance()->Register(pp_instance(), | |
| 70 pp_resource(), | |
| 71 this); | |
| 72 opened_ = true; | |
| 73 root_url_ = MakeIsolatedFileSystemUrl(origin, fsid); | |
| 74 | |
| 75 ppapi::host::ReplyMessageContext reply_context = | |
| 76 context->MakeReplyMessageContext(); | |
| 77 reply_context.params.set_result(PP_OK); | |
| 78 host()->SendReply( | |
| 79 reply_context, | |
| 80 PpapiPluginMsg_Ext_CrxFileSystem_RendererOpenReply()); | |
| 81 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.
| |
| 82 } | |
| 83 | |
| 84 } // namespace chrome | |
| OLD | NEW |