Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / extensions / common / permissions / permission_message.h
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.
4
5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/strings/string16.h"
13
14 namespace extensions {
15
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 {
21  public:
22   // Do not reorder this enumeration. If you need to add a new enum, add it just
23   // prior to kEnumBoundary.
24   enum ID {
25     kUnknown,
26     kNone,
27     kBookmarks,
28     kGeolocation,
29     kBrowsingHistory,
30     kTabs,
31     kManagement,
32     kDebugger,
33     kDesktopCapture,
34     kHid,
35     kHosts1,
36     kHosts2,
37     kHosts3,
38     kHosts4OrMore,
39     kHostsAll,
40     kFullAccess,
41     kClipboard,
42     kTtsEngine,
43     kContentSettings,
44     kPrivacy,
45     kSupervisedUser,
46     kInput,
47     kAudioCapture,
48     kVideoCapture,
49     kDownloads,
50     kDeleted_FileSystemWrite,
51     kMediaGalleriesAllGalleriesRead,
52     kSerial,
53     kSocketAnyHost,
54     kSocketDomainHosts,
55     kSocketSpecificHosts,
56     kBluetooth,
57     kUsb,
58     kSystemIndicator,
59     kUsbDevice,
60     kMediaGalleriesAllGalleriesCopyTo,
61     kSystemInfoDisplay,
62     kNativeMessaging,
63     kSyncFileSystem,
64     kAudio,
65     kFavicon,
66     kMusicManagerPrivate,
67     kWebConnectable,
68     kActivityLogPrivate,
69     kBluetoothDevices,
70     kDownloadsOpen,
71     kNetworkingPrivate,
72     kDeclarativeWebRequest,
73     kFileSystemDirectory,
74     kFileSystemWriteDirectory,
75     kSignedInDevices,
76     kWallpaper,
77     kNetworkState,
78     kHomepage,
79     kSearchProvider,
80     kStartupPages,
81     kMediaGalleriesAllGalleriesDelete,
82     kScreenlockPrivate,
83     kOverrideBookmarksUI,
84     kAutomation,
85     kAccessibilityFeaturesModify,
86     kAccessibilityFeaturesRead,
87     kBluetoothPrivate,
88     kIdentityEmail,
89     kExperienceSamplingPrivate,
90     kCopresence,
91     kTopSites,
92     kU2fDevices,
93     kEnumBoundary,
94   };
95   COMPILE_ASSERT(PermissionMessage::kNone > PermissionMessage::kUnknown,
96                  kNone_not_greater_than_kUnknown);
97
98   // Creates the corresponding permission message.
99   PermissionMessage(ID id, const base::string16& message);
100   PermissionMessage(ID id,
101                     const base::string16& message,
102                     const base::string16& details);
103   ~PermissionMessage();
104
105   // Gets the id of the permission message, which can be used in UMA
106   // histograms.
107   ID id() const { return id_; }
108
109   // Gets a localized message describing this permission. Please note that
110   // the message will be empty for message types TYPE_NONE and TYPE_UNKNOWN.
111   const base::string16& message() const { return message_; }
112
113   // Gets a localized message describing the details for this permission. Please
114   // note that the message will be empty for message types TYPE_NONE and
115   // TYPE_UNKNOWN.
116   const base::string16& details() const { return details_; }
117
118   // Comparator to work with std::set.
119   bool operator<(const PermissionMessage& that) const {
120     return id_ < that.id_;
121   }
122   // Comparator to work with base::STLSetDifference.
123   bool operator>(const PermissionMessage& that) const {
124     return id_ > that.id_;
125   }
126
127  private:
128   ID id_;
129   base::string16 message_;
130   base::string16 details_;
131 };
132
133 typedef std::vector<PermissionMessage> PermissionMessages;
134
135 }  // namespace extensions
136
137 #endif  // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_