Chromium Code Reviews| 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..348c50203bf5c4a5e9b637311182e9e9945d103e 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,13 @@ typedef NSUInteger CellAttributes; |
| - (NSDictionary*)buildDetailToggleItem:(size_t)type |
| permissionsDetailIndex:(size_t)index; |
| - (NSArray*)buildWarnings:(const ExtensionInstallPrompt::Prompt&)prompt; |
| +// Adds permissions of |type| from |prompt| to |children| and returns the |
| +// the appropriate permissions header. If no permissions are found, NULL is |
| +// returned. |
| +- (NSString*) |
| +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.
|
| + withType:(ExtensionInstallPrompt::PermissionsType)type |
| + children:(NSMutableArray*)children; |
| - (void)updateViewFrame:(NSRect)frame; |
| @end |
| @@ -592,37 +599,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]; |
| + |
| + heading = |
| + [self appendPermissionsToPrompt:prompt |
| + withType:ExtensionInstallPrompt:: |
| + PermissionsType::REGULAR_PERMISSIONS |
| + children:children]; |
| + withheldHeading = |
| + [self appendPermissionsToPrompt:prompt |
| + withType:ExtensionInstallPrompt::PermissionsType |
| + ::WITHHELD_PERMISSIONS |
| + children:withheldChildren]; |
| + |
| + if (!hasPermissions) { |
| [children addObject: |
| [self buildItemWithTitle: |
| l10n_util::GetNSString(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS) |
| @@ -631,10 +631,18 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) { |
| heading = @""; |
| } |
| - [warnings addObject:[self |
| - buildItemWithTitle:heading |
| - cellAttributes:kBoldText | kAutoExpandCell | kNoExpandMarker |
| - children:children]]; |
| + if (heading) { |
| + [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 +660,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 +674,42 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) { |
| return warnings; |
| } |
| +- (NSString*) |
| +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.
|
| + withType:(ExtensionInstallPrompt::PermissionsType)type |
| + children:(NSMutableArray*)children { |
| + size_t permissionsCount = prompt.GetPermissionCount(type); |
| + if (permissionsCount == 0) |
| + return NULL; |
| + |
| + for (size_t i = 0; i < permissionsCount; ++i) { |
| + NSDictionary* item = [self |
| + buildItemWithTitle:SysUTF16ToNSString(prompt.GetPermission(i, type)) |
| + cellAttributes:kUseBullet |
| + children:nil]; |
| + [children addObject:item]; |
| + |
| + // If there are additional details, add them below this item. |
| + if (!prompt.GetPermissionsDetails(i, type).empty()) { |
| + if (prompt.GetIsShowingDetails( |
| + ExtensionInstallPrompt::PERMISSIONS_DETAILS, i)) { |
| + item = |
| + [self buildItemWithTitle:SysUTF16ToNSString( |
| + prompt.GetPermissionsDetails(i, type)) |
| + cellAttributes:kNoExpandMarker |
| + children:nil]; |
| + [children addObject:item]; |
| + } |
| + |
| + // Add a row for the link. |
| + [children addObject: |
| + [self buildDetailToggleItem:type permissionsDetailIndex:i]]; |
| + } |
| + } |
| + |
| + return SysUTF16ToNSString(prompt.GetPermissionsHeading(type)); |
| +} |
| + |
| - (void)updateViewFrame:(NSRect)frame { |
| NSWindow* window = [[self view] window]; |
| [window setFrame:[window frameRectForContentRect:frame] display:YES]; |