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

Side by Side Diff: extensions/common/permissions/permission_message_provider.h

Issue 980353003: Extensions: Switch to new permission message system, part I (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_ 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_ 6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "extensions/common/manifest.h" 10 #include "extensions/common/manifest.h"
11 #include "extensions/common/permissions/coalesced_permission_message.h" 11 #include "extensions/common/permissions/coalesced_permission_message.h"
12 #include "extensions/common/permissions/permission_message.h" 12 #include "extensions/common/permissions/permission_message.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 class PermissionIDSet; 16 class PermissionIDSet;
17 class PermissionSet; 17 class PermissionSet;
18 18
19 // Temporary type to help the transition between old and new system. 19 // Temporary type to help the transition between old and new system.
20 // Essentially a CoalescedPermissionMessage minus the IDs. 20 // Essentially a CoalescedPermissionMessage minus the IDs.
21 // TODO(treib): Remove this once we've switched to the new system. 21 // TODO(treib): Remove this once we've switched to the new system.
22 struct PermissionMessageString { 22 struct PermissionMessageString {
23 PermissionMessageString(const CoalescedPermissionMessage& message); 23 PermissionMessageString(const CoalescedPermissionMessage& message);
24 PermissionMessageString(const base::string16& message);
25 PermissionMessageString(const base::string16& message,
26 const std::vector<base::string16>& submessages);
24 PermissionMessageString(const base::string16& message, 27 PermissionMessageString(const base::string16& message,
25 const base::string16& details); 28 const base::string16& details);
26 ~PermissionMessageString(); 29 ~PermissionMessageString();
27 30
28 base::string16 message; 31 base::string16 message;
29 std::vector<base::string16> submessages; 32 std::vector<base::string16> submessages;
30 }; 33 };
31 typedef std::vector<PermissionMessageString> PermissionMessageStrings; 34 typedef std::vector<PermissionMessageString> PermissionMessageStrings;
32 35
36 enum class ForceForTesting {
37 DONT_FORCE,
38 FORCE_OLD,
39 FORCE_NEW
40 };
41
42 void ForcePermissionMessageSystemForTesting(ForceForTesting force);
43
33 // The PermissionMessageProvider interprets permissions, translating them 44 // The PermissionMessageProvider interprets permissions, translating them
34 // into warning messages to show to the user. It also determines whether 45 // into warning messages to show to the user. It also determines whether
35 // a new set of permissions entails showing new warning messages. 46 // a new set of permissions entails showing new warning messages.
36 class PermissionMessageProvider { 47 class PermissionMessageProvider {
37 public: 48 public:
38 PermissionMessageProvider() {} 49 PermissionMessageProvider() {}
39 virtual ~PermissionMessageProvider() {} 50 virtual ~PermissionMessageProvider() {}
40 51
41 // Return the global permission message provider. 52 // Return the global permission message provider.
42 static const PermissionMessageProvider* Get(); 53 static const PermissionMessageProvider* Get();
43 54
44 // Calculates and returns the full list of permission messages for the given 55 // Calculates and returns the full list of permission messages for the given
45 // |permissions|. This forwards to the new GetCoalescedPermissionMessages or 56 // |permissions|. This forwards to the new GetCoalescedPermissionMessages or
46 // to the old GetWarningMessages/GetWarningMessagesDetails, depending on a 57 // to the old GetWarningMessages/GetWarningMessagesDetails, depending on a
47 // cmdline flag. 58 // cmdline flag.
48 // TODO(treib): Remove this once we've switched to the new system, and update 59 // TODO(treib): Remove this once we've switched to the new system, and update
49 // all callers to use GetCoalescedPermissionMessages directly. 60 // all callers to use GetCoalescedPermissionMessages directly.
50 virtual PermissionMessageStrings GetPermissionMessageStrings( 61 PermissionMessageStrings GetPermissionMessageStrings(
51 const PermissionSet* permissions, 62 const PermissionSet* permissions,
52 Manifest::Type extension_type) const = 0; 63 Manifest::Type extension_type) const;
53 64
54 // Gets the legacy permission message IDs that represent this set. 65 // Gets the legacy permission message IDs that represent this set.
55 // Deprecated. You DO NOT want to call this! 66 // Deprecated. You DO NOT want to call this!
56 // TODO(treib): Remove this once we've switched to the new system. 67 // TODO(treib): Remove this once we've switched to the new system.
57 virtual PermissionMessageIDs GetLegacyPermissionMessageIDs( 68 virtual PermissionMessageIDs GetLegacyPermissionMessageIDs(
58 const PermissionSet* permissions, 69 const PermissionSet* permissions,
59 Manifest::Type extension_type) const = 0; 70 Manifest::Type extension_type) const = 0;
60 71
61 // Calculates and returns the full list of permission messages for the given 72 // Calculates and returns the full list of permission messages for the given
62 // |permissions|. This involves converting the given PermissionIDs into 73 // |permissions|. This involves converting the given PermissionIDs into
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // this type, and make this take as little as is needed to work out the 114 // this type, and make this take as little as is needed to work out the
104 // PermissionIDSet. 115 // PermissionIDSet.
105 virtual PermissionIDSet GetAllPermissionIDs( 116 virtual PermissionIDSet GetAllPermissionIDs(
106 const PermissionSet* permissions, 117 const PermissionSet* permissions,
107 Manifest::Type extension_type) const = 0; 118 Manifest::Type extension_type) const = 0;
108 }; 119 };
109 120
110 } // namespace extensions 121 } // namespace extensions
111 122
112 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_ 123 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_PROVIDER_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/management/management_api.cc ('k') | extensions/common/permissions/permission_message_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698