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

Unified Diff: extensions/common/permissions/permission_message_provider.h

Issue 27446002: Move permission warning message handling from PermissionSet to PermissionMessageProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
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_

Powered by Google App Engine
This is Rietveld 408576698