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

Unified 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: Removed rogue comment 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 side-by-side diff with in-line comments
Download patch
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..1dec33ca492a98241a5d5eeeab09dbe4d42c413b 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)appendPermissions:(const ExtensionInstallPrompt::Prompt&)prompt
+ type:(ExtensionInstallPrompt::PermissionsType)type
+ heading:(NSString**)heading
+ children:(NSMutableArray*)children;
- (void)updateViewFrame:(NSRect)frame;
@end
@@ -592,37 +596,28 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) {
- (NSArray*)buildWarnings:(const ExtensionInstallPrompt::Prompt&)prompt {
NSMutableArray* warnings = [NSMutableArray array];
NSString* heading = nil;
+ NSString* withheld_heading = nil;
ExtensionInstallPrompt::DetailsType type =
ExtensionInstallPrompt::PERMISSIONS_DETAILS;
+ bool has_permissions = prompt.GetPermissionCount(
+ ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS);
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* withheld_children = [NSMutableArray array];
+
+ [self appendPermissions:prompt
+ type:ExtensionInstallPrompt::PermissionsType::
+ REGULAR_PERMISSIONS
+ heading:&heading
+ children:children];
+ [self appendPermissions:prompt
+ type:ExtensionInstallPrompt::PermissionsType::
+ WITHHELD_PERMISSIONS
+ heading:&withheld_heading
+ children:withheld_children];
+
+ if (!has_permissions) {
[children addObject:
[self buildItemWithTitle:
l10n_util::GetNSString(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)
@@ -635,6 +630,14 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) {
buildItemWithTitle:heading
cellAttributes:kBoldText | kAutoExpandCell | kNoExpandMarker
children:children]];
+
+ // Add withheld permissions to the prompt if they exist.
+ if (withheld_heading) {
+ [warnings addObject:[self buildItemWithTitle:withheld_heading
+ cellAttributes:kBoldText | kAutoExpandCell |
+ kNoExpandMarker
+ children:withheld_children]];
+ }
}
if (prompt.GetRetainedFileCount() > 0) {
@@ -666,6 +669,44 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) {
return warnings;
}
+- (bool)appendPermissions:(const ExtensionInstallPrompt::Prompt&)prompt
+ type:(ExtensionInstallPrompt::PermissionsType)type
+ heading:(NSString**)heading
+ children:(NSMutableArray*)children {
+ size_t permissions_count = prompt.GetPermissionCount(type);
+ if (permissions_count > 0) {
+ for (size_t i = 0; i < permissions_count; ++i) {
+ [children
+ addObject:[self buildItemWithTitle:SysUTF16ToNSString(
+ 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
+ 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));
+ return true;
+ }
+ return false;
+}
+
- (void)updateViewFrame:(NSRect)frame {
NSWindow* window = [[self view] window];
[window setFrame:[window frameRectForContentRect:frame] display:YES];

Powered by Google App Engine
This is Rietveld 408576698