| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 void RemovePermissions(const Extension* extension, | 41 void RemovePermissions(const Extension* extension, |
| 42 const PermissionSet* permissions); | 42 const PermissionSet* permissions); |
| 43 | 43 |
| 44 // Adds all permissions in the |extension|'s active permissions to its | 44 // Adds all permissions in the |extension|'s active permissions to its |
| 45 // granted permission set. | 45 // granted permission set. |
| 46 void GrantActivePermissions(const Extension* extension); | 46 void GrantActivePermissions(const Extension* extension); |
| 47 | 47 |
| 48 // Initializes the |extension|'s active permission set to include only | 48 // Initializes the |extension|'s active permission set to include only |
| 49 // permissions currently requested by the extension and all the permissions | 49 // permissions currently requested by the extension and all the permissions |
| 50 // required by the extension. | 50 // required by the extension. |
| 51 void InitializeActivePermissions(const Extension* extension); | 51 void InitializePermissions(const Extension* extension); |
| 52 |
| 53 // Grants any withheld all-hosts (or all-hosts-like) permissions. |
| 54 void GrantWithheldImpliedAllHosts(const Extension* extension); |
| 55 |
| 56 // Revokes any requests all-hosts (or all-hosts-like) permissions. |
| 57 void WithholdImpliedAllHosts(const Extension* extension); |
| 52 | 58 |
| 53 private: | 59 private: |
| 54 enum EventType { | 60 enum EventType { |
| 55 ADDED, | 61 ADDED, |
| 56 REMOVED, | 62 REMOVED, |
| 57 }; | 63 }; |
| 58 | 64 |
| 59 // Sets the |extension|'s active permissions to |permissions| and records the | 65 // Sets the |extension|'s active permissions to |active| and records the |
| 60 // change in the prefs. | 66 // change in the prefs. If |withheld| is non-null, also sets the extension's |
| 61 void SetActivePermissions(const Extension* extension, | 67 // withheld permissions to |withheld|. Otherwise, |withheld| permissions are |
| 62 const PermissionSet* permisssions); | 68 // not changed. |
| 69 void SetPermissions(const Extension* extension, |
| 70 const scoped_refptr<const PermissionSet>& active, |
| 71 scoped_refptr<const PermissionSet> withheld); |
| 63 | 72 |
| 64 // Dispatches specified event to the extension. | 73 // Dispatches specified event to the extension. |
| 65 void DispatchEvent(const std::string& extension_id, | 74 void DispatchEvent(const std::string& extension_id, |
| 66 const char* event_name, | 75 const char* event_name, |
| 67 const PermissionSet* changed_permissions); | 76 const PermissionSet* changed_permissions); |
| 68 | 77 |
| 69 // Issues the relevant events, messages and notifications when the | 78 // Issues the relevant events, messages and notifications when the |
| 70 // |extension|'s permissions have |changed| (|changed| is the delta). | 79 // |extension|'s permissions have |changed| (|changed| is the delta). |
| 71 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, | 80 // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification, |
| 72 // the ExtensionMsg_UpdatePermissions IPC message, and fires the | 81 // the ExtensionMsg_UpdatePermissions IPC message, and fires the |
| 73 // onAdded/onRemoved events in the extension. | 82 // onAdded/onRemoved events in the extension. |
| 74 void NotifyPermissionsUpdated(EventType event_type, | 83 void NotifyPermissionsUpdated(EventType event_type, |
| 75 const Extension* extension, | 84 const Extension* extension, |
| 76 const PermissionSet* changed); | 85 const PermissionSet* changed); |
| 77 | 86 |
| 78 // The associated BrowserContext. | 87 // The associated BrowserContext. |
| 79 content::BrowserContext* browser_context_; | 88 content::BrowserContext* browser_context_; |
| 80 }; | 89 }; |
| 81 | 90 |
| 82 } // namespace extensions | 91 } // namespace extensions |
| 83 | 92 |
| 84 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ | 93 #endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__ |
| OLD | NEW |