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

Side by Side Diff: chrome/common/extensions/permissions/permission_set.h

Issue 10692160: Support socket endpoint permissions for AppsV2 Socket API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase and fix a unit test Created 8 years, 4 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
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 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSION_SET_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSION_SET_H_
6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSION_SET_H_ 6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSION_SET_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/permissions/api_permission.h" 18 #include "chrome/common/extensions/permissions/api_permission.h"
19 #include "chrome/common/extensions/permissions/api_permission_set.h"
19 #include "chrome/common/extensions/permissions/permission_message.h" 20 #include "chrome/common/extensions/permissions/permission_message.h"
20 #include "chrome/common/extensions/url_pattern_set.h" 21 #include "chrome/common/extensions/url_pattern_set.h"
21 22
22 namespace extensions { 23 namespace extensions {
23 24
24 // The PermissionSet is an immutable class that encapsulates an 25 // The PermissionSet is an immutable class that encapsulates an
25 // extension's permissions. The class exposes set operations for combining and 26 // extension's permissions. The class exposes set operations for combining and
26 // manipulating the permissions. 27 // manipulating the permissions.
27 class PermissionSet 28 class PermissionSet
28 : public base::RefCountedThreadSafe<PermissionSet> { 29 : public base::RefCountedThreadSafe<PermissionSet> {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // as strings). The set of permission messages shown varies by extension type. 87 // as strings). The set of permission messages shown varies by extension type.
87 std::vector<string16> GetWarningMessages(Extension::Type extension_type) 88 std::vector<string16> GetWarningMessages(Extension::Type extension_type)
88 const; 89 const;
89 90
90 // Returns true if this is an empty set (e.g., the default permission set). 91 // Returns true if this is an empty set (e.g., the default permission set).
91 bool IsEmpty() const; 92 bool IsEmpty() const;
92 93
93 // Returns true if the set has the specified API permission. 94 // Returns true if the set has the specified API permission.
94 bool HasAPIPermission(APIPermission::ID permission) const; 95 bool HasAPIPermission(APIPermission::ID permission) const;
95 96
97 // Returns true if the set allows the given permission with the default
98 // permission detal.
99 bool CheckAPIPermission(APIPermission::ID permission) const;
100
101 // Returns true if the set allows the given permission and permission detail.
102 bool CheckAPIPermissionWithDetail(APIPermission::ID permission,
103 const APIPermissionDetail::CheckParam* detail) const;
104
96 // Returns true if the permissions in this set grant access to the specified 105 // Returns true if the permissions in this set grant access to the specified
97 // |function_name|. 106 // |function_name|.
98 bool HasAccessToFunction(const std::string& function_name) const; 107 bool HasAccessToFunction(const std::string& function_name) const;
99 108
100 // Returns true if this includes permission to access |origin|. 109 // Returns true if this includes permission to access |origin|.
101 bool HasExplicitAccessToOrigin(const GURL& origin) const; 110 bool HasExplicitAccessToOrigin(const GURL& origin) const;
102 111
103 // Returns true if this permission set includes access to script |url|. 112 // Returns true if this permission set includes access to script |url|.
104 bool HasScriptableAccessToURL(const GURL& url) const; 113 bool HasScriptableAccessToURL(const GURL& url) const;
105 114
(...skipping 29 matching lines...) Expand all
135 FRIEND_TEST_ALL_PREFIXES(PermissionsTest, 144 FRIEND_TEST_ALL_PREFIXES(PermissionsTest,
136 GetDistinctHostsForDisplay_NetIs2ndBestRcd); 145 GetDistinctHostsForDisplay_NetIs2ndBestRcd);
137 FRIEND_TEST_ALL_PREFIXES(PermissionsTest, 146 FRIEND_TEST_ALL_PREFIXES(PermissionsTest,
138 GetDistinctHostsForDisplay_OrgIs3rdBestRcd); 147 GetDistinctHostsForDisplay_OrgIs3rdBestRcd);
139 FRIEND_TEST_ALL_PREFIXES(PermissionsTest, 148 FRIEND_TEST_ALL_PREFIXES(PermissionsTest,
140 GetDistinctHostsForDisplay_FirstInListIs4thBestRcd); 149 GetDistinctHostsForDisplay_FirstInListIs4thBestRcd);
141 friend class base::RefCountedThreadSafe<PermissionSet>; 150 friend class base::RefCountedThreadSafe<PermissionSet>;
142 151
143 ~PermissionSet(); 152 ~PermissionSet();
144 153
154 void AddAPIPermission(APIPermission::ID id);
155
145 static std::set<std::string> GetDistinctHosts( 156 static std::set<std::string> GetDistinctHosts(
146 const URLPatternSet& host_patterns, 157 const URLPatternSet& host_patterns,
147 bool include_rcd, 158 bool include_rcd,
148 bool exclude_file_scheme); 159 bool exclude_file_scheme);
149 160
150 // Initializes the set based on |extension|'s manifest data. 161 // Initializes the set based on |extension|'s manifest data.
151 void InitImplicitExtensionPermissions(const extensions::Extension* extension); 162 void InitImplicitExtensionPermissions(const extensions::Extension* extension);
152 163
153 // Adds permissions implied independently of other context. 164 // Adds permissions implied independently of other context.
154 void InitImplicitPermissions(); 165 void InitImplicitPermissions();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // TODO(jstritar): Rename to "user_script_hosts_"? 197 // TODO(jstritar): Rename to "user_script_hosts_"?
187 URLPatternSet scriptable_hosts_; 198 URLPatternSet scriptable_hosts_;
188 199
189 // The list of hosts this effectively grants access to. 200 // The list of hosts this effectively grants access to.
190 URLPatternSet effective_hosts_; 201 URLPatternSet effective_hosts_;
191 }; 202 };
192 203
193 } // namespace extensions 204 } // namespace extensions
194 205
195 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSION_SET_H_ 206 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_PERMISSION_SET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698