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