diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-13 04:28:40 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-13 04:28:40 +0000 |
commit | 24cddd42154b07c6559846b2159a88a3feabb5d5 (patch) | |
tree | 96b150cab1ff6de13845f0e36c51735fed34be9e /ppapi | |
parent | 56a4bf839077e7dfd8cb178b8d8ad09f5215dead (diff) | |
download | chromium_src-24cddd42154b07c6559846b2159a88a3feabb5d5.zip chromium_src-24cddd42154b07c6559846b2159a88a3feabb5d5.tar.gz chromium_src-24cddd42154b07c6559846b2159a88a3feabb5d5.tar.bz2 |
Add permissions buts for Pepper plugins.
This patch doesn't actually hook anything up, but it plumbs them in for the laces we'll need it.
Review URL: https://chromiumcodereview.appspot.com/10735011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/host/ppapi_host.cc | 7 | ||||
-rw-r--r-- | ppapi/host/ppapi_host.h | 9 | ||||
-rw-r--r-- | ppapi/ppapi_shared.gypi | 2 | ||||
-rw-r--r-- | ppapi/shared_impl/ppapi_permissions.cc | 30 | ||||
-rw-r--r-- | ppapi/shared_impl/ppapi_permissions.h | 45 |
5 files changed, 90 insertions, 3 deletions
diff --git a/ppapi/host/ppapi_host.cc b/ppapi/host/ppapi_host.cc index 038f4e7..8754501 100644 --- a/ppapi/host/ppapi_host.cc +++ b/ppapi/host/ppapi_host.cc @@ -24,9 +24,12 @@ const size_t kMaxResourcesPerPlugin = 1 << 14; } // namespace -PpapiHost::PpapiHost(IPC::Sender* sender, HostFactory* host_factory) +PpapiHost::PpapiHost(IPC::Sender* sender, + HostFactory* host_factory, + const PpapiPermissions& perms) : sender_(sender), - host_factory_(host_factory) { + host_factory_(host_factory), + permissions_(perms) { } PpapiHost::~PpapiHost() { diff --git a/ppapi/host/ppapi_host.h b/ppapi/host/ppapi_host.h index eb195b8..7a20c1f 100644 --- a/ppapi/host/ppapi_host.h +++ b/ppapi/host/ppapi_host.h @@ -14,6 +14,7 @@ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/host/ppapi_host_export.h" +#include "ppapi/shared_impl/ppapi_permissions.h" namespace ppapi { @@ -35,9 +36,13 @@ class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener { // The sender is the channel to the plugin for outgoing messages. The factory // will be used to receive resource creation messages from the plugin. Both // pointers are owned by the caller and must outlive this class. - PpapiHost(IPC::Sender* sender, HostFactory* host_factory); + PpapiHost(IPC::Sender* sender, + HostFactory* host_factory, + const PpapiPermissions& perms); virtual ~PpapiHost(); + const PpapiPermissions& permissions() const { return permissions_; } + // Sender implementation. Forwards to the sender_. virtual bool Send(IPC::Message* msg) OVERRIDE; @@ -66,6 +71,8 @@ class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener { // Non-owning pointer. HostFactory* host_factory_; + PpapiPermissions permissions_; + typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; ResourceMap resources_; diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 6a360ca..27dbd09 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -35,6 +35,8 @@ 'shared_impl/platform_file.h', 'shared_impl/ppapi_globals.cc', 'shared_impl/ppapi_globals.h', + 'shared_impl/ppapi_permissions.cc', + 'shared_impl/ppapi_permissions.h', 'shared_impl/ppapi_preferences.cc', 'shared_impl/ppapi_preferences.h', 'shared_impl/ppb_audio_config_shared.cc', diff --git a/ppapi/shared_impl/ppapi_permissions.cc b/ppapi/shared_impl/ppapi_permissions.cc new file mode 100644 index 0000000..bcfdd96 --- /dev/null +++ b/ppapi/shared_impl/ppapi_permissions.cc @@ -0,0 +1,30 @@ +// Copyright (c) 2012 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/shared_impl/ppapi_permissions.h"
+
+#include "base/logging.h"
+
+namespace ppapi {
+
+PpapiPermissions::PpapiPermissions() : permissions_(0) {
+}
+
+PpapiPermissions::PpapiPermissions(uint32 perms) : permissions_(perms) {
+}
+
+PpapiPermissions::~PpapiPermissions() {
+}
+
+bool PpapiPermissions::HasPermission(Permission perm) const {
+ // Check that "perm" is a power of two to make sure the caller didn't set
+ // more than one permission bit. We may want to change how permissions are
+ // represented in the future so don't want callers making assumptions about
+ // bits.
+ uint32 perm_int = static_cast<uint32>(perm);
+ DCHECK((perm_int & (perm_int - 1)) == 0);
+ return !!(permissions_ & perm_int);
+}
+
+} // namespace ppapi
diff --git a/ppapi/shared_impl/ppapi_permissions.h b/ppapi/shared_impl/ppapi_permissions.h new file mode 100644 index 0000000..3caa65d --- /dev/null +++ b/ppapi/shared_impl/ppapi_permissions.h @@ -0,0 +1,45 @@ +// Copyright (c) 2012 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_SHARED_IMPL_PPAPI_PERMISSIONS_H_
+#define PPAPI_SHARED_IMPL_PPAPI_PERMISSIONS_H_
+
+#include "base/basictypes.h"
+#include "ppapi/shared_impl/ppapi_shared_export.h"
+
+namespace ppapi {
+
+enum Permission {
+ // Allows access to dev interfaces.
+ PERMISSION_DEV = 1 << 0,
+
+ // Allows access to Browser-internal interfaces.
+ PERMISSION_PRIVATE = 1 << 2,
+
+ // Allows ability to bypass user-gesture checks for showing things like
+ // file select dialogs.
+ PERMISSION_BYPASS_USER_GESTURE = 1 << 3
+};
+
+class PPAPI_SHARED_EXPORT PpapiPermissions {
+ public:
+ // Initializes the permissions struct with no permissions.
+ PpapiPermissions();
+
+ // Initializes with the given permissions bits set.
+ explicit PpapiPermissions(uint32 perms);
+
+ ~PpapiPermissions();
+
+ bool HasPermission(Permission perm) const;
+
+ private:
+ uint32 permissions_;
+
+ // Note: Copy & assign supported.
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_PPAPI_PERMISSIONS_H_
|