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

Unified Diff: extensions/common/manifest_handler.h

Issue 51433002: Enable permission warnings from ManifestHandlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code review comments. Created 7 years, 1 month 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
Index: extensions/common/manifest_handler.h
diff --git a/extensions/common/manifest_handler.h b/extensions/common/manifest_handler.h
index fd7b571e33666830d3d2bb98c6c80b7a1e7a8c50..3f67ba72d01387650983527424b70efcb31dd7ab 100644
--- a/extensions/common/manifest_handler.h
+++ b/extensions/common/manifest_handler.h
@@ -16,6 +16,8 @@
namespace extensions {
class Extension;
+class ManifestPermission;
+class ManifestPermissionSet;
// An interface for clients that recognize and parse keys in extension
// manifests.
@@ -64,6 +66,10 @@ class ManifestHandler {
// (new MyManifestHandler)->Register();
void Register();
+ virtual ManifestPermission* CreatePermission();
+ virtual ManifestPermission* CreateInitialRequiredPermission(
+ const Extension* extension);
+
// Calling FinalizeRegistration indicates that there are no more
// manifest handlers to be registered.
static void FinalizeRegistration();
@@ -79,6 +85,21 @@ class ManifestHandler {
std::string* error,
std::vector<InstallWarning>* warnings);
+ // Creates a |ManifestPermission| instance for the given manifest key |name|.
+ // The returned permission does not contain any permission data, so this
+ // method is usually used before calling |FromValue| or |Read|. Returns
+ // |NULL| if the manifest handler for the given manifest key does not support
+ // custom permissions.
+ static ManifestPermission* CreatePermission(const std::string& name);
+
+ // Adds to |permission_set| the initial set of required manifest permissions
+ // for the given |extension|. Note this should be called after all manifest
+ // data elements have been read, parsed and stored in the manifest data
+ // property of |extension|, as manifest handlers need access to their
+ // manifest data to initialize their required manifest permission.
+ static void AddExtensionRequiredPermissions(
+ const Extension* extension, ManifestPermissionSet* permission_set);
+
protected:
// A convenience method for handlers that only register for 1 key,
// so that they can define keys() { return SingleKey(kKey); }
@@ -108,6 +129,11 @@ class ManifestHandlerRegistry {
std::string* error,
std::vector<InstallWarning>* warnings);
+ ManifestPermission* CreatePermission(const std::string& name);
+
+ void AddExtensionRequiredPermissions(const Extension* extension,
+ ManifestPermissionSet* permission_set);
+
// Overrides the current global ManifestHandlerRegistry with
// |registry|, returning the current one.
static ManifestHandlerRegistry* SetForTesting(

Powered by Google App Engine
This is Rietveld 408576698