Fix crash on app list start page contents not existing.
[chromium-blink-merge.git] / extensions / common / permissions / permission_message_provider.h
bloba140e4354c258ab009253ebbd3b0c0bc196890c1
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_
8 #include <vector>
10 #include "extensions/common/manifest.h"
11 #include "extensions/common/permissions/coalesced_permission_message.h"
12 #include "extensions/common/permissions/permission_message.h"
14 namespace extensions {
16 class PermissionIDSet;
17 class PermissionSet;
19 // The PermissionMessageProvider interprets permissions, translating them
20 // into warning messages to show to the user. It also determines whether
21 // a new set of permissions entails showing new warning messages.
22 class PermissionMessageProvider {
23 public:
24 PermissionMessageProvider() {}
25 virtual ~PermissionMessageProvider() {}
27 // Return the global permission message provider.
28 static const PermissionMessageProvider* Get();
30 // Gets the localized permission messages that represent this set.
31 // The set of permission messages shown varies by extension type.
32 // TODO(sashab): Deprecate this method in favor of
33 // GetCoalescedPermissionMessages() instead.
34 virtual PermissionMessages GetPermissionMessages(
35 const PermissionSet* permissions,
36 Manifest::Type extension_type) const = 0;
38 // Calculates and returns the full list of permission messages for the given
39 // |permissions|. This involves converting the given PermissionIDs into
40 // localized messages, as well as coalescing and parameterizing any messages
41 // that require the permission ID's argument in their message.
42 // TODO(sashab): Rename this to GetPermissionMessages() once the current one
43 // is deprecated.
44 virtual CoalescedPermissionMessages GetCoalescedPermissionMessages(
45 const PermissionIDSet& permissions) const = 0;
47 // Gets the localized permission messages that represent this set (represented
48 // as strings). The set of permission messages shown varies by extension type.
49 // Any permissions added by API, host or manifest permissions need to be added
50 // to |permissions| before this function is called.
51 // TODO(sashab): Deprecate this method in favor of
52 // GetCoalescedPermissionMessages().
53 virtual std::vector<base::string16> GetWarningMessages(
54 const PermissionSet* permissions,
55 Manifest::Type extension_type) const = 0;
57 // Gets the localized permission details for messages that represent this set
58 // (represented as strings). The set of permission messages shown varies by
59 // extension type.
60 // TODO(sashab): Deprecate this method in favor of
61 // GetCoalescedPermissionMessages().
62 virtual std::vector<base::string16> GetWarningMessagesDetails(
63 const PermissionSet* permissions,
64 Manifest::Type extension_type) const = 0;
66 // Returns true if |new_permissions| has a greater privilege level than
67 // |old_permissions|.
68 // Whether certain permissions are considered varies by extension type.
69 // TODO(sashab): Add an implementation of this method that uses
70 // PermissionIDSet instead, then deprecate this one.
71 virtual bool IsPrivilegeIncrease(
72 const PermissionSet* old_permissions,
73 const PermissionSet* new_permissions,
74 Manifest::Type extension_type) const = 0;
76 // Given the permissions for an extension, finds the IDs of all the
77 // permissions for that extension (including API, manifest and host
78 // permissions).
79 // TODO(sashab): This uses the legacy PermissionSet type. Deprecate or rename
80 // this type, and make this take as little as is needed to work out the
81 // PermissionIDSet.
82 virtual PermissionIDSet GetAllPermissionIDs(
83 const PermissionSet* permissions,
84 Manifest::Type extension_type) const = 0;
87 } // namespace extensions
89 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_