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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm

Issue 501273002: Update extension install prompt to reflect withheld permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Header update Created 6 years, 3 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
OLDNEW
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 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 - (BOOL)isBundleInstall; 49 - (BOOL)isBundleInstall;
50 - (BOOL)hasWebstoreData; 50 - (BOOL)hasWebstoreData;
51 - (void)appendRatingStar:(const gfx::ImageSkia*)skiaImage; 51 - (void)appendRatingStar:(const gfx::ImageSkia*)skiaImage;
52 - (void)onOutlineViewRowCountDidChange; 52 - (void)onOutlineViewRowCountDidChange;
53 - (NSDictionary*)buildItemWithTitle:(NSString*)title 53 - (NSDictionary*)buildItemWithTitle:(NSString*)title
54 cellAttributes:(CellAttributes)cellAttributes 54 cellAttributes:(CellAttributes)cellAttributes
55 children:(NSArray*)children; 55 children:(NSArray*)children;
56 - (NSDictionary*)buildDetailToggleItem:(size_t)type 56 - (NSDictionary*)buildDetailToggleItem:(size_t)type
57 permissionsDetailIndex:(size_t)index; 57 permissionsDetailIndex:(size_t)index;
58 - (NSArray*)buildWarnings:(const ExtensionInstallPrompt::Prompt&)prompt; 58 - (NSArray*)buildWarnings:(const ExtensionInstallPrompt::Prompt&)prompt;
59 // Adds permissions of |type| from |prompt| to |children| and returns the
60 // the appropriate permissions header. If no permissions are found, NULL is
61 // returned.
62 - (NSString*)
63 appendPermissionsToPrompt:(const ExtensionInstallPrompt::Prompt&) prompt
Alexei Svitkine (slow) 2014/09/18 20:27:54 Sorry after, reading your description above, I act
gpdavis 2014/09/18 20:33:18 Done.
64 withType:(ExtensionInstallPrompt::PermissionsType)type
65 children:(NSMutableArray*)children;
59 - (void)updateViewFrame:(NSRect)frame; 66 - (void)updateViewFrame:(NSRect)frame;
60 @end 67 @end
61 68
62 @interface DetailToggleHyperlinkButtonCell : HyperlinkButtonCell { 69 @interface DetailToggleHyperlinkButtonCell : HyperlinkButtonCell {
63 NSUInteger permissionsDetailIndex_; 70 NSUInteger permissionsDetailIndex_;
64 ExtensionInstallPrompt::DetailsType permissionsDetailType_; 71 ExtensionInstallPrompt::DetailsType permissionsDetailType_;
65 SEL linkClickedAction_; 72 SEL linkClickedAction_;
66 } 73 }
67 74
68 @property(assign, nonatomic) NSUInteger permissionsDetailIndex; 75 @property(assign, nonatomic) NSUInteger permissionsDetailIndex;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 kCellAttributesKey : [NSNumber numberWithInt:kUseCustomLinkCell | 592 kCellAttributesKey : [NSNumber numberWithInt:kUseCustomLinkCell |
586 kNoExpandMarker], 593 kNoExpandMarker],
587 kPermissionsDetailIndex : [NSNumber numberWithUnsignedInteger:index], 594 kPermissionsDetailIndex : [NSNumber numberWithUnsignedInteger:index],
588 kPermissionsDetailType : [NSNumber numberWithUnsignedInteger:type], 595 kPermissionsDetailType : [NSNumber numberWithUnsignedInteger:type],
589 }; 596 };
590 } 597 }
591 598
592 - (NSArray*)buildWarnings:(const ExtensionInstallPrompt::Prompt&)prompt { 599 - (NSArray*)buildWarnings:(const ExtensionInstallPrompt::Prompt&)prompt {
593 NSMutableArray* warnings = [NSMutableArray array]; 600 NSMutableArray* warnings = [NSMutableArray array];
594 NSString* heading = nil; 601 NSString* heading = nil;
602 NSString* withheldHeading = nil;
595 603
596 ExtensionInstallPrompt::DetailsType type = 604 ExtensionInstallPrompt::DetailsType type =
597 ExtensionInstallPrompt::PERMISSIONS_DETAILS; 605 ExtensionInstallPrompt::PERMISSIONS_DETAILS;
606 bool hasPermissions = prompt.GetPermissionCount(
607 ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS);
608 CellAttributes warningCellAttributes =
609 kBoldText | kAutoExpandCell | kNoExpandMarker;
598 if (prompt.ShouldShowPermissions()) { 610 if (prompt.ShouldShowPermissions()) {
599 NSMutableArray* children = [NSMutableArray array]; 611 NSMutableArray* children = [NSMutableArray array];
600 if (prompt.GetPermissionCount() > 0) { 612 NSMutableArray* withheldChildren = [NSMutableArray array];
601 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) {
602 [children addObject:
603 [self buildItemWithTitle:SysUTF16ToNSString(prompt.GetPermission(i))
604 cellAttributes:kUseBullet
605 children:nil]];
606 613
607 // If there are additional details, add them below this item. 614 heading =
608 if (!prompt.GetPermissionsDetails(i).empty()) { 615 [self appendPermissionsToPrompt:prompt
609 if (prompt.GetIsShowingDetails( 616 withType:ExtensionInstallPrompt::
610 ExtensionInstallPrompt::PERMISSIONS_DETAILS, i)) { 617 PermissionsType::REGULAR_PERMISSIONS
611 [children addObject: 618 children:children];
612 [self buildItemWithTitle:SysUTF16ToNSString( 619 withheldHeading =
613 prompt.GetPermissionsDetails(i)) 620 [self appendPermissionsToPrompt:prompt
614 cellAttributes:kNoExpandMarker 621 withType:ExtensionInstallPrompt::PermissionsType
615 children:nil]]; 622 ::WITHHELD_PERMISSIONS
616 } 623 children:withheldChildren];
617 624
618 // Add a row for the link. 625 if (!hasPermissions) {
619 [children addObject:
620 [self buildDetailToggleItem:type permissionsDetailIndex:i]];
621 }
622 }
623
624 heading = SysUTF16ToNSString(prompt.GetPermissionsHeading());
625 } else {
626 [children addObject: 626 [children addObject:
627 [self buildItemWithTitle: 627 [self buildItemWithTitle:
628 l10n_util::GetNSString(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS) 628 l10n_util::GetNSString(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)
629 cellAttributes:kUseBullet 629 cellAttributes:kUseBullet
630 children:nil]]; 630 children:nil]];
631 heading = @""; 631 heading = @"";
632 } 632 }
633 633
634 [warnings addObject:[self 634 if (heading) {
635 buildItemWithTitle:heading 635 [warnings addObject:[self buildItemWithTitle:heading
636 cellAttributes:kBoldText | kAutoExpandCell | kNoExpandMarker 636 cellAttributes:warningCellAttributes
637 children:children]]; 637 children:children]];
638 }
639
640 // Add withheld permissions to the prompt if they exist.
641 if (withheldHeading) {
642 [warnings addObject:[self buildItemWithTitle:withheldHeading
643 cellAttributes:warningCellAttributes
644 children:withheldChildren]];
645 }
638 } 646 }
639 647
640 if (prompt.GetRetainedFileCount() > 0) { 648 if (prompt.GetRetainedFileCount() > 0) {
641 type = ExtensionInstallPrompt::RETAINED_FILES_DETAILS; 649 type = ExtensionInstallPrompt::RETAINED_FILES_DETAILS;
642 650
643 NSMutableArray* children = [NSMutableArray array]; 651 NSMutableArray* children = [NSMutableArray array];
644 652
645 if (prompt.GetIsShowingDetails(type, 0)) { 653 if (prompt.GetIsShowingDetails(type, 0)) {
646 for (size_t i = 0; i < prompt.GetRetainedFileCount(); ++i) { 654 for (size_t i = 0; i < prompt.GetRetainedFileCount(); ++i) {
647 [children addObject: 655 [children addObject:
648 [self buildItemWithTitle:SysUTF16ToNSString( 656 [self buildItemWithTitle:SysUTF16ToNSString(
649 prompt.GetRetainedFile(i)) 657 prompt.GetRetainedFile(i))
650 cellAttributes:kUseBullet 658 cellAttributes:kUseBullet
651 children:nil]]; 659 children:nil]];
652 } 660 }
653 } 661 }
654 662
655 [warnings addObject: 663 [warnings
656 [self buildItemWithTitle:SysUTF16ToNSString( 664 addObject:[self buildItemWithTitle:SysUTF16ToNSString(
657 prompt.GetRetainedFilesHeading()) 665 prompt.GetRetainedFilesHeading())
658 cellAttributes:kBoldText | kAutoExpandCell | kNoExpandMarker 666 cellAttributes:warningCellAttributes
659 children:children]]; 667 children:children]];
660 668
661 // Add a row for the link. 669 // Add a row for the link.
662 [warnings addObject: 670 [warnings addObject:
663 [self buildDetailToggleItem:type permissionsDetailIndex:0]]; 671 [self buildDetailToggleItem:type permissionsDetailIndex:0]];
664 } 672 }
665 673
666 return warnings; 674 return warnings;
667 } 675 }
668 676
677 - (NSString*)
678 appendPermissionsToPrompt:(const ExtensionInstallPrompt::Prompt&) prompt
Alexei Svitkine (slow) 2014/09/18 20:27:54 Nit: No space before prompt, same above.
gpdavis 2014/09/18 20:33:18 Done.
679 withType:(ExtensionInstallPrompt::PermissionsType)type
680 children:(NSMutableArray*)children {
681 size_t permissionsCount = prompt.GetPermissionCount(type);
682 if (permissionsCount == 0)
683 return NULL;
684
685 for (size_t i = 0; i < permissionsCount; ++i) {
686 NSDictionary* item = [self
687 buildItemWithTitle:SysUTF16ToNSString(prompt.GetPermission(i, type))
688 cellAttributes:kUseBullet
689 children:nil];
690 [children addObject:item];
691
692 // If there are additional details, add them below this item.
693 if (!prompt.GetPermissionsDetails(i, type).empty()) {
694 if (prompt.GetIsShowingDetails(
695 ExtensionInstallPrompt::PERMISSIONS_DETAILS, i)) {
696 item =
697 [self buildItemWithTitle:SysUTF16ToNSString(
698 prompt.GetPermissionsDetails(i, type))
699 cellAttributes:kNoExpandMarker
700 children:nil];
701 [children addObject:item];
702 }
703
704 // Add a row for the link.
705 [children addObject:
706 [self buildDetailToggleItem:type permissionsDetailIndex:i]];
707 }
708 }
709
710 return SysUTF16ToNSString(prompt.GetPermissionsHeading(type));
711 }
712
669 - (void)updateViewFrame:(NSRect)frame { 713 - (void)updateViewFrame:(NSRect)frame {
670 NSWindow* window = [[self view] window]; 714 NSWindow* window = [[self view] window];
671 [window setFrame:[window frameRectForContentRect:frame] display:YES]; 715 [window setFrame:[window frameRectForContentRect:frame] display:YES];
672 [[self view] setFrame:frame]; 716 [[self view] setFrame:frame];
673 } 717 }
674 718
675 @end 719 @end
676 720
677 721
678 @implementation DetailToggleHyperlinkButtonCell 722 @implementation DetailToggleHyperlinkButtonCell
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 } 778 }
735 779
736 - (void)accessibilityPerformAction:(NSString*)action { 780 - (void)accessibilityPerformAction:(NSString*)action {
737 if ([action isEqualToString:NSAccessibilityPressAction]) 781 if ([action isEqualToString:NSAccessibilityPressAction])
738 [self handleLinkClicked]; 782 [self handleLinkClicked];
739 else 783 else
740 [super accessibilityPerformAction:action]; 784 [super accessibilityPerformAction:action];
741 } 785 }
742 786
743 @end 787 @end
OLDNEW
« no previous file with comments | « chrome/browser/extensions/permissions_updater.cc ('k') | chrome/browser/ui/views/extensions/extension_install_dialog_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698