Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2531)

Unified Diff: chrome/common/extensions/permissions/chrome_permission_message_provider.cc

Issue 404803004: Cleaned up the code for suppressed messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing kalman comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/permissions/chrome_permission_message_provider.cc
diff --git a/chrome/common/extensions/permissions/chrome_permission_message_provider.cc b/chrome/common/extensions/permissions/chrome_permission_message_provider.cc
index 3e8c56f21d48f4cff1d1d97d32b818309ccf2bf8..3546387e8a491343cc3ce654ce62005fe28be22d 100644
--- a/chrome/common/extensions/permissions/chrome_permission_message_provider.cc
+++ b/chrome/common/extensions/permissions/chrome_permission_message_provider.cc
@@ -80,6 +80,29 @@ ChromePermissionMessageProvider::~ChromePermissionMessageProvider() {
PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages(
const PermissionSet* permissions,
Manifest::Type extension_type) const {
+ // Some warnings are more generic and/or powerful and superseed other
+ // warnings. In that case, the first message suppresses the second one.
+ const std::multimap<PermissionMessage::ID,
+ PermissionMessage::ID> kSuppressList = {
+ {PermissionMessage::kBluetooth, PermissionMessage::kBluetoothDevices},
+ {PermissionMessage::kBookmarks, PermissionMessage::kOverrideBookmarksUI},
+ // History already allows reading favicons.
+ {PermissionMessage::kBrowsingHistory, PermissionMessage::kFavicon},
+ // Warning for history permission already covers warning for tabs.
+ {PermissionMessage::kBrowsingHistory, PermissionMessage::kTabs},
+ // Warning for full access already covers warning for
+ // DeclarativeWebRequest.
not at google - send to devlin 2014/07/18 21:36:33 comment is in the wrong place
mhm 2014/07/18 21:49:40 Done.
+ // A special hack: If kFileSystemWriteDirectory would be displayed, hide
+ // kFileSystemDirectory as the write directory message implies it.
not at google - send to devlin 2014/07/18 21:36:33 comment could be re-worded to be more consistent w
mhm 2014/07/18 21:49:40 Done.
+ // TODO(sammc): Remove this. See http://crbug.com/284849.
+ {PermissionMessage::kFileSystemWriteDirectory,
+ PermissionMessage::kFileSystemDirectory},
+ {PermissionMessage::kHostsAll, PermissionMessage::kDeclarativeWebRequest},
+ // Warning for full access permission already covers warning for tabs
+ {PermissionMessage::kHostsAll, PermissionMessage::kTabs},
+ // Tabs already allows reading favicons.
+ {PermissionMessage::kTabs, PermissionMessage::kFavicon}};
+
PermissionMessages messages;
if (permissions->HasEffectiveFullAccess()) {
@@ -99,32 +122,13 @@ PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages(
messages.insert(messages.end(), manifest_permission_msgs.begin(),
manifest_permission_msgs.end());
- // Some warnings are more generic and/or powerful and superseed other
- // warnings. In that case, suppress the superseeded warning.
- SuppressMessage(messages,
- PermissionMessage::kBookmarks,
- PermissionMessage::kOverrideBookmarksUI);
- // Both tabs and history already allow reading favicons.
- SuppressMessage(messages,
- PermissionMessage::kTabs,
- PermissionMessage::kFavicon);
- SuppressMessage(messages,
- PermissionMessage::kBrowsingHistory,
- PermissionMessage::kFavicon);
- // Warning for history permission already covers warning for tabs permission.
- SuppressMessage(messages,
- PermissionMessage::kBrowsingHistory,
- PermissionMessage::kTabs);
- // Warning for full access permission already covers warning for tabs
- // permission.
- SuppressMessage(messages,
- PermissionMessage::kHostsAll,
- PermissionMessage::kTabs);
- // Warning for full access already covers warning for DeclarativeWebRequest
- // permission.
- SuppressMessage(messages,
- PermissionMessage::kHostsAll,
- PermissionMessage::kDeclarativeWebRequest);
+ for (std::multimap<PermissionMessage::ID,
+ PermissionMessage::ID>::const_iterator it =
+ kSuppressList.begin();
+ it != kSuppressList.end();
+ it++) {
+ SuppressMessage(messages, it->first, it->second);
+ }
return messages;
}
@@ -136,10 +140,6 @@ std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages(
PermissionMessages messages =
GetPermissionMessages(permissions, extension_type);
- SuppressMessage(messages,
- PermissionMessage::kBluetooth,
- PermissionMessage::kBluetoothDevices);
-
for (PermissionMessages::const_iterator i = messages.begin();
i != messages.end(); ++i) {
int id = i->id();
@@ -316,12 +316,6 @@ ChromePermissionMessageProvider::GetAPIPermissionMessages(
}
}
- // A special hack: If kFileSystemWriteDirectory would be displayed, hide
- // kFileSystemDirectory as the write directory message implies it.
- // TODO(sammc): Remove this. See http://crbug.com/284849.
- SuppressMessage(messages,
- PermissionMessage::kFileSystemWriteDirectory,
- PermissionMessage::kFileSystemDirectory);
// A special hack: The warning message for declarativeWebRequest
// permissions speaks about blocking parts of pages, which is a
// subset of what the "<all_urls>" access allows. Therefore we
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698