Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/common/extensions/permissions/permission_set.cc

Issue 18854021: Making the extension permissions dialog scrollable, when needed (adding expandable sections for thi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Polishing Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 for (URLPatternSet::const_iterator i = effective_hosts_.begin(); 248 for (URLPatternSet::const_iterator i = effective_hosts_.begin();
249 i != effective_hosts_.end(); ++i) { 249 i != effective_hosts_.end(); ++i) {
250 if (i->scheme() != chrome::kChromeUIScheme) { 250 if (i->scheme() != chrome::kChromeUIScheme) {
251 hosts_displayed_as_url.AddPattern(*i); 251 hosts_displayed_as_url.AddPattern(*i);
252 } 252 }
253 } 253 }
254 return GetDistinctHosts(hosts_displayed_as_url, true, true); 254 return GetDistinctHosts(hosts_displayed_as_url, true, true);
255 } 255 }
256 256
257 PermissionMessages PermissionSet::GetPermissionMessages( 257 PermissionMessages PermissionSet::GetPermissionMessages(
258 Manifest::Type extension_type) const { 258 Manifest::Type extension_type, bool details_only) const {
259 PermissionMessages messages; 259 PermissionMessages messages;
260 260
261 if (HasEffectiveFullAccess()) { 261 if (HasEffectiveFullAccess()) {
262 messages.push_back(PermissionMessage( 262 messages.push_back(PermissionMessage(
263 PermissionMessage::kFullAccess, 263 PermissionMessage::kFullAccess,
264 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); 264 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS)));
265 return messages; 265 return messages;
266 } 266 }
267 267
268 std::set<PermissionMessage> host_msgs = 268 std::set<PermissionMessage> host_msgs =
269 GetHostPermissionMessages(extension_type); 269 GetHostPermissionMessages(extension_type, details_only);
270 std::set<PermissionMessage> api_msgs = GetAPIPermissionMessages(); 270 std::set<PermissionMessage> api_msgs = GetAPIPermissionMessages();
271 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end()); 271 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end());
272 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end()); 272 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end());
273 273
274 return messages; 274 return messages;
275 } 275 }
276 276
277 std::vector<string16> PermissionSet::GetWarningMessages( 277 std::vector<string16> PermissionSet::GetWarningMessages(
278 Manifest::Type extension_type) const { 278 Manifest::Type extension_type, bool details_only) const {
279 std::vector<string16> messages; 279 std::vector<string16> messages;
280 PermissionMessages permissions = GetPermissionMessages(extension_type); 280 PermissionMessages permissions =
281 GetPermissionMessages(extension_type, details_only);
281 282
282 bool audio_capture = false; 283 bool audio_capture = false;
283 bool video_capture = false; 284 bool video_capture = false;
284 for (PermissionMessages::const_iterator i = permissions.begin(); 285 for (PermissionMessages::const_iterator i = permissions.begin();
285 i != permissions.end(); ++i) { 286 i != permissions.end(); ++i) {
286 if (i->id() == PermissionMessage::kAudioCapture) 287 if (i->id() == PermissionMessage::kAudioCapture)
287 audio_capture = true; 288 audio_capture = true;
288 if (i->id() == PermissionMessage::kVideoCapture) 289 if (i->id() == PermissionMessage::kVideoCapture)
289 video_capture = true; 290 video_capture = true;
290 } 291 }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 PermissionMessage::kUnknown); 532 PermissionMessage::kUnknown);
532 if (permission_it->HasMessages()) { 533 if (permission_it->HasMessages()) {
533 PermissionMessages new_messages = permission_it->GetMessages(); 534 PermissionMessages new_messages = permission_it->GetMessages();
534 messages.insert(new_messages.begin(), new_messages.end()); 535 messages.insert(new_messages.begin(), new_messages.end());
535 } 536 }
536 } 537 }
537 return messages; 538 return messages;
538 } 539 }
539 540
540 std::set<PermissionMessage> PermissionSet::GetHostPermissionMessages( 541 std::set<PermissionMessage> PermissionSet::GetHostPermissionMessages(
541 Manifest::Type extension_type) const { 542 Manifest::Type extension_type, bool details_only) const {
542 // Since platform apps always use isolated storage, they can't (silently) 543 // Since platform apps always use isolated storage, they can't (silently)
543 // access user data on other domains, so there's no need to prompt. 544 // access user data on other domains, so there's no need to prompt.
544 // Note: this must remain consistent with HasLessHostPrivilegesThan. 545 // Note: this must remain consistent with HasLessHostPrivilegesThan.
545 // See crbug.com/255229. 546 // See crbug.com/255229.
546 std::set<PermissionMessage> messages; 547 std::set<PermissionMessage> messages;
547 if (extension_type == Manifest::TYPE_PLATFORM_APP) 548 if (extension_type == Manifest::TYPE_PLATFORM_APP)
548 return messages; 549 return messages;
549 550
550 if (HasEffectiveAccessToAllHosts()) { 551 if (HasEffectiveAccessToAllHosts()) {
551 messages.insert(PermissionMessage( 552 messages.insert(PermissionMessage(
552 PermissionMessage::kHostsAll, 553 PermissionMessage::kHostsAll,
553 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS))); 554 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS)));
554 } else { 555 } else {
555 PermissionMessages additional_warnings = 556 PermissionMessages additional_warnings =
556 GetChromeSchemePermissionWarnings(effective_hosts_); 557 GetChromeSchemePermissionWarnings(effective_hosts_);
557 for (size_t i = 0; i < additional_warnings.size(); ++i) 558 for (size_t i = 0; i < additional_warnings.size(); ++i)
558 messages.insert(additional_warnings[i]); 559 messages.insert(additional_warnings[i]);
559 560
560 std::set<std::string> hosts = GetDistinctHostsForDisplay(); 561 std::set<std::string> hosts = GetDistinctHostsForDisplay();
561 if (!hosts.empty()) 562 if (!hosts.empty()) {
562 messages.insert(PermissionMessage::CreateFromHostList(hosts)); 563 messages.insert(
564 PermissionMessage::CreateFromHostList(hosts, details_only));
565 }
563 } 566 }
564 return messages; 567 return messages;
565 } 568 }
566 569
567 bool PermissionSet::HasLessAPIPrivilegesThan( 570 bool PermissionSet::HasLessAPIPrivilegesThan(
568 const PermissionSet* permissions) const { 571 const PermissionSet* permissions) const {
569 if (permissions == NULL) 572 if (permissions == NULL)
570 return false; 573 return false;
571 574
572 std::set<PermissionMessage> current_warnings = 575 std::set<PermissionMessage> current_warnings =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 std::set<std::string> new_hosts_only; 613 std::set<std::string> new_hosts_only;
611 614
612 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), 615 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(),
613 old_hosts_set.begin(), old_hosts_set.end(), 616 old_hosts_set.begin(), old_hosts_set.end(),
614 std::inserter(new_hosts_only, new_hosts_only.begin())); 617 std::inserter(new_hosts_only, new_hosts_only.begin()));
615 618
616 return !new_hosts_only.empty(); 619 return !new_hosts_only.empty();
617 } 620 }
618 621
619 } // namespace extensions 622 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698