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 // CRX filesystem is a filesystem that allows an extension to read its own |
| 6 // package directory tree. See ppapi/examples/crxfs for example. |
| 7 // |
| 8 // IMPLEMENTATION |
| 9 // |
| 10 // The implementation involves both browser and renderer. In order to provide |
| 11 // readonly access to CRX filesystem (i.e. extension directory), we create an |
| 12 // "isolated filesystem" pointing to current extension directory in browser. |
| 13 // Then browser grants read permission to renderer. |
| 14 // |
| 15 // The only purpose of having a renderer host is to make it accessible by |
| 16 // FileRef, which runs in renderer at this time. |
| 17 // |
| 18 // When the plugin calls PPB_Ext_CrxFileSystem_Private_API.Open, the resource |
| 19 // class ExtCrxFileSystemPrivateResource forwards the request to the browser |
| 20 // host. Once the browser host successfully creates the underlying "isolated |
| 21 // filesystem", it replies to the resource with filesystem id and current |
| 22 // extension id, which are then sent to renderer host for FileRef to access. |
| 23 |
| 24 #ifndef PPAPI_PROXY_EXT_CRX_FILE_SYSTEM_PRIVATE_RESOURCE_H_ |
| 25 #define PPAPI_PROXY_EXT_CRX_FILE_SYSTEM_PRIVATE_RESOURCE_H_ |
| 26 |
| 27 #include <string> |
| 28 |
| 29 #include "base/memory/ref_counted.h" |
| 30 #include "ppapi/proxy/connection.h" |
| 31 #include "ppapi/proxy/plugin_resource.h" |
| 32 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 33 #include "ppapi/thunk/ppb_ext_crx_file_system_private_api.h" |
| 34 |
| 35 namespace ppapi { |
| 36 |
| 37 class TrackedCallback; |
| 38 |
| 39 namespace proxy { |
| 40 |
| 41 class ResourceMessageReplyParams; |
| 42 |
| 43 class PPAPI_PROXY_EXPORT ExtCrxFileSystemPrivateResource |
| 44 : public PluginResource, |
| 45 public thunk::PPB_Ext_CrxFileSystem_Private_API { |
| 46 public: |
| 47 ExtCrxFileSystemPrivateResource(Connection connection, PP_Instance instance); |
| 48 virtual ~ExtCrxFileSystemPrivateResource(); |
| 49 |
| 50 // Resource overrides. |
| 51 virtual thunk::PPB_Ext_CrxFileSystem_Private_API* |
| 52 AsPPB_Ext_CrxFileSystem_Private_API() OVERRIDE; |
| 53 |
| 54 // PPB_Ext_CrxFileSystem_Private_API implementation. |
| 55 virtual int32_t Open(PP_Resource* file_system_resource, |
| 56 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 57 |
| 58 private: |
| 59 void OnBrowserOpenComplete(PP_Resource* file_system_resource, |
| 60 scoped_refptr<TrackedCallback> callback, |
| 61 const ResourceMessageReplyParams& params, |
| 62 const std::string& fsid); |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(ExtCrxFileSystemPrivateResource); |
| 65 }; |
| 66 |
| 67 } // namespace proxy |
| 68 } // namespace ppapi |
| 69 |
| 70 #endif // PPAPI_PROXY_EXT_CRX_FILE_SYSTEM_PRIVATE_RESOURCE_H_ |
OLD | NEW |