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_
10 #include "extensions/common/manifest.h"
11 #include "extensions/common/permissions/permission_message.h"
13 namespace extensions
{
15 class PermissionIDSet
;
18 // The PermissionMessageProvider interprets permissions, translating them
19 // into warning messages to show to the user. It also determines whether
20 // a new set of permissions entails showing new warning messages.
21 class PermissionMessageProvider
{
23 PermissionMessageProvider() {}
24 virtual ~PermissionMessageProvider() {}
26 // Return the global permission message provider.
27 static const PermissionMessageProvider
* Get();
29 // Calculates and returns the full list of permission messages for the given
30 // |permissions|. This involves converting the given PermissionIDs into
31 // localized messages, as well as coalescing and parameterizing any messages
32 // that require the permission ID's argument in their message.
33 virtual PermissionMessages
GetPermissionMessages(
34 const PermissionIDSet
& permissions
) const = 0;
36 // Returns true if |new_permissions| has a greater privilege level than
38 // Whether certain permissions are considered varies by extension type.
39 // TODO(sashab): Add an implementation of this method that uses
40 // PermissionIDSet instead, then deprecate this one.
41 virtual bool IsPrivilegeIncrease(
42 const PermissionSet
* old_permissions
,
43 const PermissionSet
* new_permissions
,
44 Manifest::Type extension_type
) const = 0;
46 // Given the permissions for an extension, finds the IDs of all the
47 // permissions for that extension (including API, manifest and host
49 // TODO(sashab): This uses the legacy PermissionSet type. Deprecate or rename
50 // this type, and make this take as little as is needed to work out the
52 virtual PermissionIDSet
GetAllPermissionIDs(
53 const PermissionSet
* permissions
,
54 Manifest::Type extension_type
) const = 0;
57 } // namespace extensions
59 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_