Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Side by Side Diff: ppapi/shared_impl/ppapi_permissions.cc

Issue 10984094: Hook up PpapiPermissions in more places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/shared_impl/ppapi_permissions.h" 5 #include "ppapi/shared_impl/ppapi_permissions.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace ppapi { 9 namespace ppapi {
10 10
11 PpapiPermissions::PpapiPermissions() : permissions_(0) { 11 PpapiPermissions::PpapiPermissions() : permissions_(0) {
12 } 12 }
13 13
14 PpapiPermissions::PpapiPermissions(uint32 perms) : permissions_(perms) { 14 PpapiPermissions::PpapiPermissions(uint32 perms) : permissions_(perms) {
15 } 15 }
16 16
17 PpapiPermissions::~PpapiPermissions() { 17 PpapiPermissions::~PpapiPermissions() {
18 } 18 }
19 19
20 // static 20 // static
21 PpapiPermissions PpapiPermissions::AllPermissions() { 21 PpapiPermissions PpapiPermissions::AllPermissions() {
22 return PpapiPermissions( 22 return PpapiPermissions(PERMISSION_ALL_BITS);
23 PERMISSION_DEV |
24 PERMISSION_PRIVATE |
25 PERMISSION_BYPASS_USER_GESTURE);
26 } 23 }
27 24
28 bool PpapiPermissions::HasPermission(Permission perm) const { 25 bool PpapiPermissions::HasPermission(Permission perm) const {
29 // Check that "perm" is a power of two to make sure the caller didn't set 26 // Check that "perm" is a power of two to make sure the caller didn't set
30 // more than one permission bit. We may want to change how permissions are 27 // more than one permission bit. We may want to change how permissions are
31 // represented in the future so don't want callers making assumptions about 28 // represented in the future so don't want callers making assumptions about
32 // bits. 29 // bits.
33 uint32 perm_int = static_cast<uint32>(perm); 30 uint32 perm_int = static_cast<uint32>(perm);
31 if (!perm_int)
32 return true; // You always have "no permission".
34 DCHECK((perm_int & (perm_int - 1)) == 0); 33 DCHECK((perm_int & (perm_int - 1)) == 0);
35 return !!(permissions_ & perm_int); 34 return !!(permissions_ & perm_int);
36 } 35 }
37 36
38 } // namespace ppapi 37 } // namespace ppapi
OLDNEW
« ppapi/proxy/ppb_flash_proxy.cc ('K') | « ppapi/shared_impl/ppapi_permissions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698