Chromium Code Reviews| 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..7d293b6e487f42043c9f9a067a1873e8ac2c3ae9 100644 |
| --- a/chrome/common/extensions/permissions/chrome_permission_message_provider.cc |
| +++ b/chrome/common/extensions/permissions/chrome_permission_message_provider.cc |
| @@ -80,6 +80,28 @@ 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}, |
| + // History already allows tabs access. |
| + {PermissionMessage::kBrowsingHistory, PermissionMessage::kTabs}, |
| + // 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. |
|
meacer
2014/07/18 22:19:49
Would it make sense to make this comment similar t
mhm
2014/07/18 22:40:41
I am not sure what is needed for that bug.
|
| + {PermissionMessage::kFileSystemWriteDirectory, |
| + PermissionMessage::kFileSystemDirectory}, |
| + // Full access already allows DeclarativeWebRequest. |
| + {PermissionMessage::kHostsAll, PermissionMessage::kDeclarativeWebRequest}, |
| + // Full access already covers tabs access. |
| + {PermissionMessage::kHostsAll, PermissionMessage::kTabs}, |
| + // Tabs already allows reading favicons. |
| + {PermissionMessage::kTabs, PermissionMessage::kFavicon}}; |
| + |
| PermissionMessages messages; |
| if (permissions->HasEffectiveFullAccess()) { |
| @@ -99,32 +121,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++) { |
|
meacer
2014/07/18 22:19:49
nit: ++it instead of it++
mhm
2014/07/18 22:40:41
Done.
|
| + SuppressMessage(messages, it->first, it->second); |
| + } |
| return messages; |
| } |
| @@ -136,10 +139,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 +315,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 |