Chromium Code Reviews| 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_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/shared_memory.h" | |
| 12 #include "extensions/browser/extension_event_histogram_value.h" | 13 #include "extensions/browser/extension_event_histogram_value.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class DictionaryValue; | 16 class DictionaryValue; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 class BrowserContext; | 20 class BrowserContext; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace extensions { | 23 namespace extensions { |
| 23 | 24 |
| 24 class Extension; | 25 class Extension; |
| 25 class ExtensionPrefs; | 26 class ExtensionPrefs; |
| 26 class PermissionSet; | 27 class PermissionSet; |
| 28 class URLPatternSet; | |
| 27 | 29 |
| 28 // Updates an Extension's active and granted permissions in persistent storage | 30 // Updates an Extension's active and granted permissions in persistent storage |
| 29 // and notifies interested parties of the changes. | 31 // and notifies interested parties of the changes. |
| 30 class PermissionsUpdater { | 32 class PermissionsUpdater { |
| 31 public: | 33 public: |
| 32 enum InitFlag { | 34 enum InitFlag { |
| 33 INIT_FLAG_NONE = 0, | 35 INIT_FLAG_NONE = 0, |
| 34 INIT_FLAG_TRANSIENT = 1 << 0, | 36 INIT_FLAG_TRANSIENT = 1 << 0, |
| 35 }; | 37 }; |
| 36 | 38 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 62 void RemovePermissions(const Extension* extension, | 64 void RemovePermissions(const Extension* extension, |
| 63 const PermissionSet& permissions, | 65 const PermissionSet& permissions, |
| 64 RemoveType remove_type); | 66 RemoveType remove_type); |
| 65 | 67 |
| 66 // Removes the |permissions| from |extension| and makes no effort to determine | 68 // Removes the |permissions| from |extension| and makes no effort to determine |
| 67 // if doing so is safe in the slightlest. This method shouldn't be used, | 69 // if doing so is safe in the slightlest. This method shouldn't be used, |
| 68 // except for removing permissions totally blacklisted by management. | 70 // except for removing permissions totally blacklisted by management. |
| 69 void RemovePermissionsUnsafe(const Extension* extension, | 71 void RemovePermissionsUnsafe(const Extension* extension, |
| 70 const PermissionSet& permissions); | 72 const PermissionSet& permissions); |
| 71 | 73 |
| 74 // Sets list of hosts |extension| may not interact with (overrides default). | |
| 75 // This is the individual scope of ExtensionSettings. | |
| 76 void SetRuntimeBlockedAllowedHosts(const Extension* extension, | |
|
Devlin
2017/01/09 23:30:57
RuntimeBlockedAllowedHosts makes no sense to me :)
nrpeter
2017/01/10 17:48:05
This function updates the list of hosts to be bloc
| |
| 77 const URLPatternSet& runtime_blocked_hosts, | |
| 78 const URLPatternSet& runtime_allowed_hosts, | |
| 79 bool is_default); | |
| 80 | |
| 81 // Sets list of hosts extensions may not interact with. Extension specific | |
| 82 // exceptions to this default policy are defined with | |
| 83 // SetRuntimeBlockedAllowedHosts. This is the Deault scope "*" of | |
| 84 // ExtensionSettings. | |
| 85 void SetDefaultRuntimeBlockedAllowedHosts( | |
| 86 const URLPatternSet& default_runtime_blocked_hosts, | |
| 87 const URLPatternSet& default_runtime_allowed_hosts); | |
| 88 | |
| 72 // Returns the set of revokable permissions. | 89 // Returns the set of revokable permissions. |
| 73 std::unique_ptr<const PermissionSet> GetRevokablePermissions( | 90 std::unique_ptr<const PermissionSet> GetRevokablePermissions( |
| 74 const Extension* extension) const; | 91 const Extension* extension) const; |
| 75 | 92 |
| 76 // Adds all permissions in the |extension|'s active permissions to its | 93 // Adds all permissions in the |extension|'s active permissions to its |
| 77 // granted permission set. | 94 // granted permission set. |
| 78 void GrantActivePermissions(const Extension* extension); | 95 void GrantActivePermissions(const Extension* extension); |
| 79 | 96 |
| 80 // Initializes the |extension|'s active permission set to include only | 97 // Initializes the |extension|'s active permission set to include only |
| 81 // permissions currently requested by the extension and all the permissions | 98 // permissions currently requested by the extension and all the permissions |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 104 | 121 |
| 105 // Issues the relevant events, messages and notifications when the | 122 // Issues the relevant events, messages and notifications when the |
| 106 // |extension|'s permissions have |changed| (|changed| is the delta). | 123 // |extension|'s permissions have |changed| (|changed| is the delta). |
| 107 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, | 124 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, |
| 108 // the ExtensionMsg_UpdatePermissions IPC message, and fires the | 125 // the ExtensionMsg_UpdatePermissions IPC message, and fires the |
| 109 // onAdded/onRemoved events in the extension. | 126 // onAdded/onRemoved events in the extension. |
| 110 void NotifyPermissionsUpdated(EventType event_type, | 127 void NotifyPermissionsUpdated(EventType event_type, |
| 111 const Extension* extension, | 128 const Extension* extension, |
| 112 const PermissionSet& changed); | 129 const PermissionSet& changed); |
| 113 | 130 |
| 131 // Issues the relevant events, messages and notifications when the | |
| 132 // |extension|'s management policy have changed. | |
| 133 // Specifically, this sends the EXTENSION_POLICY_UPDATED notification, | |
| 134 // the ExtensionMsg_UpdateAllowedAndBlockedHosts IPC message. | |
| 135 void NotifyRuntimeBlockedAllowedHostsUpdated( | |
| 136 const Extension* extension, | |
| 137 const URLPatternSet& runtime_blocked_hosts, | |
| 138 const URLPatternSet& runtime_allowed_hosts, | |
| 139 bool is_default); | |
| 140 | |
| 141 // Issues the relevant events, messages and notifications when the | |
| 142 // |extension|'s management policy have changed. | |
| 143 // Specifically, this sends the EXTENSION_POLICY_UPDATED notification, | |
| 144 // the ExtensionMsg_UpdateDefaultAllowedAndBlockedHostsPolicy IPC message. | |
| 145 void NotifyDefaultRuntimeBlockedAllowedHostsUpdated( | |
| 146 const URLPatternSet& default_runtime_blocked_hosts, | |
| 147 const URLPatternSet& default_runtime_allowed_hosts); | |
| 148 | |
| 114 // The associated BrowserContext. | 149 // The associated BrowserContext. |
| 115 content::BrowserContext* browser_context_; | 150 content::BrowserContext* browser_context_; |
| 116 | 151 |
| 117 // Initialization flag that determines whether prefs is consulted about the | 152 // Initialization flag that determines whether prefs is consulted about the |
| 118 // extension. Transient extensions should not have entries in prefs. | 153 // extension. Transient extensions should not have entries in prefs. |
| 119 InitFlag init_flag_; | 154 InitFlag init_flag_; |
| 120 | 155 |
| 121 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater); | 156 DISALLOW_COPY_AND_ASSIGN(PermissionsUpdater); |
| 122 }; | 157 }; |
| 123 | 158 |
| 124 } // namespace extensions | 159 } // namespace extensions |
| 125 | 160 |
| 126 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 161 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
| OLD | NEW |