Index: chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm |
diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm |
index df708813c6d13897c38c52112c02c69dcc13e9be..9e14fd1c3a69ba12d35d024c741ab97b3620cb55 100644 |
--- a/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm |
+++ b/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm |
@@ -56,6 +56,10 @@ typedef NSUInteger CellAttributes; |
- (NSDictionary*)buildDetailToggleItem:(size_t)type |
permissionsDetailIndex:(size_t)index; |
- (NSArray*)buildWarnings:(const ExtensionInstallPrompt::Prompt&)prompt; |
+- (bool)appendPermissionsToPrompt:(const ExtensionInstallPrompt::Prompt&)prompt |
+ withType:(ExtensionInstallPrompt::PermissionsType)type |
+ heading:(NSString**)heading |
+ children:(NSMutableArray*)children; |
- (void)updateViewFrame:(NSRect)frame; |
@end |
@@ -592,37 +596,30 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) { |
- (NSArray*)buildWarnings:(const ExtensionInstallPrompt::Prompt&)prompt { |
NSMutableArray* warnings = [NSMutableArray array]; |
NSString* heading = nil; |
+ NSString* withheldHeading = nil; |
ExtensionInstallPrompt::DetailsType type = |
ExtensionInstallPrompt::PERMISSIONS_DETAILS; |
+ bool hasPermissions = prompt.GetPermissionCount( |
+ ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS); |
+ CellAttributes warningCellAttributes = |
+ kBoldText | kAutoExpandCell | kNoExpandMarker; |
if (prompt.ShouldShowPermissions()) { |
NSMutableArray* children = [NSMutableArray array]; |
- if (prompt.GetPermissionCount() > 0) { |
- for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) { |
- [children addObject: |
- [self buildItemWithTitle:SysUTF16ToNSString(prompt.GetPermission(i)) |
- cellAttributes:kUseBullet |
- children:nil]]; |
- |
- // If there are additional details, add them below this item. |
- if (!prompt.GetPermissionsDetails(i).empty()) { |
- if (prompt.GetIsShowingDetails( |
- ExtensionInstallPrompt::PERMISSIONS_DETAILS, i)) { |
- [children addObject: |
- [self buildItemWithTitle:SysUTF16ToNSString( |
- prompt.GetPermissionsDetails(i)) |
- cellAttributes:kNoExpandMarker |
- children:nil]]; |
- } |
- |
- // Add a row for the link. |
- [children addObject: |
- [self buildDetailToggleItem:type permissionsDetailIndex:i]]; |
- } |
- } |
- |
- heading = SysUTF16ToNSString(prompt.GetPermissionsHeading()); |
- } else { |
+ NSMutableArray* withheldChildren = [NSMutableArray array]; |
+ |
+ [self appendPermissionsToPrompt:prompt |
+ withType:ExtensionInstallPrompt::PermissionsType:: |
+ REGULAR_PERMISSIONS |
+ heading:&heading |
+ children:children]; |
+ [self appendPermissionsToPrompt:prompt |
+ withType:ExtensionInstallPrompt::PermissionsType:: |
+ WITHHELD_PERMISSIONS |
+ heading:&withheldHeading |
+ children:withheldChildren]; |
+ |
+ if (!hasPermissions) { |
[children addObject: |
[self buildItemWithTitle: |
l10n_util::GetNSString(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS) |
@@ -631,10 +628,16 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) { |
heading = @""; |
} |
- [warnings addObject:[self |
- buildItemWithTitle:heading |
- cellAttributes:kBoldText | kAutoExpandCell | kNoExpandMarker |
- children:children]]; |
+ [warnings addObject:[self buildItemWithTitle:heading |
+ cellAttributes:warningCellAttributes |
+ children:children]]; |
+ |
+ // Add withheld permissions to the prompt if they exist. |
+ if (withheldHeading) { |
+ [warnings addObject:[self buildItemWithTitle:withheldHeading |
+ cellAttributes:warningCellAttributes |
+ children:withheldChildren]]; |
+ } |
} |
if (prompt.GetRetainedFileCount() > 0) { |
@@ -652,11 +655,11 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) { |
} |
} |
- [warnings addObject: |
- [self buildItemWithTitle:SysUTF16ToNSString( |
- prompt.GetRetainedFilesHeading()) |
- cellAttributes:kBoldText | kAutoExpandCell | kNoExpandMarker |
- children:children]]; |
+ [warnings |
+ addObject:[self buildItemWithTitle:SysUTF16ToNSString( |
+ prompt.GetRetainedFilesHeading()) |
+ cellAttributes:warningCellAttributes |
+ children:children]]; |
// Add a row for the link. |
[warnings addObject: |
@@ -666,6 +669,44 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) { |
return warnings; |
} |
+- (bool)appendPermissionsToPrompt:(const ExtensionInstallPrompt::Prompt&)prompt |
+ withType:(ExtensionInstallPrompt::PermissionsType)type |
+ heading:(NSString**)heading |
+ children:(NSMutableArray*)children { |
+ size_t permissionsCount = prompt.GetPermissionCount(type); |
+ if (permissionsCount == 0) |
+ return false; |
+ |
+ for (size_t i = 0; i < permissionsCount; ++i) { |
+ [children |
+ addObject:[self buildItemWithTitle:SysUTF16ToNSString( |
Alexei Svitkine (slow)
2014/09/13 04:01:30
Nit: Extract the return value from -buildItem.. to
gpdavis
2014/09/15 20:04:07
Done.
|
+ prompt.GetPermission(i, type)) |
+ cellAttributes:kUseBullet |
+ children:nil]]; |
+ |
+ // If there are additional details, add them below this item. |
+ if (!prompt.GetPermissionsDetails(i, type).empty()) { |
+ if (prompt.GetIsShowingDetails( |
+ ExtensionInstallPrompt::PERMISSIONS_DETAILS, i)) { |
+ [children |
Alexei Svitkine (slow)
2014/09/13 04:01:30
Nit: Ditto.
gpdavis
2014/09/15 20:04:07
Done.
|
+ addObject:[self |
+ buildItemWithTitle:SysUTF16ToNSString( |
+ prompt.GetPermissionsDetails( |
+ i, type)) |
+ cellAttributes:kNoExpandMarker |
+ children:nil]]; |
+ } |
+ |
+ // Add a row for the link. |
+ [children addObject:[self buildDetailToggleItem:type |
+ permissionsDetailIndex:i]]; |
+ } |
+ } |
+ |
+ *heading = SysUTF16ToNSString(prompt.GetPermissionsHeading(type)); |
Alexei Svitkine (slow)
2014/09/13 04:01:30
Seems your calling code doesn't use the return boo
gpdavis
2014/09/15 20:04:07
Done.
|
+ return true; |
+} |
+ |
- (void)updateViewFrame:(NSRect)frame { |
NSWindow* window = [[self view] window]; |
[window setFrame:[window frameRectForContentRect:frame] display:YES]; |