Index: extensions/common/permissions/permission_message_provider.h |
diff --git a/extensions/common/permissions/permission_message_provider.h b/extensions/common/permissions/permission_message_provider.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2404fc3e48054c6c489507d1a2a005ae93d6b476 |
--- /dev/null |
+++ b/extensions/common/permissions/permission_message_provider.h |
@@ -0,0 +1,62 @@ |
+// Copyright 2013 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 EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_ |
+#define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_ |
+ |
+#include <vector> |
+ |
+#include "extensions/common/manifest.h" |
+#include "extensions/common/permissions/permission_message.h" |
+ |
+namespace extensions { |
+ |
+class PermissionSet; |
+ |
+// The PermissionMessageProvider interprets permissions, translating them |
+// into warning messages to show to the user. It also determines whether |
+// a new set of permissions entails showing new warning messages. |
+class PermissionMessageProvider { |
+ public: |
+ PermissionMessageProvider() {} |
+ virtual ~PermissionMessageProvider() {} |
+ |
+ // Return the registered permission message provider for the extension type. |
+ static PermissionMessageProvider* Get(Manifest::Type extension_type); |
+ |
+ // Set the permissions providers for Get() to return. |default_provider| |
+ // is returned for types, unless a custom provider is given with that type |
+ // in |custom_providers|. Takes ownership of the given providers. |
+ static void SetProviders( |
Matt Perry
2013/10/16 20:07:04
This interface feels a bit clunky. How about split
Yoyo Zhou
2013/10/17 19:45:52
I moved the ownership to ChromeExtensionsClient.
|
+ PermissionMessageProvider* default_provider, |
+ const std::vector<std::pair<Manifest::Type, PermissionMessageProvider*> >& |
+ custom_providers); |
+ |
+ // Gets the localized permission messages that represent this set. |
+ // The set of permission messages shown varies by extension type. |
+ virtual PermissionMessages GetPermissionMessages( |
+ const PermissionSet* permissions) const = 0; |
+ |
+ // Gets the localized permission messages that represent this set (represented |
+ // as strings). The set of permission messages shown varies by extension type. |
+ virtual std::vector<string16> GetWarningMessages( |
+ const PermissionSet* permissions) const = 0; |
+ |
+ // Gets the localized permission details for messages that represent this set |
+ // (represented as strings). The set of permission messages shown varies by |
+ // extension type. |
+ virtual std::vector<string16> GetWarningMessagesDetails( |
+ const PermissionSet* permissions) const = 0; |
+ |
+ // Returns true if |new_permissions| has a greater privilege level than |
+ // |old_permissions|. |
+ // Whether certain permissions are considered varies by extension type. |
+ virtual bool IsPrivilegeIncrease( |
+ const PermissionSet* old_permissions, |
+ const PermissionSet* new_permissions) const = 0; |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_ |