1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_
#define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/strings/string16.h"
namespace extensions {
// When prompting the user to install or approve permissions, we display
// messages describing the effects of the permissions rather than listing the
// permissions themselves. Each PermissionMessage represents one of the
// messages shown to the user.
class PermissionMessage {
public:
// Do not reorder this enumeration. If you need to add a new enum, add it just
// prior to kEnumBoundary.
enum ID {
kUnknown,
kNone,
kBookmarks,
kGeolocation,
kBrowsingHistory,
kTabs,
kManagement,
kDebugger,
kDesktopCapture,
kHosts1,
kHosts2,
kHosts3,
kHosts4OrMore,
kHostsAll,
kFullAccess,
kClipboard,
kTtsEngine,
kContentSettings,
kPrivacy,
kManagedMode,
kInput,
kAudioCapture,
kVideoCapture,
kDownloads,
kFileSystemWrite,
kMediaGalleriesAllGalleriesRead,
kSerial,
kSocketAnyHost,
kSocketDomainHosts,
kSocketSpecificHosts,
kBluetooth,
kUsb,
kSystemIndicator,
kUsbDevice,
kMediaGalleriesAllGalleriesCopyTo,
kSystemInfoDisplay,
kNativeMessaging,
kSyncFileSystem,
kAudio,
kFavicon,
kMusicManagerPrivate,
kWebConnectable,
kActivityLogPrivate,
kBluetoothDevices,
kDownloadsOpen,
kNetworkingPrivate,
kDeclarativeWebRequest,
kFileSystemDirectory,
kFileSystemWriteDirectory,
kSignedInDevices,
kWallpaper,
kNetworkState,
kEnumBoundary,
};
COMPILE_ASSERT(PermissionMessage::kNone > PermissionMessage::kUnknown,
kNone_not_greater_than_kUnknown);
// Creates the corresponding permission message.
PermissionMessage(ID id, const string16& message);
PermissionMessage(ID id, const string16& message, const string16& details);
~PermissionMessage();
// Gets the id of the permission message, which can be used in UMA
// histograms.
ID id() const { return id_; }
// Gets a localized message describing this permission. Please note that
// the message will be empty for message types TYPE_NONE and TYPE_UNKNOWN.
const string16& message() const { return message_; }
// Gets a localized message describing the details for this permission. Please
// note that the message will be empty for message types TYPE_NONE and
// TYPE_UNKNOWN.
const string16& details() const { return details_; }
// Comparator to work with std::set.
bool operator<(const PermissionMessage& that) const {
return id_ < that.id_;
}
// Comparator to work with base::STLSetDifference.
bool operator>(const PermissionMessage& that) const {
return id_ > that.id_;
}
private:
ID id_;
string16 message_;
string16 details_;
};
typedef std::vector<PermissionMessage> PermissionMessages;
} // namespace extensions
#endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_
|