Index: chrome/common/extensions/permissions/api_permission.h |
diff --git a/chrome/common/extensions/permissions/api_permission.h b/chrome/common/extensions/permissions/api_permission.h |
index 02f5119e64c79857d33db036cdc78446bbf35505..70f5da633bd00a0b243eab025d35206bee3dc9e3 100644 |
--- a/chrome/common/extensions/permissions/api_permission.h |
+++ b/chrome/common/extensions/permissions/api_permission.h |
@@ -5,12 +5,30 @@ |
#ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_H_ |
#define CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_H_ |
+#include <map> |
#include <set> |
+#include <string> |
+#include "base/callback.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/pickle.h" |
#include "chrome/common/extensions/permissions/permission_message.h" |
+namespace base { |
+ |
+class Value; |
+ |
miket_OOO
2012/07/31 18:18:37
Vertical whitespace inside forward-declaration nam
Peng
2012/07/31 19:32:28
Done.
|
+} |
+ |
+namespace IPC { |
+ |
+class Message; |
+ |
+} |
+ |
namespace extensions { |
+class APIPermissionDetail; |
class PermissionsInfo; |
// The APIPermission is an immutable class that describes a single |
@@ -104,10 +122,15 @@ class APIPermission { |
kFlagCannotBeOptional = 1 << 3 |
}; |
+ typedef base::Callback<APIPermissionDetail *(void)> DetailConstructor; |
+ |
typedef std::set<ID> IDSet; |
~APIPermission(); |
+ // Creates a permission detail instance. |
+ scoped_refptr<APIPermissionDetail> CreateDetail() const; |
+ |
// Returns the localized permission message associated with this api. |
// Use GetMessage_ to avoid name conflict with macro GetMessage on Windows. |
PermissionMessage GetMessage_() const; |
@@ -149,7 +172,8 @@ class APIPermission { |
const char* name, |
int l10n_message_id, |
PermissionMessage::ID message_id, |
- int flags); |
+ int flags, |
+ const DetailConstructor& detail_constructor); |
// Register ALL the permissions! |
static void RegisterAllPermissions(PermissionsInfo* info); |
@@ -159,9 +183,80 @@ class APIPermission { |
int flags_; |
int l10n_message_id_; |
PermissionMessage::ID message_id_; |
+ DetailConstructor detail_constructor_; |
}; |
-typedef std::set<APIPermission::ID> APIPermissionSet; |
+class APIPermissionDetail : public base::RefCounted<APIPermissionDetail> { |
+ public: |
+ struct DetailParam { |
+ }; |
+ |
+ APIPermissionDetail(const APIPermission* permission) |
+ : permission_(permission) { } |
miket_OOO
2012/07/31 18:18:37
As long as you have a constructor body, might as w
Peng
2012/07/31 19:32:28
Done.
|
+ |
+ // Returns the id of this permission. |
+ APIPermission::ID id() const { |
+ return permission()->id(); |
+ } |
+ |
+ // Returns the name of this permission. |
+ const char* name() const { |
+ return permission()->name(); |
+ } |
+ |
+ // Returns the APIPermission of this permission. |
+ const APIPermission* permission() const { |
+ return permission_; |
+ } |
+ |
+ // Returns true if the given permission detail is allowed. |
+ virtual bool Check(const DetailParam* detail) const = 0; |
+ |
+ // Returns true if |detail| is a subset of this. |
+ virtual bool Contains(const APIPermissionDetail*detail) const = 0; |
miket_OOO
2012/07/31 18:18:37
space after *
Peng
2012/07/31 19:32:28
Done.
|
+ |
+ // Returns true if |detail| is equal to this. |
+ virtual bool Equal(const APIPermissionDetail* detail) const = 0; |
+ |
+ // Parses the detail from |value|. Returns false if error happens. |
+ virtual bool FromValue(const base::Value* value) = 0; |
+ |
+ // Stores this into a new created |value|. |
+ virtual void ToValue(base::Value** value) const = 0; |
+ |
+ // Clones this. |
+ virtual APIPermissionDetail* Clone() const = 0; |
+ |
+ // Returns a new created differences detail objectbetween this and |
miket_OOO
2012/07/31 18:18:37
typo. Also, this description is not fluent. "Retur
Peng
2012/07/31 19:32:28
Done.
|
+ // |detail| (this - |detal|). |
miket_OOO
2012/07/31 18:18:37
typo
Peng
2012/07/31 19:32:28
Done.
|
+ virtual APIPermissionDetail* Diff( |
+ const APIPermissionDetail* detail) const = 0; |
+ |
+ // Returns a new created union detail of this and |detail|. |
miket_OOO
2012/07/31 18:18:37
same (et seq.)
Peng
2012/07/31 19:32:28
Done.
|
+ virtual APIPermissionDetail* Union( |
+ const APIPermissionDetail* detail) const = 0; |
+ |
+ // Returns a new created intersect detail of this and |detail|. |
+ virtual APIPermissionDetail* Intersect( |
+ const APIPermissionDetail* detail) const = 0; |
+ |
+ // IPC functions |
+ // Writes this into the given IPC message |m|. |
+ virtual void Write(IPC::Message *m) const = 0; |
+ |
+ // Reads from the given IPC message |m|. |
+ virtual bool Read(const IPC::Message *m, PickleIterator *iter) = 0; |
+ |
+ // Logs this detail. |
+ virtual void Log(std::string *l) const = 0; |
miket_OOO
2012/07/31 18:18:37
As a general readability rule, avoid lowercase L a
Peng
2012/07/31 19:32:28
Done.
|
+ |
+ protected: |
+ friend base::RefCounted<APIPermissionDetail>; |
+ virtual ~APIPermissionDetail(); |
+ |
+ private: |
+ const APIPermission* const permission_; |
+}; |
} // namespace extensions |