| OLD | NEW |
| 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_EXTENSION_PERMISSION_SET_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // Extension::TYPE_PLATFORM_APP | 176 // Extension::TYPE_PLATFORM_APP |
| 177 kTypePlatformApp = 1 << 3, | 177 kTypePlatformApp = 1 << 3, |
| 178 | 178 |
| 179 // Supports all types. | 179 // Supports all types. |
| 180 kTypeAll = (1 << 4) - 1, | 180 kTypeAll = (1 << 4) - 1, |
| 181 | 181 |
| 182 // Convenience flag for all types except hosted apps. | 182 // Convenience flag for all types except hosted apps. |
| 183 kTypeDefault = kTypeAll - kTypeHostedApp, | 183 kTypeDefault = kTypeAll - kTypeHostedApp, |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 typedef std::set<ID> IDSet; |
| 187 |
| 186 ~ExtensionAPIPermission(); | 188 ~ExtensionAPIPermission(); |
| 187 | 189 |
| 188 // Returns the localized permission message associated with this api. | 190 // Returns the localized permission message associated with this api. |
| 189 ExtensionPermissionMessage GetMessage() const; | 191 ExtensionPermissionMessage GetMessage() const; |
| 190 | 192 |
| 191 int flags() const { return flags_; } | 193 int flags() const { return flags_; } |
| 192 | 194 |
| 193 int type_restrictions() const { return type_restrictions_; } | 195 int type_restrictions() const { return type_restrictions_; } |
| 194 | 196 |
| 195 ID id() const { return id_; } | 197 ID id() const { return id_; } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 const ExtensionPermissionSet* set1, const ExtensionPermissionSet* set2); | 387 const ExtensionPermissionSet* set1, const ExtensionPermissionSet* set2); |
| 386 | 388 |
| 387 bool operator==(const ExtensionPermissionSet& rhs) const; | 389 bool operator==(const ExtensionPermissionSet& rhs) const; |
| 388 | 390 |
| 389 // Returns true if |set| is a subset of this. | 391 // Returns true if |set| is a subset of this. |
| 390 bool Contains(const ExtensionPermissionSet& set) const; | 392 bool Contains(const ExtensionPermissionSet& set) const; |
| 391 | 393 |
| 392 // Gets the API permissions in this set as a set of strings. | 394 // Gets the API permissions in this set as a set of strings. |
| 393 std::set<std::string> GetAPIsAsStrings() const; | 395 std::set<std::string> GetAPIsAsStrings() const; |
| 394 | 396 |
| 395 // Gets the API permissions in this set, plus any that have implicit access | |
| 396 // (such as APIs that require no permissions, or APIs with functions that | |
| 397 // require no permissions). | |
| 398 // TODO(kalman): return scoped_ptr to avoid copying. | |
| 399 std::set<std::string> GetAPIsWithAnyAccessAsStrings() const; | |
| 400 | |
| 401 // Returns whether this namespace has any functions which the extension has | 397 // Returns whether this namespace has any functions which the extension has |
| 402 // permission to use. For example, even though the extension may not have | 398 // permission to use. For example, even though the extension may not have |
| 403 // the "tabs" permission, "tabs.create" requires no permissions so | 399 // the "tabs" permission, "tabs.create" requires no permissions so |
| 404 // HasAnyAPIPermission("tabs") will return true. | 400 // HasAnyAPIPermission("tabs") will return true. |
| 405 bool HasAnyAccessToAPI(const std::string& api_name) const; | 401 bool HasAnyAccessToAPI(const std::string& api_name) const; |
| 406 | 402 |
| 407 // Gets a list of the distinct hosts for displaying to the user. | 403 // Gets a list of the distinct hosts for displaying to the user. |
| 408 // NOTE: do not use this for comparing permissions, since this disgards some | 404 // NOTE: do not use this for comparing permissions, since this disgards some |
| 409 // information. | 405 // information. |
| 410 std::set<std::string> GetDistinctHostsForDisplay() const; | 406 std::set<std::string> GetDistinctHostsForDisplay() const; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 | 495 |
| 500 // The list of hosts that can be scripted by content scripts. | 496 // The list of hosts that can be scripted by content scripts. |
| 501 // TODO(jstritar): Rename to "user_script_hosts_"? | 497 // TODO(jstritar): Rename to "user_script_hosts_"? |
| 502 URLPatternSet scriptable_hosts_; | 498 URLPatternSet scriptable_hosts_; |
| 503 | 499 |
| 504 // The list of hosts this effectively grants access to. | 500 // The list of hosts this effectively grants access to. |
| 505 URLPatternSet effective_hosts_; | 501 URLPatternSet effective_hosts_; |
| 506 }; | 502 }; |
| 507 | 503 |
| 508 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ | 504 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_PERMISSION_SET_H_ |
| OLD | NEW |