Chromium Code Reviews| 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 #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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 kCellAttributesKey : [NSNumber numberWithInt:kUseCustomLinkCell | | 585 kCellAttributesKey : [NSNumber numberWithInt:kUseCustomLinkCell | |
| 586 kNoExpandMarker], | 586 kNoExpandMarker], |
| 587 kPermissionsDetailIndex : [NSNumber numberWithUnsignedInteger:index], | 587 kPermissionsDetailIndex : [NSNumber numberWithUnsignedInteger:index], |
| 588 kPermissionsDetailType : [NSNumber numberWithUnsignedInteger:type], | 588 kPermissionsDetailType : [NSNumber numberWithUnsignedInteger:type], |
| 589 }; | 589 }; |
| 590 } | 590 } |
| 591 | 591 |
| 592 - (NSArray*)buildWarnings:(const ExtensionInstallPrompt::Prompt&)prompt { | 592 - (NSArray*)buildWarnings:(const ExtensionInstallPrompt::Prompt&)prompt { |
| 593 NSMutableArray* warnings = [NSMutableArray array]; | 593 NSMutableArray* warnings = [NSMutableArray array]; |
| 594 NSString* heading = nil; | 594 NSString* heading = nil; |
| 595 NSString* withheld_heading = nil; | |
| 595 | 596 |
| 596 ExtensionInstallPrompt::DetailsType type = | 597 ExtensionInstallPrompt::DetailsType type = |
| 597 ExtensionInstallPrompt::PERMISSIONS_DETAILS; | 598 ExtensionInstallPrompt::PERMISSIONS_DETAILS; |
| 598 if (prompt.ShouldShowPermissions()) { | 599 if (prompt.ShouldShowPermissions()) { |
| 599 NSMutableArray* children = [NSMutableArray array]; | 600 NSMutableArray* children = [NSMutableArray array]; |
| 600 if (prompt.GetPermissionCount() > 0) { | 601 NSMutableArray* withheld_children = [NSMutableArray array]; |
| 601 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) { | 602 |
| 602 [children addObject: | 603 ExtensionInstallPrompt::PermissionsType type = |
| 603 [self buildItemWithTitle:SysUTF16ToNSString(prompt.GetPermission(i)) | 604 ExtensionInstallPrompt::PermissionsType::REGULAR_PERMISSIONS; |
| 604 cellAttributes:kUseBullet | 605 size_t permissions_count = prompt.GetPermissionCount(type); |
| 605 children:nil]]; | 606 if (permissions_count > 0) { |
| 607 for (size_t i = 0; i < permissions_count; ++i) { | |
| 608 [children addObject:[self buildItemWithTitle:SysUTF16ToNSString( | |
| 609 prompt.GetPermission( | |
| 610 i, type)) | |
| 611 cellAttributes:kUseBullet | |
| 612 children:nil]]; | |
| 606 | 613 |
| 607 // If there are additional details, add them below this item. | 614 // If there are additional details, add them below this item. |
| 608 if (!prompt.GetPermissionsDetails(i).empty()) { | 615 if (!prompt.GetPermissionsDetails(i, type).empty()) { |
| 609 if (prompt.GetIsShowingDetails( | 616 if (prompt.GetIsShowingDetails( |
| 610 ExtensionInstallPrompt::PERMISSIONS_DETAILS, i)) { | 617 ExtensionInstallPrompt::PERMISSIONS_DETAILS, i)) { |
| 611 [children addObject: | 618 [children |
| 612 [self buildItemWithTitle:SysUTF16ToNSString( | 619 addObject:[self buildItemWithTitle: |
| 613 prompt.GetPermissionsDetails(i)) | 620 SysUTF16ToNSString( |
| 614 cellAttributes:kNoExpandMarker | 621 prompt.GetPermissionsDetails(i, type)) |
| 615 children:nil]]; | 622 cellAttributes:kNoExpandMarker |
| 623 children:nil]]; | |
| 616 } | 624 } |
| 617 | 625 |
| 618 // Add a row for the link. | 626 // Add a row for the link. |
| 619 [children addObject: | 627 [children addObject: |
| 620 [self buildDetailToggleItem:type permissionsDetailIndex:i]]; | 628 [self buildDetailToggleItem:type permissionsDetailIndex:i]]; |
| 621 } | 629 } |
| 622 } | 630 } |
| 623 | 631 |
| 624 heading = SysUTF16ToNSString(prompt.GetPermissionsHeading()); | 632 heading = SysUTF16ToNSString(prompt.GetPermissionsHeading(type)); |
| 625 } else { | 633 } |
| 634 | |
| 635 type = ExtensionInstallPrompt::PermissionsType::WITHHELD_PERMISSIONS; | |
| 636 size_t withheld_permissions_count = prompt.GetPermissionCount(type); | |
| 637 if (withheld_permissions_count > 0) { | |
| 638 for (size_t i = 0; i < withheld_permissions_count; ++i) { | |
| 639 [withheld_children | |
| 640 addObject:[self | |
| 641 buildItemWithTitle:SysUTF16ToNSString( | |
| 642 prompt.GetPermission(i, type)) | |
| 643 cellAttributes:kUseBullet | |
| 644 children:nil]]; | |
| 645 | |
| 646 // If there are additional details, add them below this item. | |
| 647 if (!prompt.GetPermissionsDetails(i, type).empty()) { | |
| 648 if (prompt.GetIsShowingDetails( | |
| 649 ExtensionInstallPrompt::WITHHELD_PERMISSIONS_DETAILS, i)) { | |
|
Devlin
2014/09/04 22:06:09
It looks like a helper function might be in order
gpdavis
2014/09/05 20:23:02
Done.
| |
| 650 [withheld_children | |
| 651 addObject:[self buildItemWithTitle: | |
| 652 SysUTF16ToNSString( | |
| 653 prompt.GetPermissionsDetails(i, type)) | |
| 654 cellAttributes:kNoExpandMarker | |
| 655 children:nil]]; | |
| 656 } | |
| 657 | |
| 658 // Add a row for the link. | |
| 659 [withheld_children addObject:[self buildDetailToggleItem:type | |
| 660 permissionsDetailIndex:i]]; | |
| 661 } | |
| 662 } | |
| 663 | |
| 664 withheld_heading = SysUTF16ToNSString(prompt.GetPermissionsHeading(type)); | |
| 665 } | |
| 666 | |
| 667 if (permissions_count + withheld_permissions_count == 0) { | |
| 626 [children addObject: | 668 [children addObject: |
| 627 [self buildItemWithTitle: | 669 [self buildItemWithTitle: |
| 628 l10n_util::GetNSString(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS) | 670 l10n_util::GetNSString(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS) |
| 629 cellAttributes:kUseBullet | 671 cellAttributes:kUseBullet |
| 630 children:nil]]; | 672 children:nil]]; |
| 631 heading = @""; | 673 heading = @""; |
| 632 } | 674 } |
| 633 | 675 |
| 634 [warnings addObject:[self | 676 [warnings addObject:[self |
| 635 buildItemWithTitle:heading | 677 buildItemWithTitle:heading |
| 636 cellAttributes:kBoldText | kAutoExpandCell | kNoExpandMarker | 678 cellAttributes:kBoldText | kAutoExpandCell | kNoExpandMarker |
| 637 children:children]]; | 679 children:children]]; |
| 680 | |
| 681 // Add withheld permissions to the prompt if they exist. | |
| 682 if (withheld_heading) { | |
| 683 [warnings addObject:[self buildItemWithTitle:withheld_heading | |
| 684 cellAttributes:kBoldText | kAutoExpandCell | | |
| 685 kNoExpandMarker | |
| 686 children:withheld_children]]; | |
| 687 } | |
| 638 } | 688 } |
| 639 | 689 |
| 640 if (prompt.GetRetainedFileCount() > 0) { | 690 if (prompt.GetRetainedFileCount() > 0) { |
| 641 type = ExtensionInstallPrompt::RETAINED_FILES_DETAILS; | 691 type = ExtensionInstallPrompt::RETAINED_FILES_DETAILS; |
| 642 | 692 |
| 643 NSMutableArray* children = [NSMutableArray array]; | 693 NSMutableArray* children = [NSMutableArray array]; |
| 644 | 694 |
| 645 if (prompt.GetIsShowingDetails(type, 0)) { | 695 if (prompt.GetIsShowingDetails(type, 0)) { |
| 646 for (size_t i = 0; i < prompt.GetRetainedFileCount(); ++i) { | 696 for (size_t i = 0; i < prompt.GetRetainedFileCount(); ++i) { |
| 647 [children addObject: | 697 [children addObject: |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 734 } | 784 } |
| 735 | 785 |
| 736 - (void)accessibilityPerformAction:(NSString*)action { | 786 - (void)accessibilityPerformAction:(NSString*)action { |
| 737 if ([action isEqualToString:NSAccessibilityPressAction]) | 787 if ([action isEqualToString:NSAccessibilityPressAction]) |
| 738 [self handleLinkClicked]; | 788 [self handleLinkClicked]; |
| 739 else | 789 else |
| 740 [super accessibilityPerformAction:action]; | 790 [super accessibilityPerformAction:action]; |
| 741 } | 791 } |
| 742 | 792 |
| 743 @end | 793 @end |
| OLD | NEW |