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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 if (permissions->HasEffectiveAccessToAllHosts()) { | 182 if (permissions->HasEffectiveAccessToAllHosts()) { |
179 messages.erase( | 183 messages.erase( |
180 PermissionMessage( | 184 PermissionMessage( |
181 PermissionMessage::kDeclarativeWebRequest, string16())); | 185 PermissionMessage::kDeclarativeWebRequest, string16())); |
182 } | 186 } |
183 | 187 |
184 return messages; | 188 return messages; |
185 } | 189 } |
186 | 190 |
187 std::set<PermissionMessage> | 191 std::set<PermissionMessage> |
| 192 ChromePermissionMessageProvider::GetManifestPermissionMessages( |
| 193 const PermissionSet* permissions) const { |
| 194 std::set<PermissionMessage> messages; |
| 195 for (ManifestPermissionSet::const_iterator permission_it = |
| 196 permissions->manifest_permissions().begin(); |
| 197 permission_it != permissions->manifest_permissions().end(); |
| 198 ++permission_it) { |
| 199 if (permission_it->HasMessages()) { |
| 200 PermissionMessages new_messages = permission_it->GetMessages(); |
| 201 messages.insert(new_messages.begin(), new_messages.end()); |
| 202 } |
| 203 } |
| 204 return messages; |
| 205 } |
| 206 |
| 207 std::set<PermissionMessage> |
188 ChromePermissionMessageProvider::GetHostPermissionMessages( | 208 ChromePermissionMessageProvider::GetHostPermissionMessages( |
189 const PermissionSet* permissions, | 209 const PermissionSet* permissions, |
190 Manifest::Type extension_type) const { | 210 Manifest::Type extension_type) const { |
191 std::set<PermissionMessage> messages; | 211 std::set<PermissionMessage> messages; |
192 // Since platform apps always use isolated storage, they can't (silently) | 212 // Since platform apps always use isolated storage, they can't (silently) |
193 // access user data on other domains, so there's no need to prompt. | 213 // access user data on other domains, so there's no need to prompt. |
194 // Note: this must remain consistent with IsHostPrivilegeIncrease. | 214 // Note: this must remain consistent with IsHostPrivilegeIncrease. |
195 // See crbug.com/255229. | 215 // See crbug.com/255229. |
196 if (extension_type == Manifest::TYPE_PLATFORM_APP) | 216 if (extension_type == Manifest::TYPE_PLATFORM_APP) |
197 return messages; | 217 return messages; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 std::set<std::string> old_hosts_set( | 290 std::set<std::string> old_hosts_set( |
271 permission_message_util::GetDistinctHosts(old_list, false, false)); | 291 permission_message_util::GetDistinctHosts(old_list, false, false)); |
272 std::set<std::string> new_hosts_only = | 292 std::set<std::string> new_hosts_only = |
273 base::STLSetDifference<std::set<std::string> >(new_hosts_set, | 293 base::STLSetDifference<std::set<std::string> >(new_hosts_set, |
274 old_hosts_set); | 294 old_hosts_set); |
275 | 295 |
276 return !new_hosts_only.empty(); | 296 return !new_hosts_only.empty(); |
277 } | 297 } |
278 | 298 |
279 } // namespace extensions | 299 } // namespace extensions |
OLD | NEW |