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

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

Issue 1548813002: Switch to standard integer types in ppapi/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 12 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
« no previous file with comments | « ppapi/shared_impl/ppapi_permissions.h ('k') | ppapi/shared_impl/ppb_audio_config_shared.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "build/build_config.h"
9 #include "ppapi/shared_impl/ppapi_switches.h" 10 #include "ppapi/shared_impl/ppapi_switches.h"
10 11
11 namespace ppapi { 12 namespace ppapi {
12 13
13 PpapiPermissions::PpapiPermissions() : permissions_(0) {} 14 PpapiPermissions::PpapiPermissions() : permissions_(0) {}
14 15
15 PpapiPermissions::PpapiPermissions(uint32 perms) : permissions_(perms) {} 16 PpapiPermissions::PpapiPermissions(uint32_t perms) : permissions_(perms) {}
16 17
17 PpapiPermissions::~PpapiPermissions() {} 18 PpapiPermissions::~PpapiPermissions() {}
18 19
19 // static 20 // static
20 PpapiPermissions PpapiPermissions::AllPermissions() { 21 PpapiPermissions PpapiPermissions::AllPermissions() {
21 return PpapiPermissions(PERMISSION_ALL_BITS); 22 return PpapiPermissions(PERMISSION_ALL_BITS);
22 } 23 }
23 24
24 // static 25 // static
25 PpapiPermissions PpapiPermissions::GetForCommandLine(uint32 base_perms) { 26 PpapiPermissions PpapiPermissions::GetForCommandLine(uint32_t base_perms) {
26 uint32 additional_permissions = 0; 27 uint32_t additional_permissions = 0;
27 28
28 #if !defined(OS_NACL) 29 #if !defined(OS_NACL)
29 // Testing permissions. The testing flag implies all permissions since the 30 // Testing permissions. The testing flag implies all permissions since the
30 // test plugin needs to test all interfaces. 31 // test plugin needs to test all interfaces.
31 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 32 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
32 switches::kEnablePepperTesting)) 33 switches::kEnablePepperTesting))
33 additional_permissions |= ppapi::PERMISSION_ALL_BITS; 34 additional_permissions |= ppapi::PERMISSION_ALL_BITS;
34 #endif 35 #endif
35 36
36 return PpapiPermissions(base_perms | additional_permissions); 37 return PpapiPermissions(base_perms | additional_permissions);
37 } 38 }
38 39
39 bool PpapiPermissions::HasPermission(Permission perm) const { 40 bool PpapiPermissions::HasPermission(Permission perm) const {
40 // Check that "perm" is a power of two to make sure the caller didn't set 41 // Check that "perm" is a power of two to make sure the caller didn't set
41 // more than one permission bit. We may want to change how permissions are 42 // more than one permission bit. We may want to change how permissions are
42 // represented in the future so don't want callers making assumptions about 43 // represented in the future so don't want callers making assumptions about
43 // bits. 44 // bits.
44 uint32 perm_int = static_cast<uint32>(perm); 45 uint32_t perm_int = static_cast<uint32_t>(perm);
45 if (!perm_int) 46 if (!perm_int)
46 return true; // You always have "no permission". 47 return true; // You always have "no permission".
47 DCHECK((perm_int & (perm_int - 1)) == 0); 48 DCHECK((perm_int & (perm_int - 1)) == 0);
48 return !!(permissions_ & perm_int); 49 return !!(permissions_ & perm_int);
49 } 50 }
50 51
51 } // namespace ppapi 52 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/ppapi_permissions.h ('k') | ppapi/shared_impl/ppb_audio_config_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698