- add sources.
[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     kHosts1,
35     kHosts2,
36     kHosts3,
37     kHosts4OrMore,
38     kHostsAll,
39     kFullAccess,
40     kClipboard,
41     kTtsEngine,
42     kContentSettings,
43     kPrivacy,
44     kManagedMode,
45     kInput,
46     kAudioCapture,
47     kVideoCapture,
48     kDownloads,
49     kFileSystemWrite,
50     kMediaGalleriesAllGalleriesRead,
51     kSerial,
52     kSocketAnyHost,
53     kSocketDomainHosts,
54     kSocketSpecificHosts,
55     kBluetooth,
56     kUsb,
57     kSystemIndicator,
58     kUsbDevice,
59     kMediaGalleriesAllGalleriesCopyTo,
60     kSystemInfoDisplay,
61     kNativeMessaging,
62     kSyncFileSystem,
63     kAudio,
64     kFavicon,
65     kMusicManagerPrivate,
66     kWebConnectable,
67     kActivityLogPrivate,
68     kBluetoothDevices,
69     kDownloadsOpen,
70     kNetworkingPrivate,
71     kDeclarativeWebRequest,
72     kFileSystemDirectory,
73     kFileSystemWriteDirectory,
74     kSignedInDevices,
75     kWallpaper,
76     kNetworkState,
77     kHomepage,
78     kSearchProvider,
79     kStartupPages,
80     kEnumBoundary,
81   };
82   COMPILE_ASSERT(PermissionMessage::kNone > PermissionMessage::kUnknown,
83                  kNone_not_greater_than_kUnknown);
84
85   // Creates the corresponding permission message.
86   PermissionMessage(ID id, const string16& message);
87   PermissionMessage(ID id, const string16& message, const string16& details);
88   ~PermissionMessage();
89
90   // Gets the id of the permission message, which can be used in UMA
91   // histograms.
92   ID id() const { return id_; }
93
94   // Gets a localized message describing this permission. Please note that
95   // the message will be empty for message types TYPE_NONE and TYPE_UNKNOWN.
96   const string16& message() const { return message_; }
97
98   // Gets a localized message describing the details for this permission. Please
99   // note that the message will be empty for message types TYPE_NONE and
100   // TYPE_UNKNOWN.
101   const string16& details() const { return details_; }
102
103   // Comparator to work with std::set.
104   bool operator<(const PermissionMessage& that) const {
105     return id_ < that.id_;
106   }
107   // Comparator to work with base::STLSetDifference.
108   bool operator>(const PermissionMessage& that) const {
109     return id_ > that.id_;
110   }
111
112  private:
113   ID id_;
114   string16 message_;
115   string16 details_;
116 };
117
118 typedef std::vector<PermissionMessage> PermissionMessages;
119
120 }  // namespace extensions
121
122 #endif  // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_