| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ | 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ |
| 6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ | 6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "extensions/common/manifest.h" | 15 #include "extensions/common/manifest.h" |
| 16 #include "extensions/common/permissions/api_permission.h" | 16 #include "extensions/common/permissions/api_permission.h" |
| 17 #include "extensions/common/permissions/coalesced_permission_message.h" | 17 #include "extensions/common/permissions/coalesced_permission_message.h" |
| 18 #include "extensions/common/permissions/permission_message.h" | 18 #include "extensions/common/permissions/permission_message.h" |
| 19 #include "extensions/common/permissions/permission_message_provider.h" |
| 19 #include "extensions/common/permissions/permission_set.h" | 20 #include "extensions/common/permissions/permission_set.h" |
| 20 | 21 |
| 21 class GURL; | 22 class GURL; |
| 22 | 23 |
| 23 namespace extensions { | 24 namespace extensions { |
| 24 class Extension; | 25 class Extension; |
| 25 class URLPatternSet; | 26 class URLPatternSet; |
| 26 | 27 |
| 27 // A container for the permissions state of an extension, including active, | 28 // A container for the permissions state of an extension, including active, |
| 28 // withheld, and tab-specific permissions. | 29 // withheld, and tab-specific permissions. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 static bool CanExecuteScriptEverywhere(const Extension* extension); | 65 static bool CanExecuteScriptEverywhere(const Extension* extension); |
| 65 | 66 |
| 66 // Returns true if the --scripts-require-action flag would possibly affect | 67 // Returns true if the --scripts-require-action flag would possibly affect |
| 67 // the given |extension| and |permissions|. We pass in the |permissions| | 68 // the given |extension| and |permissions|. We pass in the |permissions| |
| 68 // explicitly, as we may need to check with permissions other than the ones | 69 // explicitly, as we may need to check with permissions other than the ones |
| 69 // that are currently on the extension's PermissionsData. | 70 // that are currently on the extension's PermissionsData. |
| 70 static bool ScriptsMayRequireActionForExtension( | 71 static bool ScriptsMayRequireActionForExtension( |
| 71 const Extension* extension, | 72 const Extension* extension, |
| 72 const PermissionSet* permissions); | 73 const PermissionSet* permissions); |
| 73 | 74 |
| 74 // Returns true if we should skip the permisisons warning for the extension | 75 // Returns true if we should skip the permissions warning for the extension |
| 75 // with the given |extension_id|. | 76 // with the given |extension_id|. |
| 76 static bool ShouldSkipPermissionWarnings(const std::string& extension_id); | 77 static bool ShouldSkipPermissionWarnings(const std::string& extension_id); |
| 77 | 78 |
| 78 // Returns true if the given |url| is restricted for the given |extension|, | 79 // Returns true if the given |url| is restricted for the given |extension|, |
| 79 // as is commonly the case for chrome:// urls. | 80 // as is commonly the case for chrome:// urls. |
| 80 // NOTE: You probably want to use CanAccessPage(). | 81 // NOTE: You probably want to use CanAccessPage(). |
| 81 static bool IsRestrictedUrl(const GURL& document_url, | 82 static bool IsRestrictedUrl(const GURL& document_url, |
| 82 const GURL& top_frame_url, | 83 const GURL& top_frame_url, |
| 83 const Extension* extension, | 84 const Extension* extension, |
| 84 std::string* error); | 85 std::string* error); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // network, etc.) | 132 // network, etc.) |
| 132 bool HasEffectiveAccessToAllHosts() const; | 133 bool HasEffectiveAccessToAllHosts() const; |
| 133 | 134 |
| 134 // Returns the full list of legacy permission message IDs. | 135 // Returns the full list of legacy permission message IDs. |
| 135 // Deprecated. You DO NOT want to call this! | 136 // Deprecated. You DO NOT want to call this! |
| 136 // TODO(treib): Remove once we've switched to the new system. | 137 // TODO(treib): Remove once we've switched to the new system. |
| 137 PermissionMessageIDs GetLegacyPermissionMessageIDs() const; | 138 PermissionMessageIDs GetLegacyPermissionMessageIDs() const; |
| 138 | 139 |
| 139 // Returns the full list of permission messages that should display at install | 140 // Returns the full list of permission messages that should display at install |
| 140 // time as strings. | 141 // time as strings. |
| 141 // TODO(sashab): Deprecate this in favor of GetCoalescedPermissionMessages(). | 142 PermissionMessageStrings GetPermissionMessageStrings() const; |
| 142 std::vector<base::string16> GetPermissionMessageStrings() const; | 143 |
| 144 // Returns the full list of permission messages that should display at install |
| 145 // time as strings. |
| 146 // TODO(sashab): Deprecate this in favor of GetCoalescedPermissionMessages. |
| 147 std::vector<base::string16> GetLegacyPermissionMessageStrings() const; |
| 143 | 148 |
| 144 // Returns the full list of permission details for messages that should | 149 // Returns the full list of permission details for messages that should |
| 145 // display at install time as strings. | 150 // display at install time as strings. |
| 146 // TODO(sashab): Deprecate this in favor of GetCoalescedPermissionMessages(). | 151 // TODO(sashab): Deprecate this in favor of GetCoalescedPermissionMessages. |
| 147 std::vector<base::string16> GetPermissionMessageDetailsStrings() const; | 152 std::vector<base::string16> GetLegacyPermissionMessageDetailsStrings() const; |
| 148 | 153 |
| 149 // Returns the full list of permission details for messages that should | 154 // Returns the full list of permission details for messages that should |
| 150 // display at install time, in a nested format ready for display. | 155 // display at install time, in a nested format ready for display. |
| 151 CoalescedPermissionMessages GetCoalescedPermissionMessages() const; | 156 CoalescedPermissionMessages GetCoalescedPermissionMessages() const; |
| 152 | 157 |
| 153 // Returns true if the extension has requested all-hosts permissions (or | 158 // Returns true if the extension has requested all-hosts permissions (or |
| 154 // something close to it), but has had it withheld. | 159 // something close to it), but has had it withheld. |
| 155 bool HasWithheldImpliedAllHosts() const; | 160 bool HasWithheldImpliedAllHosts() const; |
| 156 | 161 |
| 157 // Returns true if the |extension| has permission to access and interact with | 162 // Returns true if the |extension| has permission to access and interact with |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 mutable scoped_refptr<const PermissionSet> withheld_permissions_unsafe_; | 282 mutable scoped_refptr<const PermissionSet> withheld_permissions_unsafe_; |
| 278 | 283 |
| 279 mutable TabPermissionsMap tab_specific_permissions_; | 284 mutable TabPermissionsMap tab_specific_permissions_; |
| 280 | 285 |
| 281 DISALLOW_COPY_AND_ASSIGN(PermissionsData); | 286 DISALLOW_COPY_AND_ASSIGN(PermissionsData); |
| 282 }; | 287 }; |
| 283 | 288 |
| 284 } // namespace extensions | 289 } // namespace extensions |
| 285 | 290 |
| 286 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ | 291 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_ |
| OLD | NEW |