Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/extensions/permissions/chrome_permission_message_provide r.h" | 5 #include "chrome/common/extensions/permissions/chrome_permission_message_provide r.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "extensions/common/extensions_client.h" | 9 #include "extensions/common/extensions_client.h" |
| 10 #include "extensions/common/permissions/permission_message.h" | 10 #include "extensions/common/permissions/permission_message.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 | 73 |
| 74 ChromePermissionMessageProvider::ChromePermissionMessageProvider() { | 74 ChromePermissionMessageProvider::ChromePermissionMessageProvider() { |
| 75 } | 75 } |
| 76 | 76 |
| 77 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() { | 77 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() { |
| 78 } | 78 } |
| 79 | 79 |
| 80 PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages( | 80 PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages( |
| 81 const PermissionSet* permissions, | 81 const PermissionSet* permissions, |
| 82 Manifest::Type extension_type) const { | 82 Manifest::Type extension_type) const { |
| 83 const std::multimap<PermissionMessage::ID, | |
| 84 PermissionMessage::ID> SuppressList = { | |
|
not at google - send to devlin
2014/07/18 20:17:25
should be kSuppressList I suppose?
mhm
2014/07/18 21:29:12
Done.
| |
| 85 // Some warnings are more generic and/or powerful and superseed other | |
|
not at google - send to devlin
2014/07/18 20:17:25
this comment applies to the whole variable right,
mhm
2014/07/18 21:29:12
Done.
| |
| 86 // warnings. In that case, suppress the superseeded warning. | |
| 87 {PermissionMessage::kBookmarks, PermissionMessage::kOverrideBookmarksUI}, | |
| 88 {PermissionMessage::kTabs, PermissionMessage::kFavicon}, | |
| 89 {PermissionMessage::kBrowsingHistory, PermissionMessage::kFavicon}, | |
| 90 {PermissionMessage::kBrowsingHistory, PermissionMessage::kTabs}, | |
| 91 {PermissionMessage::kHostsAll, PermissionMessage::kTabs}, | |
| 92 {PermissionMessage::kHostsAll, PermissionMessage::kDeclarativeWebRequest}, | |
| 93 {PermissionMessage::kBluetooth, PermissionMessage::kBluetoothDevices}, | |
| 94 // A special hack: If kFileSystemWriteDirectory would be displayed, hide | |
| 95 // kFileSystemDirectory as the write directory message implies it. | |
| 96 // TODO(sammc): Remove this. See http://crbug.com/284849. | |
| 97 {PermissionMessage::kFileSystemWriteDirectory, | |
| 98 PermissionMessage::kFileSystemDirectory}}; | |
|
not at google - send to devlin
2014/07/18 20:17:25
can you sort this list?
mhm
2014/07/18 21:29:12
Done.
| |
| 99 | |
| 83 PermissionMessages messages; | 100 PermissionMessages messages; |
| 84 | 101 |
| 85 if (permissions->HasEffectiveFullAccess()) { | 102 if (permissions->HasEffectiveFullAccess()) { |
| 86 messages.push_back(PermissionMessage( | 103 messages.push_back(PermissionMessage( |
| 87 PermissionMessage::kFullAccess, | 104 PermissionMessage::kFullAccess, |
| 88 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); | 105 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); |
| 89 return messages; | 106 return messages; |
| 90 } | 107 } |
| 91 | 108 |
| 92 PermissionMsgSet host_msgs = | 109 PermissionMsgSet host_msgs = |
| 93 GetHostPermissionMessages(permissions, extension_type); | 110 GetHostPermissionMessages(permissions, extension_type); |
| 94 PermissionMsgSet api_msgs = GetAPIPermissionMessages(permissions); | 111 PermissionMsgSet api_msgs = GetAPIPermissionMessages(permissions); |
| 95 PermissionMsgSet manifest_permission_msgs = | 112 PermissionMsgSet manifest_permission_msgs = |
| 96 GetManifestPermissionMessages(permissions); | 113 GetManifestPermissionMessages(permissions); |
| 97 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end()); | 114 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end()); |
| 98 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end()); | 115 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end()); |
| 99 messages.insert(messages.end(), manifest_permission_msgs.begin(), | 116 messages.insert(messages.end(), manifest_permission_msgs.begin(), |
| 100 manifest_permission_msgs.end()); | 117 manifest_permission_msgs.end()); |
| 101 | 118 |
| 102 // Some warnings are more generic and/or powerful and superseed other | 119 for (std::multimap<PermissionMessage::ID, |
| 103 // warnings. In that case, suppress the superseeded warning. | 120 PermissionMessage::ID>::const_iterator it = |
| 104 SuppressMessage(messages, | 121 SuppressList.begin(); |
| 105 PermissionMessage::kBookmarks, | 122 it != SuppressList.end(); |
| 106 PermissionMessage::kOverrideBookmarksUI); | 123 it++) { |
| 107 // Both tabs and history already allow reading favicons. | 124 SuppressMessage(messages, it->first, it->second); |
|
not at google - send to devlin
2014/07/18 20:17:26
but maybe you should retain these comments on that
mhm
2014/07/18 21:29:12
Done.
| |
| 108 SuppressMessage(messages, | 125 } |
| 109 PermissionMessage::kTabs, | |
| 110 PermissionMessage::kFavicon); | |
| 111 SuppressMessage(messages, | |
| 112 PermissionMessage::kBrowsingHistory, | |
| 113 PermissionMessage::kFavicon); | |
| 114 // Warning for history permission already covers warning for tabs permission. | |
| 115 SuppressMessage(messages, | |
| 116 PermissionMessage::kBrowsingHistory, | |
| 117 PermissionMessage::kTabs); | |
| 118 // Warning for full access permission already covers warning for tabs | |
| 119 // permission. | |
| 120 SuppressMessage(messages, | |
| 121 PermissionMessage::kHostsAll, | |
| 122 PermissionMessage::kTabs); | |
| 123 // Warning for full access already covers warning for DeclarativeWebRequest | |
| 124 // permission. | |
| 125 SuppressMessage(messages, | |
| 126 PermissionMessage::kHostsAll, | |
| 127 PermissionMessage::kDeclarativeWebRequest); | |
| 128 | 126 |
| 129 return messages; | 127 return messages; |
| 130 } | 128 } |
| 131 | 129 |
| 132 std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages( | 130 std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages( |
| 133 const PermissionSet* permissions, | 131 const PermissionSet* permissions, |
| 134 Manifest::Type extension_type) const { | 132 Manifest::Type extension_type) const { |
| 135 std::vector<base::string16> message_strings; | 133 std::vector<base::string16> message_strings; |
| 136 PermissionMessages messages = | 134 PermissionMessages messages = |
| 137 GetPermissionMessages(permissions, extension_type); | 135 GetPermissionMessages(permissions, extension_type); |
| 138 | 136 |
| 139 SuppressMessage(messages, | |
|
not at google - send to devlin
2014/07/18 20:17:25
this change isn't obvious, and it doesn't seem rel
mhm
2014/07/18 21:29:12
This was added in another CL when showing the mess
not at google - send to devlin
2014/07/18 21:36:33
I mean that the other changes you've made are in G
| |
| 140 PermissionMessage::kBluetooth, | |
| 141 PermissionMessage::kBluetoothDevices); | |
| 142 | |
| 143 for (PermissionMessages::const_iterator i = messages.begin(); | 137 for (PermissionMessages::const_iterator i = messages.begin(); |
| 144 i != messages.end(); ++i) { | 138 i != messages.end(); ++i) { |
| 145 int id = i->id(); | 139 int id = i->id(); |
| 146 // Access to users' devices should provide a single warning message | 140 // Access to users' devices should provide a single warning message |
| 147 // specifying the transport method used; USB, serial and/or Bluetooth. | 141 // specifying the transport method used; USB, serial and/or Bluetooth. |
| 148 if (id == PermissionMessage::kBluetooth || | 142 if (id == PermissionMessage::kBluetooth || |
| 149 id == PermissionMessage::kSerial || | 143 id == PermissionMessage::kSerial || |
| 150 id == PermissionMessage::kUsb) { | 144 id == PermissionMessage::kUsb) { |
| 151 if (ContainsMessages(messages, | 145 if (ContainsMessages(messages, |
| 152 PermissionMessage::kBluetooth, | 146 PermissionMessage::kBluetooth, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 PermissionMsgSet messages; | 303 PermissionMsgSet messages; |
| 310 for (APIPermissionSet::const_iterator permission_it = | 304 for (APIPermissionSet::const_iterator permission_it = |
| 311 permissions->apis().begin(); | 305 permissions->apis().begin(); |
| 312 permission_it != permissions->apis().end(); ++permission_it) { | 306 permission_it != permissions->apis().end(); ++permission_it) { |
| 313 if (permission_it->HasMessages()) { | 307 if (permission_it->HasMessages()) { |
| 314 PermissionMessages new_messages = permission_it->GetMessages(); | 308 PermissionMessages new_messages = permission_it->GetMessages(); |
| 315 messages.insert(new_messages.begin(), new_messages.end()); | 309 messages.insert(new_messages.begin(), new_messages.end()); |
| 316 } | 310 } |
| 317 } | 311 } |
| 318 | 312 |
| 319 // A special hack: If kFileSystemWriteDirectory would be displayed, hide | |
| 320 // kFileSystemDirectory as the write directory message implies it. | |
| 321 // TODO(sammc): Remove this. See http://crbug.com/284849. | |
| 322 SuppressMessage(messages, | |
| 323 PermissionMessage::kFileSystemWriteDirectory, | |
| 324 PermissionMessage::kFileSystemDirectory); | |
| 325 // A special hack: The warning message for declarativeWebRequest | 313 // A special hack: The warning message for declarativeWebRequest |
| 326 // permissions speaks about blocking parts of pages, which is a | 314 // permissions speaks about blocking parts of pages, which is a |
| 327 // subset of what the "<all_urls>" access allows. Therefore we | 315 // subset of what the "<all_urls>" access allows. Therefore we |
| 328 // display only the "<all_urls>" warning message if both permissions | 316 // display only the "<all_urls>" warning message if both permissions |
| 329 // are required. | 317 // are required. |
| 330 if (permissions->ShouldWarnAllHosts()) { | 318 if (permissions->ShouldWarnAllHosts()) { |
| 331 messages.erase( | 319 messages.erase( |
| 332 PermissionMessage( | 320 PermissionMessage( |
| 333 PermissionMessage::kDeclarativeWebRequest, base::string16())); | 321 PermissionMessage::kDeclarativeWebRequest, base::string16())); |
| 334 } | 322 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 std::set<std::string> old_hosts_set( | 439 std::set<std::string> old_hosts_set( |
| 452 permission_message_util::GetDistinctHosts(old_list, false, false)); | 440 permission_message_util::GetDistinctHosts(old_list, false, false)); |
| 453 std::set<std::string> new_hosts_only = | 441 std::set<std::string> new_hosts_only = |
| 454 base::STLSetDifference<std::set<std::string> >(new_hosts_set, | 442 base::STLSetDifference<std::set<std::string> >(new_hosts_set, |
| 455 old_hosts_set); | 443 old_hosts_set); |
| 456 | 444 |
| 457 return !new_hosts_only.empty(); | 445 return !new_hosts_only.empty(); |
| 458 } | 446 } |
| 459 | 447 |
| 460 } // namespace extensions | 448 } // namespace extensions |
| OLD | NEW |