OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/permission_set.h" | 5 #include "chrome/common/extensions/permissions/permission_set.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 } | 257 } |
258 | 258 |
259 return false; | 259 return false; |
260 } | 260 } |
261 | 261 |
262 std::set<std::string> | 262 std::set<std::string> |
263 PermissionSet::GetDistinctHostsForDisplay() const { | 263 PermissionSet::GetDistinctHostsForDisplay() const { |
264 return GetDistinctHosts(effective_hosts_, true, true); | 264 return GetDistinctHosts(effective_hosts_, true, true); |
265 } | 265 } |
266 | 266 |
267 PermissionMessages | 267 PermissionMessages PermissionSet::GetPermissionMessages( |
268 PermissionSet::GetPermissionMessages() const { | 268 const Extension* extension) const { |
269 PermissionMessages messages; | 269 PermissionMessages messages; |
270 | 270 |
271 if (HasEffectiveFullAccess()) { | 271 if (HasEffectiveFullAccess()) { |
272 messages.push_back(PermissionMessage( | 272 messages.push_back(PermissionMessage( |
273 PermissionMessage::kFullAccess, | 273 PermissionMessage::kFullAccess, |
274 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); | 274 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); |
275 return messages; | 275 return messages; |
276 } | 276 } |
277 | 277 |
278 if (HasEffectiveAccessToAllHosts()) { | 278 if (!extension->is_platform_app()) { |
Aaron Boodman
2012/08/01 23:13:05
Consider passing in only the type enum since that
Mihai Parparita -not on Chrome
2012/08/02 00:33:44
Done. Since this means #include-ing extension.h in
| |
279 messages.push_back(PermissionMessage( | 279 if (HasEffectiveAccessToAllHosts()) { |
280 PermissionMessage::kHostsAll, | 280 messages.push_back(PermissionMessage( |
281 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS))); | 281 PermissionMessage::kHostsAll, |
282 } else { | 282 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS))); |
283 std::set<std::string> hosts = GetDistinctHostsForDisplay(); | 283 } else { |
284 if (!hosts.empty()) | 284 std::set<std::string> hosts = GetDistinctHostsForDisplay(); |
285 messages.push_back(PermissionMessage::CreateFromHostList(hosts)); | 285 if (!hosts.empty()) |
286 messages.push_back(PermissionMessage::CreateFromHostList(hosts)); | |
287 } | |
286 } | 288 } |
287 | 289 |
288 std::set<PermissionMessage> simple_msgs = | 290 std::set<PermissionMessage> simple_msgs = |
289 GetSimplePermissionMessages(); | 291 GetSimplePermissionMessages(); |
290 messages.insert(messages.end(), simple_msgs.begin(), simple_msgs.end()); | 292 messages.insert(messages.end(), simple_msgs.begin(), simple_msgs.end()); |
291 | 293 |
292 return messages; | 294 return messages; |
293 } | 295 } |
294 | 296 |
295 std::vector<string16> PermissionSet::GetWarningMessages() const { | 297 std::vector<string16> PermissionSet::GetWarningMessages( |
298 const Extension* extension) const { | |
296 std::vector<string16> messages; | 299 std::vector<string16> messages; |
297 PermissionMessages permissions = GetPermissionMessages(); | 300 PermissionMessages permissions = GetPermissionMessages(extension); |
298 | 301 |
299 bool audio_capture = false; | 302 bool audio_capture = false; |
300 bool video_capture = false; | 303 bool video_capture = false; |
301 for (PermissionMessages::const_iterator i = permissions.begin(); | 304 for (PermissionMessages::const_iterator i = permissions.begin(); |
302 i != permissions.end(); ++i) { | 305 i != permissions.end(); ++i) { |
303 if (i->id() == PermissionMessage::kAudioCapture) | 306 if (i->id() == PermissionMessage::kAudioCapture) |
304 audio_capture = true; | 307 audio_capture = true; |
305 if (i->id() == PermissionMessage::kVideoCapture) | 308 if (i->id() == PermissionMessage::kVideoCapture) |
306 video_capture = true; | 309 video_capture = true; |
307 } | 310 } |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 std::set<std::string> new_hosts_only; | 589 std::set<std::string> new_hosts_only; |
587 | 590 |
588 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), | 591 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), |
589 old_hosts_set.begin(), old_hosts_set.end(), | 592 old_hosts_set.begin(), old_hosts_set.end(), |
590 std::inserter(new_hosts_only, new_hosts_only.begin())); | 593 std::inserter(new_hosts_only, new_hosts_only.begin())); |
591 | 594 |
592 return !new_hosts_only.empty(); | 595 return !new_hosts_only.empty(); |
593 } | 596 } |
594 | 597 |
595 } // namespace extensions | 598 } // namespace extensions |
OLD | NEW |