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 "content/public/renderer/renderer_ppapi_host.h" | |
8 #include "googleurl/src/gurl.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 "ppapi/proxy/resource_message_params.h" | |
14 | |
15 namespace chrome { | |
16 | |
17 namespace { | |
18 | |
19 GURL MakeIsolatedFileSystemUrl(const std::string& origin, | |
20 const std::string& fsid) { | |
21 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.
| |
22 "/crxfs/"); | |
kinuko
2013/04/18 13:45:03
Can we instead use fileapi::GetIsolatedFileSystemR
victorhsieh
2013/04/18 19:28:38
Done.
| |
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 PpapiRendererHostMsg_Ext_CrxFileSystem_Open, | |
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 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 ppapi::host::ReplyMessageContext reply_context = | |
74 context->MakeReplyMessageContext(); | |
75 reply_context.params.set_result(PP_OK); | |
76 host()->SendReply( | |
77 reply_context, | |
78 PpapiPluginMsg_Ext_CrxFileSystem_RendererOpenReply()); | |
79 return PP_OK_COMPLETIONPENDING; | |
80 } | |
81 | |
82 } // namespace chrome | |
OLD | NEW |