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 CHROME_COMMON_EXTENSIONS_PERMISSIONS_CHROME_PERMISSION_MESSAGE_PROVIDER_H_
6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_CHROME_PERMISSION_MESSAGE_PROVIDER_H_
10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h"
12 #include "base/strings/string16.h"
13 #include "extensions/common/permissions/permission_message_provider.h"
15 namespace extensions
{
17 // Tested in two places:
18 // 1. chrome_permission_message_provider_unittest.cc, which is a regular unit
19 // test for this class
20 // 2. chrome/browser/extensions/permission_messages_unittest.cc, which is an
21 // integration test that ensures messages are correctly generated for
22 // extensions created through the extension system.
23 class ChromePermissionMessageProvider
: public PermissionMessageProvider
{
25 ChromePermissionMessageProvider();
26 ~ChromePermissionMessageProvider() override
;
28 // PermissionMessageProvider implementation.
29 CoalescedPermissionMessages
GetPermissionMessages(
30 const PermissionIDSet
& permissions
) const override
;
31 bool IsPrivilegeIncrease(const PermissionSet
* old_permissions
,
32 const PermissionSet
* new_permissions
,
33 Manifest::Type extension_type
) const override
;
34 PermissionIDSet
GetAllPermissionIDs(
35 const PermissionSet
* permissions
,
36 Manifest::Type extension_type
) const override
;
39 // Adds any permission IDs from API permissions to |permission_ids|.
40 void AddAPIPermissions(const PermissionSet
* permissions
,
41 PermissionIDSet
* permission_ids
) const;
43 // Adds any permission IDs from manifest permissions to |permission_ids|.
44 void AddManifestPermissions(const PermissionSet
* permissions
,
45 PermissionIDSet
* permission_ids
) const;
47 // Adds any permission IDs from host permissions to |permission_ids|.
48 void AddHostPermissions(const PermissionSet
* permissions
,
49 PermissionIDSet
* permission_ids
,
50 Manifest::Type extension_type
) const;
52 // Returns true if |new_permissions| has an elevated API privilege level
53 // compared to |old_permissions|.
54 bool IsAPIPrivilegeIncrease(const PermissionSet
* old_permissions
,
55 const PermissionSet
* new_permissions
) const;
57 // Returns true if |new_permissions| has an elevated manifest permission
58 // privilege level compared to |old_permissions|.
59 bool IsManifestPermissionPrivilegeIncrease(
60 const PermissionSet
* old_permissions
,
61 const PermissionSet
* new_permissions
) const;
63 bool IsAPIOrManifestPrivilegeIncrease(const PermissionIDSet
& old_ids
,
64 const PermissionIDSet
& new_ids
) const;
66 // Returns true if |new_permissions| has more host permissions compared to
68 bool IsHostPrivilegeIncrease(
69 const PermissionSet
* old_permissions
,
70 const PermissionSet
* new_permissions
,
71 Manifest::Type extension_type
) const;
73 DISALLOW_COPY_AND_ASSIGN(ChromePermissionMessageProvider
);
76 } // namespace extensions
78 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_CHROME_PERMISSION_MESSAGE_PROVIDER_H_