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_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_
11 #include "base/basictypes.h"
12 #include "base/strings/string16.h"
14 namespace extensions
{
16 // When prompting the user to install or approve permissions, we display
17 // messages describing the effects of the permissions rather than listing the
18 // permissions themselves. Each PermissionMessage represents one of the
19 // messages shown to the user.
20 class PermissionMessage
{
22 // Do not reorder this enumeration. If you need to add a new enum, add it just
23 // prior to kEnumBoundary.
24 // TODO(sashab): Deprecate these IDs - use whatever APIPermission::ID becomes
52 kDeleted_FileSystemWrite
,
53 kMediaGalleriesAllGalleriesRead
,
62 kMediaGalleriesAllGalleriesCopyTo
,
74 kDeclarativeWebRequest
,
76 kFileSystemWriteDirectory
,
83 kMediaGalleriesAllGalleriesDelete
,
87 kAccessibilityFeaturesModify
,
88 kAccessibilityFeaturesRead
,
91 kExperienceSamplingPrivate
,
103 kHosts4OrMoreReadOnly
,
108 kSearchEnginesPrivate
,
112 // Last entry: Add new entries above.
115 static_assert(PermissionMessage::kNone
> PermissionMessage::kUnknown
,
116 "kNone should not greater than kUnknown");
118 // Creates the corresponding permission message.
119 PermissionMessage(ID id
, const base::string16
& message
);
120 PermissionMessage(ID id
,
121 const base::string16
& message
,
122 const base::string16
& details
);
123 ~PermissionMessage();
125 // Gets the id of the permission message, which can be used in UMA
127 ID
id() const { return id_
; }
129 // Gets a localized message describing this permission. Please note that
130 // the message will be empty for message types TYPE_NONE and TYPE_UNKNOWN.
131 const base::string16
& message() const { return message_
; }
133 // Gets a localized message describing the details for this permission. Please
134 // note that the message will be empty for message types TYPE_NONE and
136 const base::string16
& details() const { return details_
; }
138 // Comparator to work with std::set.
139 bool operator<(const PermissionMessage
& that
) const {
140 return id_
< that
.id_
;
142 // Comparator to work with base::STLSetDifference.
143 bool operator>(const PermissionMessage
& that
) const {
144 return id_
> that
.id_
;
149 base::string16 message_
;
150 base::string16 details_
;
153 typedef std::vector
<PermissionMessage
> PermissionMessages
;
154 typedef std::vector
<PermissionMessage::ID
> PermissionMessageIDs
;
156 } // namespace extensions
158 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_