summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-27 21:46:14 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-27 21:46:14 +0000
commite54e710f716c7fedaf57b89c91afc37c4cbeb664 (patch)
tree7a6f1fb34b7225fd9bf51e1c77b15f58467a949f /extensions
parentacbc3fb9b41af24c83bd5f0688c03ee91fd35a25 (diff)
downloadchromium_src-e54e710f716c7fedaf57b89c91afc37c4cbeb664.zip
chromium_src-e54e710f716c7fedaf57b89c91afc37c4cbeb664.tar.gz
chromium_src-e54e710f716c7fedaf57b89c91afc37c4cbeb664.tar.bz2
Refactor PermissionMessage and move it to top-level extensions.
BUG=298586 R=benwells@chromium.org Review URL: https://codereview.chromium.org/24555005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225791 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r--extensions/common/permissions/permission_message.cc27
-rw-r--r--extensions/common/permissions/permission_message.h119
-rw-r--r--extensions/extensions.gyp2
3 files changed, 148 insertions, 0 deletions
diff --git a/extensions/common/permissions/permission_message.cc b/extensions/common/permissions/permission_message.cc
new file mode 100644
index 0000000..1b11a37
--- /dev/null
+++ b/extensions/common/permissions/permission_message.cc
@@ -0,0 +1,27 @@
+// 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.
+
+#include "extensions/common/permissions/permission_message.h"
+
+namespace extensions {
+//
+// PermissionMessage
+//
+
+PermissionMessage::PermissionMessage(
+ PermissionMessage::ID id, const string16& message)
+ : id_(id),
+ message_(message) {
+}
+
+PermissionMessage::PermissionMessage(
+ PermissionMessage::ID id, const string16& message, const string16& details)
+ : id_(id),
+ message_(message),
+ details_(details) {
+}
+
+PermissionMessage::~PermissionMessage() {}
+
+} // namespace extensions
diff --git a/extensions/common/permissions/permission_message.h b/extensions/common/permissions/permission_message.h
new file mode 100644
index 0000000..19c5799
--- /dev/null
+++ b/extensions/common/permissions/permission_message.h
@@ -0,0 +1,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_
diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp
index ebcdbfa..b9e1f209 100644
--- a/extensions/extensions.gyp
+++ b/extensions/extensions.gyp
@@ -64,6 +64,8 @@
'common/matcher/url_matcher_helpers.h',
'common/one_shot_event.cc',
'common/one_shot_event.h',
+ 'common/permissions/permission_message.cc',
+ 'common/permissions/permission_message.h',
'common/permissions/permissions_provider.h',
'common/stack_frame.cc',
'common/stack_frame.h',