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

Unified Diff: chrome/browser/extensions/permissions_updater.h

Issue 8493017: Cleanup extension permissions module. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/permissions_apitest.cc ('k') | chrome/browser/extensions/permissions_updater.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/permissions_updater.h
diff --git a/chrome/browser/extensions/permissions_updater.h b/chrome/browser/extensions/permissions_updater.h
new file mode 100644
index 0000000000000000000000000000000000000000..0640f2d80a87df3f7199bc737baf1851d0330adb
--- /dev/null
+++ b/chrome/browser/extensions/permissions_updater.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
+#define CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
+#pragma once
+
+#include <string>
+
+#include "base/memory/ref_counted.h"
+
+namespace base {
+class DictionaryValue;
+}
+class Extension;
+class ExtensionPermissionSet;
+class ExtensionPrefs;
+class Profile;
+
+namespace extensions {
+
+// Updates an Extension's active and granted permissions in persistent storage
+// and notifies interested parties of the changes.
+class PermissionsUpdater {
+ public:
+ explicit PermissionsUpdater(Profile* profile);
+ ~PermissionsUpdater();
+
+ // Adds the set of |permissions| to the |extension|'s active permission set
+ // and sends the relevant messages and notifications. This method assumes the
+ // user has already been prompted, if necessary, for the extra permissions.
+ void AddPermissions(const Extension* extension,
+ const ExtensionPermissionSet* permissions);
+
+ // Removes the set of |permissions| from the |extension|'s active permission
+ // set and sends the relevant messages and notifications.
+ void RemovePermissions(const Extension* extension,
+ const ExtensionPermissionSet* permissions);
+
+ // Adds all permissions in the |extension|'s active permissions to its
+ // granted permission set.
+ void GrantActivePermissions(const Extension* extension);
+
+ // Sets the |extension|'s active permissions to |permissions|.
+ void UpdateActivePermissions(const Extension* extension,
+ const ExtensionPermissionSet* permissions);
+
+ private:
+ enum EventType {
+ ADDED,
+ REMOVED,
+ };
+
+ // Dispatches specified event to the extension.
+ void DispatchEvent(const std::string& extension_id,
+ const char* event_name,
+ const ExtensionPermissionSet* changed_permissions);
+
+ // Issues the relevant events, messages and notifications when the
+ // |extension|'s permissions have |changed| (|changed| is the delta).
+ // Specifically, this sends the EXTENSION_PERMISSIONS_UPDATED notification,
+ // the ExtensionMsg_UpdatePermissions IPC message, and fires the
+ // onAdded/onRemoved events in the extension.
+ void NotifyPermissionsUpdated(EventType event_type,
+ const Extension* extension,
+ const ExtensionPermissionSet* changed);
+
+ // Gets the ExtensionPrefs for the associated profile.
+ ExtensionPrefs* GetExtensionPrefs();
+
+ Profile* profile_;
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_PERMISSIONS_UPDATER_H__
« no previous file with comments | « chrome/browser/extensions/permissions_apitest.cc ('k') | chrome/browser/extensions/permissions_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698