| 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 "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 10 #include "extensions/common/extensions_client.h" | 10 #include "extensions/common/extensions_client.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 ChromePermissionMessageProvider::ChromePermissionMessageProvider() { | 75 ChromePermissionMessageProvider::ChromePermissionMessageProvider() { |
| 76 } | 76 } |
| 77 | 77 |
| 78 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() { | 78 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() { |
| 79 } | 79 } |
| 80 | 80 |
| 81 PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages( | 81 PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages( |
| 82 const PermissionSet* permissions, | 82 const PermissionSet* permissions, |
| 83 Manifest::Type extension_type) const { | 83 Manifest::Type extension_type) const { |
| 84 PermissionMessages messages; |
| 85 if (permissions->HasEffectiveFullAccess()) { |
| 86 messages.push_back(PermissionMessage( |
| 87 PermissionMessage::kFullAccess, |
| 88 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); |
| 89 return messages; |
| 90 } |
| 91 |
| 84 // Some warnings are more generic and/or powerful and superseed other | 92 // Some warnings are more generic and/or powerful and superseed other |
| 85 // warnings. In that case, the first message suppresses the second one. | 93 // warnings. In that case, the first message suppresses the second one. |
| 86 std::multimap<PermissionMessage::ID, PermissionMessage::ID> kSuppressList; | 94 std::multimap<PermissionMessage::ID, PermissionMessage::ID> kSuppressList; |
| 87 kSuppressList.insert( | 95 kSuppressList.insert( |
| 88 {PermissionMessage::kBluetooth, PermissionMessage::kBluetoothDevices}); | 96 {PermissionMessage::kBluetooth, PermissionMessage::kBluetoothDevices}); |
| 89 kSuppressList.insert( | 97 kSuppressList.insert( |
| 90 {PermissionMessage::kBookmarks, PermissionMessage::kOverrideBookmarksUI}); | 98 {PermissionMessage::kBookmarks, PermissionMessage::kOverrideBookmarksUI}); |
| 91 // History already allows reading favicons. | 99 // History already allows reading favicons. |
| 92 kSuppressList.insert( | 100 kSuppressList.insert( |
| 93 {PermissionMessage::kBrowsingHistory, PermissionMessage::kFavicon}); | 101 {PermissionMessage::kBrowsingHistory, PermissionMessage::kFavicon}); |
| 94 // History already allows tabs access. | 102 // History already allows tabs access. |
| 95 kSuppressList.insert( | 103 kSuppressList.insert( |
| 96 {PermissionMessage::kBrowsingHistory, PermissionMessage::kTabs}); | 104 {PermissionMessage::kBrowsingHistory, PermissionMessage::kTabs}); |
| 105 // History already allows access the list of most frequently visited sites. |
| 106 kSuppressList.insert( |
| 107 {PermissionMessage::kBrowsingHistory, PermissionMessage::kTopSites}); |
| 97 // A special hack: If kFileSystemWriteDirectory would be displayed, hide | 108 // A special hack: If kFileSystemWriteDirectory would be displayed, hide |
| 98 // kFileSystemDirectory as the write directory message implies it. | 109 // kFileSystemDirectory as the write directory message implies it. |
| 99 // TODO(sammc): Remove this. See http://crbug.com/284849. | 110 // TODO(sammc): Remove this. See http://crbug.com/284849. |
| 100 kSuppressList.insert({PermissionMessage::kFileSystemWriteDirectory, | 111 kSuppressList.insert({PermissionMessage::kFileSystemWriteDirectory, |
| 101 PermissionMessage::kFileSystemDirectory}); | 112 PermissionMessage::kFileSystemDirectory}); |
| 102 // Full access already allows DeclarativeWebRequest. | 113 // Full access already allows DeclarativeWebRequest. |
| 103 kSuppressList.insert({PermissionMessage::kHostsAll, | 114 kSuppressList.insert({PermissionMessage::kHostsAll, |
| 104 PermissionMessage::kDeclarativeWebRequest}); | 115 PermissionMessage::kDeclarativeWebRequest}); |
| 116 // Full access implies reading the list of most frequently visited sites. |
| 117 kSuppressList.insert( |
| 118 {PermissionMessage::kHostsAll, PermissionMessage::kTopSites}); |
| 105 // Full access already covers tabs access. | 119 // Full access already covers tabs access. |
| 106 kSuppressList.insert( | 120 kSuppressList.insert( |
| 107 {PermissionMessage::kHostsAll, PermissionMessage::kTabs}); | 121 {PermissionMessage::kHostsAll, PermissionMessage::kTabs}); |
| 108 // Tabs already allows reading favicons. | 122 // Tabs already allows reading favicons. |
| 109 kSuppressList.insert({PermissionMessage::kTabs, PermissionMessage::kFavicon}); | 123 kSuppressList.insert({PermissionMessage::kTabs, PermissionMessage::kFavicon}); |
| 110 | 124 // Tabs already allows reading the list of most frequently visited sites. |
| 111 PermissionMessages messages; | 125 kSuppressList.insert( |
| 112 | 126 {PermissionMessage::kTabs, PermissionMessage::kTopSites}); |
| 113 if (permissions->HasEffectiveFullAccess()) { | |
| 114 messages.push_back(PermissionMessage( | |
| 115 PermissionMessage::kFullAccess, | |
| 116 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); | |
| 117 return messages; | |
| 118 } | |
| 119 | 127 |
| 120 PermissionMsgSet host_msgs = | 128 PermissionMsgSet host_msgs = |
| 121 GetHostPermissionMessages(permissions, extension_type); | 129 GetHostPermissionMessages(permissions, extension_type); |
| 122 PermissionMsgSet api_msgs = GetAPIPermissionMessages(permissions); | 130 PermissionMsgSet api_msgs = GetAPIPermissionMessages(permissions); |
| 123 PermissionMsgSet manifest_permission_msgs = | 131 PermissionMsgSet manifest_permission_msgs = |
| 124 GetManifestPermissionMessages(permissions); | 132 GetManifestPermissionMessages(permissions); |
| 125 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end()); | 133 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end()); |
| 126 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end()); | 134 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end()); |
| 127 messages.insert(messages.end(), manifest_permission_msgs.begin(), | 135 messages.insert(messages.end(), manifest_permission_msgs.begin(), |
| 128 manifest_permission_msgs.end()); | 136 manifest_permission_msgs.end()); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 std::set<std::string> old_hosts_set( | 458 std::set<std::string> old_hosts_set( |
| 451 permission_message_util::GetDistinctHosts(old_list, false, false)); | 459 permission_message_util::GetDistinctHosts(old_list, false, false)); |
| 452 std::set<std::string> new_hosts_only = | 460 std::set<std::string> new_hosts_only = |
| 453 base::STLSetDifference<std::set<std::string> >(new_hosts_set, | 461 base::STLSetDifference<std::set<std::string> >(new_hosts_set, |
| 454 old_hosts_set); | 462 old_hosts_set); |
| 455 | 463 |
| 456 return !new_hosts_only.empty(); | 464 return !new_hosts_only.empty(); |
| 457 } | 465 } |
| 458 | 466 |
| 459 } // namespace extensions | 467 } // namespace extensions |
| OLD | NEW |