| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 260 |
| 261 return false; | 261 return false; |
| 262 } | 262 } |
| 263 | 263 |
| 264 std::set<std::string> | 264 std::set<std::string> |
| 265 PermissionSet::GetDistinctHostsForDisplay() const { | 265 PermissionSet::GetDistinctHostsForDisplay() const { |
| 266 return GetDistinctHosts(effective_hosts_, true, true); | 266 return GetDistinctHosts(effective_hosts_, true, true); |
| 267 } | 267 } |
| 268 | 268 |
| 269 PermissionMessages PermissionSet::GetPermissionMessages( | 269 PermissionMessages PermissionSet::GetPermissionMessages( |
| 270 Extension::Type extension_type) const { | 270 Manifest::Type extension_type) const { |
| 271 PermissionMessages messages; | 271 PermissionMessages messages; |
| 272 | 272 |
| 273 if (HasEffectiveFullAccess()) { | 273 if (HasEffectiveFullAccess()) { |
| 274 messages.push_back(PermissionMessage( | 274 messages.push_back(PermissionMessage( |
| 275 PermissionMessage::kFullAccess, | 275 PermissionMessage::kFullAccess, |
| 276 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); | 276 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); |
| 277 return messages; | 277 return messages; |
| 278 } | 278 } |
| 279 | 279 |
| 280 // Since platform apps always use isolated storage, they can't (silently) | 280 // Since platform apps always use isolated storage, they can't (silently) |
| 281 // access user data on other domains, so there's no need to prompt. | 281 // access user data on other domains, so there's no need to prompt. |
| 282 if (extension_type != Extension::TYPE_PLATFORM_APP) { | 282 if (extension_type != Manifest::TYPE_PLATFORM_APP) { |
| 283 if (HasEffectiveAccessToAllHosts()) { | 283 if (HasEffectiveAccessToAllHosts()) { |
| 284 messages.push_back(PermissionMessage( | 284 messages.push_back(PermissionMessage( |
| 285 PermissionMessage::kHostsAll, | 285 PermissionMessage::kHostsAll, |
| 286 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS))); | 286 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS))); |
| 287 } else { | 287 } else { |
| 288 std::set<std::string> hosts = GetDistinctHostsForDisplay(); | 288 std::set<std::string> hosts = GetDistinctHostsForDisplay(); |
| 289 if (!hosts.empty()) | 289 if (!hosts.empty()) |
| 290 messages.push_back(PermissionMessage::CreateFromHostList(hosts)); | 290 messages.push_back(PermissionMessage::CreateFromHostList(hosts)); |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 | 293 |
| 294 std::set<PermissionMessage> simple_msgs = | 294 std::set<PermissionMessage> simple_msgs = |
| 295 GetSimplePermissionMessages(); | 295 GetSimplePermissionMessages(); |
| 296 messages.insert(messages.end(), simple_msgs.begin(), simple_msgs.end()); | 296 messages.insert(messages.end(), simple_msgs.begin(), simple_msgs.end()); |
| 297 | 297 |
| 298 return messages; | 298 return messages; |
| 299 } | 299 } |
| 300 | 300 |
| 301 std::vector<string16> PermissionSet::GetWarningMessages( | 301 std::vector<string16> PermissionSet::GetWarningMessages( |
| 302 Extension::Type extension_type) const { | 302 Manifest::Type extension_type) const { |
| 303 std::vector<string16> messages; | 303 std::vector<string16> messages; |
| 304 PermissionMessages permissions = GetPermissionMessages(extension_type); | 304 PermissionMessages permissions = GetPermissionMessages(extension_type); |
| 305 | 305 |
| 306 bool audio_capture = false; | 306 bool audio_capture = false; |
| 307 bool video_capture = false; | 307 bool video_capture = false; |
| 308 for (PermissionMessages::const_iterator i = permissions.begin(); | 308 for (PermissionMessages::const_iterator i = permissions.begin(); |
| 309 i != permissions.end(); ++i) { | 309 i != permissions.end(); ++i) { |
| 310 if (i->id() == PermissionMessage::kAudioCapture) | 310 if (i->id() == PermissionMessage::kAudioCapture) |
| 311 audio_capture = true; | 311 audio_capture = true; |
| 312 if (i->id() == PermissionMessage::kVideoCapture) | 312 if (i->id() == PermissionMessage::kVideoCapture) |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 std::set<std::string> new_hosts_only; | 606 std::set<std::string> new_hosts_only; |
| 607 | 607 |
| 608 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), | 608 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), |
| 609 old_hosts_set.begin(), old_hosts_set.end(), | 609 old_hosts_set.begin(), old_hosts_set.end(), |
| 610 std::inserter(new_hosts_only, new_hosts_only.begin())); | 610 std::inserter(new_hosts_only, new_hosts_only.begin())); |
| 611 | 611 |
| 612 return !new_hosts_only.empty(); | 612 return !new_hosts_only.empty(); |
| 613 } | 613 } |
| 614 | 614 |
| 615 } // namespace extensions | 615 } // namespace extensions |
| OLD | NEW |