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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 messages.insert(messages.end(), manifest_permission_msgs.begin(), | 74 messages.insert(messages.end(), manifest_permission_msgs.begin(), |
| 75 manifest_permission_msgs.end()); | 75 manifest_permission_msgs.end()); |
| 76 | 76 |
| 77 // Some warnings are more generic and/or powerful and superseed other | 77 // Some warnings are more generic and/or powerful and superseed other |
| 78 // warnings. In that case, suppress the superseeded warning. | 78 // warnings. In that case, suppress the superseeded warning. |
| 79 SuppressMessage(messages, | 79 SuppressMessage(messages, |
| 80 PermissionMessage::kBookmarks, | 80 PermissionMessage::kBookmarks, |
| 81 PermissionMessage::kOverrideBookmarksUI); | 81 PermissionMessage::kOverrideBookmarksUI); |
| 82 // Both tabs and history already allow reading favicons. | 82 // Both tabs and history already allow reading favicons. |
| 83 SuppressMessage(messages, | 83 SuppressMessage(messages, |
| 84 PermissionMessage::kTabs, | 84 PermissionMessage::kBrowsingHistoryRead, |
| 85 PermissionMessage::kFavicon); | 85 PermissionMessage::kFavicon); |
| 86 SuppressMessage(messages, | 86 SuppressMessage(messages, |
| 87 PermissionMessage::kBrowsingHistory, | 87 PermissionMessage::kBrowsingHistoryWrite, |
| 88 PermissionMessage::kFavicon); | 88 PermissionMessage::kFavicon); |
| 89 // Warning for history permission already covers warning for tabs permission. | 89 // Warning for writing history already covers warning for reading history. |
| 90 SuppressMessage(messages, | 90 SuppressMessage(messages, |
| 91 PermissionMessage::kBrowsingHistory, | 91 PermissionMessage::kBrowsingHistoryWrite, |
| 92 PermissionMessage::kTabs); | 92 PermissionMessage::kBrowsingHistoryRead); |
| 93 // Warning for full access permission already covers warning for tabs | 93 // Warning for full access permission already covers warning for tabs |
| 94 // permission. | 94 // permission. |
| 95 SuppressMessage(messages, | 95 SuppressMessage(messages, |
| 96 PermissionMessage::kHostsAll, | 96 PermissionMessage::kHostsAll, |
| 97 PermissionMessage::kTabs); | 97 PermissionMessage::kBrowsingHistoryRead); |
|
wjywbs
2014/06/13 15:42:47
Granting all hosts permission will also allow "pro
| |
| 98 | 98 |
| 99 return messages; | 99 return messages; |
| 100 } | 100 } |
| 101 | 101 |
| 102 std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages( | 102 std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages( |
| 103 const PermissionSet* permissions, | 103 const PermissionSet* permissions, |
| 104 Manifest::Type extension_type) const { | 104 Manifest::Type extension_type) const { |
| 105 std::vector<base::string16> message_strings; | 105 std::vector<base::string16> message_strings; |
| 106 PermissionMessages messages = | 106 PermissionMessages messages = |
| 107 GetPermissionMessages(permissions, extension_type); | 107 GetPermissionMessages(permissions, extension_type); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_DELETE; | 155 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_READ_DELETE; |
| 156 message_strings.push_back(l10n_util::GetStringUTF16(m_id)); | 156 message_strings.push_back(l10n_util::GetStringUTF16(m_id)); |
| 157 continue; | 157 continue; |
| 158 } else if (id == PermissionMessage::kMediaGalleriesAllGalleriesCopyTo || | 158 } else if (id == PermissionMessage::kMediaGalleriesAllGalleriesCopyTo || |
| 159 id == PermissionMessage::kMediaGalleriesAllGalleriesDelete) { | 159 id == PermissionMessage::kMediaGalleriesAllGalleriesDelete) { |
| 160 // The combined message will be pushed above. | 160 // The combined message will be pushed above. |
| 161 continue; | 161 continue; |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 if (permissions->HasAPIPermission(APIPermission::kSessions) && | 164 if (permissions->HasAPIPermission(APIPermission::kSessions) && |
| 165 id == PermissionMessage::kTabs) { | 165 id == PermissionMessage::kBrowsingHistoryRead) { |
| 166 message_strings.push_back(l10n_util::GetStringUTF16( | 166 message_strings.push_back(l10n_util::GetStringUTF16( |
| 167 IDS_EXTENSION_PROMPT_WARNING_TABS_AND_SESSIONS)); | 167 IDS_EXTENSION_PROMPT_WARNING_HISTORY_READ_AND_SESSIONS)); |
| 168 continue; | 168 continue; |
| 169 } | 169 } |
| 170 if (permissions->HasAPIPermission(APIPermission::kSessions) && | 170 if (permissions->HasAPIPermission(APIPermission::kSessions) && |
| 171 id == PermissionMessage::kBrowsingHistory) { | 171 id == PermissionMessage::kBrowsingHistoryWrite) { |
| 172 message_strings.push_back(l10n_util::GetStringUTF16( | 172 message_strings.push_back(l10n_util::GetStringUTF16( |
| 173 IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY_AND_SESSIONS)); | 173 IDS_EXTENSION_PROMPT_WARNING_HISTORY_WRITE_AND_SESSIONS)); |
| 174 continue; | 174 continue; |
| 175 } | 175 } |
| 176 | 176 |
| 177 message_strings.push_back(i->message()); | 177 message_strings.push_back(i->message()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 return message_strings; | 180 return message_strings; |
| 181 } | 181 } |
| 182 | 182 |
| 183 std::vector<base::string16> | 183 std::vector<base::string16> |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 std::set<std::string> old_hosts_set( | 367 std::set<std::string> old_hosts_set( |
| 368 permission_message_util::GetDistinctHosts(old_list, false, false)); | 368 permission_message_util::GetDistinctHosts(old_list, false, false)); |
| 369 std::set<std::string> new_hosts_only = | 369 std::set<std::string> new_hosts_only = |
| 370 base::STLSetDifference<std::set<std::string> >(new_hosts_set, | 370 base::STLSetDifference<std::set<std::string> >(new_hosts_set, |
| 371 old_hosts_set); | 371 old_hosts_set); |
| 372 | 372 |
| 373 return !new_hosts_only.empty(); | 373 return !new_hosts_only.empty(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 } // namespace extensions | 376 } // namespace extensions |
| OLD | NEW |