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

Side by Side Diff: chrome/common/extensions/permissions/permissions_info.cc

Issue 10649003: Move each permission classes to its own files in extensions/permissions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase on HEAD Created 8 years, 6 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
OLDNEW
(Empty)
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 #include "chrome/common/extensions/permissions/permissions_info.h"
6
7 namespace extensions {
8
9 //
10 // PermissionsInfo
11 //
12
13 // static
14 PermissionsInfo* PermissionsInfo::GetInstance() {
15 return Singleton<PermissionsInfo>::get();
16 }
17
18 APIPermission* PermissionsInfo::GetByID(
19 APIPermission::ID id) {
20 IDMap::iterator i = id_map_.find(id);
21 return (i == id_map_.end()) ? NULL : i->second;
22 }
23
24 APIPermission* PermissionsInfo::GetByName(
25 const std::string& name) {
26 NameMap::iterator i = name_map_.find(name);
27 return (i == name_map_.end()) ? NULL : i->second;
28 }
29
30 APIPermissionSet PermissionsInfo::GetAll() {
31 APIPermissionSet permissions;
32 for (IDMap::const_iterator i = id_map_.begin(); i != id_map_.end(); ++i)
33 permissions.insert(i->second->id());
34 return permissions;
35 }
36
37 APIPermissionSet PermissionsInfo::GetAllByName(
38 const std::set<std::string>& permission_names) {
39 APIPermissionSet permissions;
40 for (std::set<std::string>::const_iterator i = permission_names.begin();
41 i != permission_names.end(); ++i) {
42 APIPermission* permission = GetByName(*i);
43 if (permission)
44 permissions.insert(permission->id());
45 }
46 return permissions;
47 }
48
49 PermissionsInfo::~PermissionsInfo() {
50 for (IDMap::iterator i = id_map_.begin(); i != id_map_.end(); ++i)
51 delete i->second;
52 }
53
54 PermissionsInfo::PermissionsInfo()
55 : hosted_app_permission_count_(0),
56 permission_count_(0) {
57 APIPermission::RegisterAllPermissions(this);
58 }
59
60 void PermissionsInfo::RegisterAlias(
61 const char* name,
62 const char* alias) {
63 DCHECK(name_map_.find(name) != name_map_.end());
64 DCHECK(name_map_.find(alias) == name_map_.end());
65 name_map_[alias] = name_map_[name];
66 }
67
68 APIPermission* PermissionsInfo::RegisterPermission(
69 APIPermission::ID id,
70 const char* name,
71 int l10n_message_id,
72 PermissionMessage::ID message_id,
73 int flags) {
74 DCHECK(id_map_.find(id) == id_map_.end());
75 DCHECK(name_map_.find(name) == name_map_.end());
76
77 APIPermission* permission = new APIPermission(
78 id, name, l10n_message_id, message_id, flags);
79
80 id_map_[id] = permission;
81 name_map_[name] = permission;
82
83 permission_count_++;
84
85 return permission;
86 }
87
88 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/permissions_info.h ('k') | chrome/renderer/chrome_render_view_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698