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 "chrome/common/extensions/permissions/permission_message_util.h" | 8 #include "chrome/common/extensions/permissions/permission_message_util.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 19 matching lines...) Expand all Loading... |
30 if (permissions->HasEffectiveFullAccess()) { | 30 if (permissions->HasEffectiveFullAccess()) { |
31 messages.push_back(PermissionMessage( | 31 messages.push_back(PermissionMessage( |
32 PermissionMessage::kFullAccess, | 32 PermissionMessage::kFullAccess, |
33 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); | 33 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); |
34 return messages; | 34 return messages; |
35 } | 35 } |
36 | 36 |
37 std::set<PermissionMessage> host_msgs = | 37 std::set<PermissionMessage> host_msgs = |
38 GetHostPermissionMessages(permissions, extension_type); | 38 GetHostPermissionMessages(permissions, extension_type); |
39 std::set<PermissionMessage> api_msgs = GetAPIPermissionMessages(permissions); | 39 std::set<PermissionMessage> api_msgs = GetAPIPermissionMessages(permissions); |
| 40 std::set<PermissionMessage> manifest_permission_msgs = |
| 41 GetManifestPermissionMessages(permissions); |
40 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end()); | 42 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end()); |
41 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end()); | 43 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end()); |
| 44 messages.insert(messages.end(), manifest_permission_msgs.begin(), |
| 45 manifest_permission_msgs.end()); |
42 | 46 |
43 return messages; | 47 return messages; |
44 } | 48 } |
45 | 49 |
46 // static | 50 // static |
47 std::vector<string16> ChromePermissionMessageProvider::GetWarningMessages( | 51 std::vector<string16> ChromePermissionMessageProvider::GetWarningMessages( |
48 const PermissionSet* permissions, | 52 const PermissionSet* permissions, |
49 Manifest::Type extension_type) const { | 53 Manifest::Type extension_type) const { |
50 std::vector<string16> message_strings; | 54 std::vector<string16> message_strings; |
51 PermissionMessages messages = | 55 PermissionMessages messages = |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (permissions->HasEffectiveAccessToAllHosts()) { | 190 if (permissions->HasEffectiveAccessToAllHosts()) { |
187 messages.erase( | 191 messages.erase( |
188 PermissionMessage( | 192 PermissionMessage( |
189 PermissionMessage::kDeclarativeWebRequest, string16())); | 193 PermissionMessage::kDeclarativeWebRequest, string16())); |
190 } | 194 } |
191 | 195 |
192 return messages; | 196 return messages; |
193 } | 197 } |
194 | 198 |
195 std::set<PermissionMessage> | 199 std::set<PermissionMessage> |
| 200 ChromePermissionMessageProvider::GetManifestPermissionMessages( |
| 201 const PermissionSet* permissions) const { |
| 202 std::set<PermissionMessage> messages; |
| 203 for (ManifestPermissionSet::const_iterator permission_it = |
| 204 permissions->manifest_permissions().begin(); |
| 205 permission_it != permissions->manifest_permissions().end(); |
| 206 ++permission_it) { |
| 207 if (permission_it->HasMessages()) { |
| 208 PermissionMessages new_messages = permission_it->GetMessages(); |
| 209 messages.insert(new_messages.begin(), new_messages.end()); |
| 210 } |
| 211 } |
| 212 return messages; |
| 213 } |
| 214 |
| 215 std::set<PermissionMessage> |
196 ChromePermissionMessageProvider::GetHostPermissionMessages( | 216 ChromePermissionMessageProvider::GetHostPermissionMessages( |
197 const PermissionSet* permissions, | 217 const PermissionSet* permissions, |
198 Manifest::Type extension_type) const { | 218 Manifest::Type extension_type) const { |
199 std::set<PermissionMessage> messages; | 219 std::set<PermissionMessage> messages; |
200 // Since platform apps always use isolated storage, they can't (silently) | 220 // Since platform apps always use isolated storage, they can't (silently) |
201 // access user data on other domains, so there's no need to prompt. | 221 // access user data on other domains, so there's no need to prompt. |
202 // Note: this must remain consistent with IsHostPrivilegeIncrease. | 222 // Note: this must remain consistent with IsHostPrivilegeIncrease. |
203 // See crbug.com/255229. | 223 // See crbug.com/255229. |
204 if (extension_type == Manifest::TYPE_PLATFORM_APP) | 224 if (extension_type == Manifest::TYPE_PLATFORM_APP) |
205 return messages; | 225 return messages; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 std::set<std::string> old_hosts_set( | 298 std::set<std::string> old_hosts_set( |
279 permission_message_util::GetDistinctHosts(old_list, false, false)); | 299 permission_message_util::GetDistinctHosts(old_list, false, false)); |
280 std::set<std::string> new_hosts_only = | 300 std::set<std::string> new_hosts_only = |
281 base::STLSetDifference<std::set<std::string> >(new_hosts_set, | 301 base::STLSetDifference<std::set<std::string> >(new_hosts_set, |
282 old_hosts_set); | 302 old_hosts_set); |
283 | 303 |
284 return !new_hosts_only.empty(); | 304 return !new_hosts_only.empty(); |
285 } | 305 } |
286 | 306 |
287 } // namespace extensions | 307 } // namespace extensions |
OLD | NEW |