diff options
author | treib <treib@chromium.org> | 2015-08-20 07:27:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-20 14:28:05 +0000 |
commit | 399178470b3d78bb383cdc56d8a3af6474174271 (patch) | |
tree | 2ce20de5e49f75b59d8333b0611469d261df3ffb /extensions/common/permissions | |
parent | 391140ca9b908a7a550b3d8573ea16c44ee3d8bc (diff) | |
download | chromium_src-399178470b3d78bb383cdc56d8a3af6474174271.zip chromium_src-399178470b3d78bb383cdc56d8a3af6474174271.tar.gz chromium_src-399178470b3d78bb383cdc56d8a3af6474174271.tar.bz2 |
Extensions: Remove PermissionMessage (permission_message.h/cc)
and all the (unused) code that referenced it.
[This is part 5 of operation "remove the old permission message system".]
BUG=398257
Review URL: https://codereview.chromium.org/1213623006
Cr-Commit-Position: refs/heads/master@{#344495}
Diffstat (limited to 'extensions/common/permissions')
14 files changed, 19 insertions, 353 deletions
diff --git a/extensions/common/permissions/api_permission.cc b/extensions/common/permissions/api_permission.cc index 70b71ce..89eaea5 100644 --- a/extensions/common/permissions/api_permission.cc +++ b/extensions/common/permissions/api_permission.cc @@ -11,8 +11,6 @@ namespace { using extensions::APIPermission; using extensions::APIPermissionInfo; -using extensions::PermissionMessage; -using extensions::PermissionMessages; class SimpleAPIPermission : public APIPermission { public: diff --git a/extensions/common/permissions/api_permission.h b/extensions/common/permissions/api_permission.h index 8600454..01e075e 100644 --- a/extensions/common/permissions/api_permission.h +++ b/extensions/common/permissions/api_permission.h @@ -13,7 +13,6 @@ #include "base/memory/scoped_ptr.h" #include "base/pickle.h" #include "base/values.h" -#include "extensions/common/permissions/permission_message.h" namespace IPC { class Message; diff --git a/extensions/common/permissions/extensions_api_permissions.cc b/extensions/common/permissions/extensions_api_permissions.cc index 6977f8f..c9eb11b 100644 --- a/extensions/common/permissions/extensions_api_permissions.cc +++ b/extensions/common/permissions/extensions_api_permissions.cc @@ -7,7 +7,6 @@ #include <vector> #include "extensions/common/permissions/api_permission.h" -#include "extensions/common/permissions/permission_message.h" #include "extensions/common/permissions/socket_permission.h" #include "extensions/common/permissions/usb_device_permission.h" #include "grit/extensions_strings.h" diff --git a/extensions/common/permissions/manifest_permission.h b/extensions/common/permissions/manifest_permission.h index 31e6ffc..6bb5be6 100644 --- a/extensions/common/permissions/manifest_permission.h +++ b/extensions/common/permissions/manifest_permission.h @@ -11,7 +11,6 @@ #include "base/pickle.h" #include "extensions/common/permissions/api_permission_set.h" #include "extensions/common/permissions/coalesced_permission_message.h" -#include "extensions/common/permissions/permission_message.h" namespace base { class PickleIterator; diff --git a/extensions/common/permissions/media_galleries_permission.cc b/extensions/common/permissions/media_galleries_permission.cc index 864d13e..1b3b919 100644 --- a/extensions/common/permissions/media_galleries_permission.cc +++ b/extensions/common/permissions/media_galleries_permission.cc @@ -38,12 +38,10 @@ bool IsValidPermissionSet(bool has_read, bool has_copy_to, bool has_delete, return true; } -// Adds the permissions from the |data_set| to the permission lists that are -// not NULL. If NULL, that list is ignored. +// Adds the permissions from the |data_set| to |ids|. void AddPermissionsToLists( const std::set<MediaGalleriesPermissionData>& data_set, - PermissionIDSet* ids, - PermissionMessages* messages) { + PermissionIDSet* ids) { // TODO(sashab): Once GetMessages() is deprecated, move this logic back into // GetPermissions(). bool has_all_auto_detected = false; @@ -80,38 +78,16 @@ void AddPermissionsToLists( // Separate PermissionMessage IDs for read, copyTo, and delete. Otherwise an // extension can silently gain new access capabilities. - if (messages) { - messages->push_back(PermissionMessage( - PermissionMessage::kMediaGalleriesAllGalleriesRead, - l10n_util::GetStringUTF16( - IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ))); - } - if (ids) - ids->insert(APIPermission::kMediaGalleriesAllGalleriesRead); + ids->insert(APIPermission::kMediaGalleriesAllGalleriesRead); // For copyTo and delete, the proper combined permission message will be // derived in ChromePermissionMessageProvider::GetWarningMessages(), such // that the user get 1 entry for all media galleries access permissions, // rather than several separate entries. - if (has_copy_to) { - if (messages) { - messages->push_back(PermissionMessage( - PermissionMessage::kMediaGalleriesAllGalleriesCopyTo, - base::string16())); - } - if (ids) - ids->insert(APIPermission::kMediaGalleriesAllGalleriesCopyTo); - } - if (has_delete) { - if (messages) { - messages->push_back(PermissionMessage( - PermissionMessage::kMediaGalleriesAllGalleriesDelete, - base::string16())); - } - if (ids) - ids->insert(APIPermission::kMediaGalleriesAllGalleriesDelete); - } - return; + if (has_copy_to) + ids->insert(APIPermission::kMediaGalleriesAllGalleriesCopyTo); + if (has_delete) + ids->insert(APIPermission::kMediaGalleriesAllGalleriesDelete); } } // namespace @@ -188,7 +164,7 @@ bool MediaGalleriesPermission::FromValue( PermissionIDSet MediaGalleriesPermission::GetPermissions() const { PermissionIDSet result; - AddPermissionsToLists(data_set_, &result, NULL); + AddPermissionsToLists(data_set_, &result); return result; } diff --git a/extensions/common/permissions/permission_message.cc b/extensions/common/permissions/permission_message.cc deleted file mode 100644 index bc2008e..0000000 --- a/extensions/common/permissions/permission_message.cc +++ /dev/null @@ -1,29 +0,0 @@ -// 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 base::string16& message) - : id_(id), - message_(message) { -} - -PermissionMessage::PermissionMessage( - PermissionMessage::ID id, - const base::string16& message, - const base::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 deleted file mode 100644 index e4df834..0000000 --- a/extensions/common/permissions/permission_message.h +++ /dev/null @@ -1,157 +0,0 @@ -// 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. - // TODO(sashab): Deprecate these IDs - use whatever APIPermission::ID becomes - // instead. - enum ID { - kUnknown, - kNone, - kBookmarks, - kGeolocation, - kBrowsingHistory, - kTabs, - kManagement, - kDebugger, - kDesktopCapture, - kHid, - kHosts1, - kHosts2, - kHosts3, - kHosts4OrMore, - kHostsAll, - kFullAccess, - kClipboard, - kTtsEngine, - kContentSettings, - kPrivacy, - kSupervisedUser, - kInput, - kAudioCapture, - kVideoCapture, - kDownloads, - kDeleted_FileSystemWrite, - 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, - kHomepage, - kSearchProvider, - kStartupPages, - kMediaGalleriesAllGalleriesDelete, - kScreenlockPrivate, - kOverrideBookmarksUI, - kAutomation, - kAccessibilityFeaturesModify, - kAccessibilityFeaturesRead, - kBluetoothPrivate, - kIdentityEmail, - kExperienceSamplingPrivate, - kCopresence, - kTopSites, - kU2fDevices, - kDocumentScan, - kNetworkingConfig, - kPlatformKeys, - kMDns, - kVpnProvider, - kHosts1ReadOnly, - kHosts2ReadOnly, - kHosts3ReadOnly, - kHosts4OrMoreReadOnly, - kHostsAllReadOnly, - kInterceptAllKeys, - kSettingsPrivate, - kPrinterProvider, - kSearchEnginesPrivate, - kAutofillPrivate, - kPasswordsPrivate, - kUsersPrivate, - // Last entry: Add new entries above. - kEnumBoundary, - }; - static_assert(PermissionMessage::kNone > PermissionMessage::kUnknown, - "kNone should not greater than kUnknown"); - - // Creates the corresponding permission message. - PermissionMessage(ID id, const base::string16& message); - PermissionMessage(ID id, - const base::string16& message, - const base::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 base::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 base::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_; - base::string16 message_; - base::string16 details_; -}; - -typedef std::vector<PermissionMessage> PermissionMessages; - -} // namespace extensions - -#endif // EXTENSIONS_COMMON_PERMISSIONS_PERMISSION_MESSAGE_H_ diff --git a/extensions/common/permissions/permission_message_util.cc b/extensions/common/permissions/permission_message_util.cc index 2358ac4..ccd4722 100644 --- a/extensions/common/permissions/permission_message_util.cc +++ b/extensions/common/permissions/permission_message_util.cc @@ -9,7 +9,6 @@ #include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" #include "extensions/common/permissions/coalesced_permission_message.h" -#include "extensions/common/permissions/permission_message.h" #include "extensions/common/permissions/permission_set.h" #include "extensions/common/url_pattern_set.h" #include "grit/extensions_strings.h" @@ -17,7 +16,6 @@ #include "ui/base/l10n/l10n_util.h" #include "url/url_constants.h" -using extensions::PermissionMessage; using extensions::URLPatternSet; namespace { @@ -65,58 +63,6 @@ std::vector<base::string16> GetHostListFromHosts( return host_list; } -PermissionMessage CreateFromHostList(const std::set<std::string>& hosts, - PermissionMessageProperties properties) { - typedef std::pair<PermissionMessage::ID, int> MsgPair; - static const MsgPair kReadWriteMessagesList[] = { - std::make_pair(PermissionMessage::kHosts1, - IDS_EXTENSION_PROMPT_WARNING_1_HOST), - std::make_pair(PermissionMessage::kHosts2, - IDS_EXTENSION_PROMPT_WARNING_2_HOSTS), - std::make_pair(PermissionMessage::kHosts3, - IDS_EXTENSION_PROMPT_WARNING_3_HOSTS), - std::make_pair(PermissionMessage::kHosts4OrMore, - IDS_EXTENSION_PROMPT_WARNING_HOSTS_LIST)}; - static const MsgPair kReadOnlyMessagesList[] = { - std::make_pair(PermissionMessage::kHosts1ReadOnly, - IDS_EXTENSION_PROMPT_WARNING_1_HOST_READ_ONLY), - std::make_pair(PermissionMessage::kHosts2ReadOnly, - IDS_EXTENSION_PROMPT_WARNING_2_HOSTS_READ_ONLY), - std::make_pair(PermissionMessage::kHosts3ReadOnly, - IDS_EXTENSION_PROMPT_WARNING_3_HOSTS_READ_ONLY), - std::make_pair(PermissionMessage::kHosts4OrMoreReadOnly, - IDS_EXTENSION_PROMPT_WARNING_HOSTS_LIST_READ_ONLY)}; - static_assert( - arraysize(kReadWriteMessagesList) == arraysize(kReadOnlyMessagesList), - "message lists should be of different size"); - static_assert(kNumMessages == arraysize(kReadWriteMessagesList), - "messages array should be of different size"); - - const MsgPair(&messages_list)[kNumMessages] = - properties == kReadOnly ? kReadOnlyMessagesList : kReadWriteMessagesList; - std::vector<base::string16> host_list = - GetHostListFromHosts(hosts, properties); - - if (host_list.size() < kNumMessages) { - return PermissionMessage( - messages_list[host_list.size() - 1].first, - l10n_util::GetStringFUTF16(messages_list[host_list.size() - 1].second, - host_list, NULL)); - } - - base::string16 details; - for (size_t i = 0; i < host_list.size(); ++i) { - if (i > 0) - details += base::ASCIIToUTF16("\n"); - details += host_list[i]; - } - return PermissionMessage( - messages_list[arraysize(messages_list) - 1].first, - l10n_util::GetStringUTF16( - messages_list[arraysize(messages_list) - 1].second), - details); -} - void AddHostPermissions(extensions::PermissionIDSet* permissions, const std::set<std::string>& hosts, PermissionMessageProperties properties) { diff --git a/extensions/common/permissions/permission_message_util.h b/extensions/common/permissions/permission_message_util.h index 995d226..fc006d7 100644 --- a/extensions/common/permissions/permission_message_util.h +++ b/extensions/common/permissions/permission_message_util.h @@ -13,7 +13,6 @@ namespace extensions { class PermissionIDSet; -class PermissionMessage; class URLPatternSet; } @@ -23,20 +22,11 @@ enum PermissionMessageProperties { kReadOnly, kReadWrite }; // Get a list of hosts to display in a permission message from the given list of // hosts from the manifest. -// TODO(sashab): Merge this into AddHostPermissions() once CreateFromHostList() -// is deprecated. +// TODO(sashab): Merge this into AddHostPermissions(). std::vector<base::string16> GetHostListFromHosts( const std::set<std::string>& hosts, PermissionMessageProperties properties); -// Creates the corresponding permission message for a list of hosts. -// The messages change depending on how many hosts are present, and whether -// |read_only| is true. -// TODO(sashab): Deprecate this, prefer AddHostPermissions() instead. -extensions::PermissionMessage CreateFromHostList( - const std::set<std::string>& hosts, - PermissionMessageProperties); - // Adds the appropriate permissions from given hosts to |permissions|. void AddHostPermissions(extensions::PermissionIDSet* permissions, const std::set<std::string>& hosts, diff --git a/extensions/common/permissions/permissions_data.h b/extensions/common/permissions/permissions_data.h index ed55c2b..0112210 100644 --- a/extensions/common/permissions/permissions_data.h +++ b/extensions/common/permissions/permissions_data.h @@ -15,7 +15,6 @@ #include "extensions/common/manifest.h" #include "extensions/common/permissions/api_permission.h" #include "extensions/common/permissions/coalesced_permission_message.h" -#include "extensions/common/permissions/permission_message.h" #include "extensions/common/permissions/permission_message_provider.h" #include "extensions/common/permissions/permission_set.h" diff --git a/extensions/common/permissions/permissions_info.h b/extensions/common/permissions/permissions_info.h index 0f0fb35..43d61b2 100644 --- a/extensions/common/permissions/permissions_info.h +++ b/extensions/common/permissions/permissions_info.h @@ -13,7 +13,6 @@ #include "base/lazy_instance.h" #include "extensions/common/permissions/api_permission.h" #include "extensions/common/permissions/api_permission_set.h" -#include "extensions/common/permissions/permission_message.h" #include "extensions/common/permissions/permissions_provider.h" namespace extensions { diff --git a/extensions/common/permissions/socket_permission.cc b/extensions/common/permissions/socket_permission.cc index 1826282..c2ca223 100644 --- a/extensions/common/permissions/socket_permission.cc +++ b/extensions/common/permissions/socket_permission.cc @@ -41,7 +41,7 @@ SocketPermission::~SocketPermission() {} PermissionIDSet SocketPermission::GetPermissions() const { PermissionIDSet ids; SocketPermissionEntrySet entries = ExtractSocketEntries(data_set_); - SocketsManifestPermission::AddSocketHostPermissions(entries, &ids, NULL); + SocketsManifestPermission::AddSocketHostPermissions(entries, &ids); return ids; } diff --git a/extensions/common/permissions/socket_permission.h b/extensions/common/permissions/socket_permission.h index d554293..3fb1262 100644 --- a/extensions/common/permissions/socket_permission.h +++ b/extensions/common/permissions/socket_permission.h @@ -29,23 +29,6 @@ class SocketPermission ~SocketPermission() override; PermissionIDSet GetPermissions() const override; - - private: - // Add all host messages for this manifest permission into the given lists. - // TODO(sashab): Remove the |messages| argument from these methods, and remove - // the AddAllHostMessages() function (move all the logic into GetPermissions() - // above). - void AddAllHostMessages(PermissionMessages& messages, - PermissionIDSet& ids) const; - - bool AddAnyHostMessage(PermissionMessages& messages, - PermissionIDSet& ids) const; - void AddSubdomainHostMessage(PermissionMessages& messages, - PermissionIDSet& ids) const; - void AddSpecificHostMessage(PermissionMessages& messages, - PermissionIDSet& ids) const; - void AddNetworkListMessage(PermissionMessages& messages, - PermissionIDSet& ids) const; }; } // namespace extensions diff --git a/extensions/common/permissions/usb_device_permission.cc b/extensions/common/permissions/usb_device_permission.cc index 287cf24..bedf6b0 100644 --- a/extensions/common/permissions/usb_device_permission.cc +++ b/extensions/common/permissions/usb_device_permission.cc @@ -21,11 +21,9 @@ namespace extensions { namespace { -// Adds the permissions from the |data_set| to the permission lists that are -// not NULL. If NULL, that list is ignored. +// Adds the permissions from the |data_set| to |ids|. void AddPermissionsToLists(const std::set<UsbDevicePermissionData>& data_set, - PermissionIDSet* ids, - PermissionMessages* messages) { + PermissionIDSet* ids) { // TODO(sashab): Once GetMessages() is deprecated, move this logic back into // GetPermissions(). // TODO(sashab, reillyg): Once GetMessages() is deprecated, rework the @@ -43,38 +41,13 @@ void AddPermissionsToLists(const std::set<UsbDevicePermissionData>& data_set, IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_PRODUCT_NAME_AND_VENDOR, base::UTF8ToUTF16(product), base::UTF8ToUTF16(vendor)); - if (messages) { - messages->push_back( - PermissionMessage(PermissionMessage::kUsbDevice, - l10n_util::GetStringFUTF16( - IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE, - product_name_and_vendor))); - } - if (ids) - ids->insert(APIPermission::kUsbDevice, product_name_and_vendor); + ids->insert(APIPermission::kUsbDevice, product_name_and_vendor); } else { - if (messages) { - messages->push_back(PermissionMessage( - PermissionMessage::kUsbDevice, - l10n_util::GetStringFUTF16( - IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_UNKNOWN_PRODUCT, - base::UTF8ToUTF16(vendor)))); - } - if (ids) { - ids->insert(APIPermission::kUsbDeviceUnknownProduct, - base::UTF8ToUTF16(vendor)); - } + ids->insert(APIPermission::kUsbDeviceUnknownProduct, + base::UTF8ToUTF16(vendor)); } } else { - if (messages) { - messages->push_back(PermissionMessage( - PermissionMessage::kUsbDevice, - l10n_util::GetStringUTF16( - IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_UNKNOWN_VENDOR))); - } - if (ids) { - ids->insert(APIPermission::kUsbDeviceUnknownVendor); - } + ids->insert(APIPermission::kUsbDeviceUnknownVendor); } } else if (data_set.size() > 1) { std::vector<base::string16> details; @@ -116,17 +89,8 @@ void AddPermissionsToLists(const std::set<UsbDevicePermissionData>& data_set, IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_LIST_ITEM_UNKNOWN_VENDOR)); } - if (messages) { - messages->push_back(PermissionMessage( - PermissionMessage::kUsbDevice, - l10n_util::GetStringUTF16( - IDS_EXTENSION_PROMPT_WARNING_USB_DEVICE_LIST), - base::JoinString(details, base::ASCIIToUTF16("\n")))); - } - if (ids) { - for (const auto& detail : details) - ids->insert(APIPermission::kUsbDeviceList, detail); - } + for (const auto& detail : details) + ids->insert(APIPermission::kUsbDeviceList, detail); } } @@ -142,7 +106,7 @@ UsbDevicePermission::~UsbDevicePermission() { PermissionIDSet UsbDevicePermission::GetPermissions() const { PermissionIDSet ids; - AddPermissionsToLists(data_set_, &ids, NULL); + AddPermissionsToLists(data_set_, &ids); return ids; } |