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 kMediaGalleriesAllGalleriesDelete, 81 kScreenlockPrivate, 82 kHideBookmarkButton, 83 kEnumBoundary, 84 }; 85 COMPILE_ASSERT(PermissionMessage::kNone > PermissionMessage::kUnknown, 86 kNone_not_greater_than_kUnknown); 87 88 // Creates the corresponding permission message. 89 PermissionMessage(ID id, const string16& message); 90 PermissionMessage(ID id, const string16& message, const string16& details); 91 ~PermissionMessage(); 92 93 // Gets the id of the permission message, which can be used in UMA 94 // histograms. 95 ID id() const { return id_; } 96 97 // Gets a localized message describing this permission. Please note that 98 // the message will be empty for message types TYPE_NONE and TYPE_UNKNOWN. 99 const string16& message() const { return message_; } 100 101 // Gets a localized message describing the details for this permission. Please 102 // note that the message will be empty for message types TYPE_NONE and 103 // TYPE_UNKNOWN. 104 const string16& details() const { return details_; } 105 106 // Comparator to work with std::set. 107 bool operator<(const PermissionMessage& that) const { 108 return id_ < that.id_; 109 } 110 // Comparator to work with base::STLSetDifference. 111 bool operator>(const PermissionMessage& that) const { 112 return id_ > that.id_; 113 } 114 115 private: 116 ID id_; 117 string16 message_; 118 string16 details_; 119 }; 120 121 typedef std::vector<PermissionMessage> PermissionMessages; 122 123 } // namespace extensions 124 125 #endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_ 126