1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
// Copyright 2012 The Chromium Authors
// 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 <stdint.h>
#include "ppapi/shared_impl/ppapi_shared_export.h"
namespace ppapi {
enum Permission {
// Placeholder/uninitialized permission.
PERMISSION_NONE = 0,
// Allows access to dev interfaces. These are experimental interfaces not
// tied to any particular release channel.
PERMISSION_DEV = 1 << 0,
// Allows access to Browser-internal interfaces.
PERMISSION_PRIVATE = 1 << 1,
// Allows ability to bypass user-gesture checks for showing things like
// file select dialogs.
PERMISSION_BYPASS_USER_GESTURE = 1 << 2,
// Testing-only interfaces.
PERMISSION_TESTING = 1 << 3,
// Flash-related interfaces.
PERMISSION_FLASH = 1 << 4,
// "Dev channel" interfaces. This is different than PERMISSION_DEV above;
// these interfaces may only be used on Dev or Canary channel releases of
// Chrome.
PERMISSION_DEV_CHANNEL = 1 << 5,
// PDF-related interfaces.
PERMISSION_PDF = 1 << 6,
// Socket APIs. Formerly part of public APIs.
PERMISSION_SOCKET = 1 << 7,
// NOTE: If you add stuff be sure to update PERMISSION_ALL_BITS.
// Meta permission for for initializing plugins with permissions that have
// historically been part of public APIs but are now covered by finer-grained
// permissions.
PERMISSION_DEFAULT = PERMISSION_SOCKET,
// Meta permission for initializing plugins registered on the command line
// that get all permissions.
PERMISSION_ALL_BITS = PERMISSION_DEV | PERMISSION_PRIVATE |
PERMISSION_BYPASS_USER_GESTURE | PERMISSION_TESTING |
PERMISSION_FLASH | PERMISSION_DEV_CHANNEL |
PERMISSION_PDF | PERMISSION_SOCKET,
};
class PPAPI_SHARED_EXPORT PpapiPermissions {
public:
// Initializes the permissions struct with no permissions.
PpapiPermissions();
// Initializes with the given permissions bits set.
explicit PpapiPermissions(uint32_t perms);
~PpapiPermissions();
// Returns a permissions class with all features enabled. This is for testing
// and manually registered plugins.
static PpapiPermissions AllPermissions();
// Returns the effective permissions given the "base" permissions granted
// to the given plugin and the current command line flags, which may enable
// more features.
static PpapiPermissions GetForCommandLine(uint32_t base_perms);
bool HasPermission(Permission perm) const;
// Returns the internal permission bits. Use for serialization only.
uint32_t GetBits() const { return permissions_; }
private:
uint32_t permissions_;
// Note: Copy & assign supported.
};
} // namespace ppapi
#endif // PPAPI_SHARED_IMPL_PPAPI_PERMISSIONS_H_
|