summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
diff options
context:
space:
mode:
authorvictorhsieh@chromium.org <victorhsieh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 18:04:58 +0000
committervictorhsieh@chromium.org <victorhsieh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 18:04:58 +0000
commitd196ccaf213718d4b3d33f2c07021ef86ce86253 (patch)
tree7d993de1cf5675e7730e3e1038b3c560f29818e4 /ppapi/cpp
parent24e1ffbfc1e82294e909ce031e7aeaa8b8cca205 (diff)
downloadchromium_src-d196ccaf213718d4b3d33f2c07021ef86ce86253.zip
chromium_src-d196ccaf213718d4b3d33f2c07021ef86ce86253.tar.gz
chromium_src-d196ccaf213718d4b3d33f2c07021ef86ce86253.tar.bz2
CRX FileSystem Pepper private API
pp::ExtCrxFileSystemPrivate is introduced in this change to allow plugin to mount (readonly) CRX extension directory as a filesystem. Files can be access through pp::ExtCrxFileRefPrivate (which is a subclass of pp::FileRef) just like normal file, and the path would look like "/manifest.json". See ppapi/example/crxfs for example. Some keypoints in this change: * pepper resource/host architecture: - please refer to ppapi/proxy/ext_crx_file_system_private_resource.h. * webkit/fileapi related: - Changes run in browser - Isoloated filesystem is the underlying filesystem - Grant read permission to corresponding renderer of the plugin - See chrome/browser/renderer_host/pepper/pepper_ext_crx_file_system_browser_host.cc * extension related: - Changes run in browser - This is for getting extension installed directory to mount TEST=out/Debug/chrome --register-pepper-plugins="out/Debug/lib/libppapi_example_crxfs.so#PPAPI Tests##1.2.3;application/x-ppapi-example-crxfs" \ ppapi/examples/crxfs/crxfs.html BUG=223301 Review URL: https://chromiumcodereview.appspot.com/14188019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198938 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r--ppapi/cpp/file_ref.h2
-rw-r--r--ppapi/cpp/file_system.cc4
-rw-r--r--ppapi/cpp/file_system.h6
-rw-r--r--ppapi/cpp/private/ext_crx_file_system_private.cc38
-rw-r--r--ppapi/cpp/private/ext_crx_file_system_private.h31
5 files changed, 80 insertions, 1 deletions
diff --git a/ppapi/cpp/file_ref.h b/ppapi/cpp/file_ref.h
index b7e5e65..8b008ac 100644
--- a/ppapi/cpp/file_ref.h
+++ b/ppapi/cpp/file_ref.h
@@ -47,7 +47,7 @@ class FileRef : public Resource {
/// system. File paths are POSIX style.
///
/// @param[in] file_system A <code>FileSystem</code> corresponding to a file
- /// system typ.
+ /// system type.
/// @param[in] path A path to the file.
FileRef(const FileSystem& file_system, const char* path);
diff --git a/ppapi/cpp/file_system.cc b/ppapi/cpp/file_system.cc
index 022288c..de14c36 100644
--- a/ppapi/cpp/file_system.cc
+++ b/ppapi/cpp/file_system.cc
@@ -25,6 +25,10 @@ template <> const char* interface_name<PPB_FileSystem_1_0>() {
FileSystem::FileSystem() {
}
+FileSystem::FileSystem(PassRef, PP_Resource resource)
+ : Resource(PASS_REF, resource) {
+}
+
FileSystem::FileSystem(const InstanceHandle& instance,
PP_FileSystemType type) {
if (!has_interface<PPB_FileSystem_1_0>())
diff --git a/ppapi/cpp/file_system.h b/ppapi/cpp/file_system.h
index 3dc7758..6b67ca3 100644
--- a/ppapi/cpp/file_system.h
+++ b/ppapi/cpp/file_system.h
@@ -28,6 +28,12 @@ class FileSystem : public Resource {
/// use it.
FileSystem();
+ /// A constructor used when you have received a PP_Resource as a return
+ /// value that has already been reference counted.
+ ///
+ /// @param[in] resource A PP_Resource corresponding to a PPB_FileSystem.
+ FileSystem(PassRef, PP_Resource resource);
+
/// This constructor creates a file system object of the given type.
///
/// @param[in] instance The instance with which this resource will be
diff --git a/ppapi/cpp/private/ext_crx_file_system_private.cc b/ppapi/cpp/private/ext_crx_file_system_private.cc
new file mode 100644
index 0000000..87752b9
--- /dev/null
+++ b/ppapi/cpp/private/ext_crx_file_system_private.cc
@@ -0,0 +1,38 @@
+// 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 "ppapi/cpp/private/ext_crx_file_system_private.h"
+
+#include "ppapi/c/private/ppb_ext_crx_file_system_private.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Ext_CrxFileSystem_Private_0_1>() {
+ return PPB_EXT_CRXFILESYSTEM_PRIVATE_INTERFACE_0_1;
+}
+
+} // namespace
+
+ExtCrxFileSystemPrivate::ExtCrxFileSystemPrivate() {
+}
+
+ExtCrxFileSystemPrivate::ExtCrxFileSystemPrivate(
+ const InstanceHandle& instance) : instance_(instance.pp_instance()) {
+}
+
+ExtCrxFileSystemPrivate::~ExtCrxFileSystemPrivate() {
+}
+
+int32_t ExtCrxFileSystemPrivate::Open(
+ const CompletionCallbackWithOutput<pp::FileSystem>& cc) {
+ if (!has_interface<PPB_Ext_CrxFileSystem_Private_0_1>())
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
+ return get_interface<PPB_Ext_CrxFileSystem_Private_0_1>()->
+ Open(instance_, cc.output(), cc.pp_completion_callback());
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/private/ext_crx_file_system_private.h b/ppapi/cpp/private/ext_crx_file_system_private.h
new file mode 100644
index 0000000..e307f91
--- /dev/null
+++ b/ppapi/cpp/private/ext_crx_file_system_private.h
@@ -0,0 +1,31 @@
+// 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.
+
+#ifndef PPAPI_CPP_PRIVATE_EXTENSION_CRX_FILE_SYSTEM_PRIVATE_H_
+#define PPAPI_CPP_PRIVATE_EXTENSION_CRX_FILE_SYSTEM_PRIVATE_H_
+
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/file_system.h"
+#include "ppapi/cpp/instance_handle.h"
+
+namespace pp {
+
+class CompletionCallback;
+
+class ExtCrxFileSystemPrivate {
+ public:
+ ExtCrxFileSystemPrivate();
+ explicit ExtCrxFileSystemPrivate(const InstanceHandle& instance);
+ virtual ~ExtCrxFileSystemPrivate();
+
+ int32_t Open(const CompletionCallbackWithOutput<pp::FileSystem>& cc);
+
+ private:
+ PP_Instance instance_;
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_PRIVATE_EXTENSION_CRX_FILE_SYSTEM_PRIVATE_H_