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

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: Minor changes 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..22a83100abb3a3b1654bb4a82a8aef69a3fcc00a 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm
@@ -592,27 +592,35 @@ 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;
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]];
+ NSMutableArray* withheld_children = [NSMutableArray array];
+
+ ExtensionInstallPrompt::PermissionsType type =
+ ExtensionInstallPrompt::PermissionsType::REGULAR_PERMISSIONS;
+ 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).empty()) {
+ if (!prompt.GetPermissionsDetails(i, type).empty()) {
if (prompt.GetIsShowingDetails(
ExtensionInstallPrompt::PERMISSIONS_DETAILS, i)) {
- [children addObject:
- [self buildItemWithTitle:SysUTF16ToNSString(
- prompt.GetPermissionsDetails(i))
- cellAttributes:kNoExpandMarker
- children:nil]];
+ [children
+ addObject:[self buildItemWithTitle:
+ SysUTF16ToNSString(
+ prompt.GetPermissionsDetails(i, type))
+ cellAttributes:kNoExpandMarker
+ children:nil]];
}
// Add a row for the link.
@@ -621,8 +629,42 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) {
}
}
- heading = SysUTF16ToNSString(prompt.GetPermissionsHeading());
- } else {
+ heading = SysUTF16ToNSString(prompt.GetPermissionsHeading(type));
+ }
+
+ type = ExtensionInstallPrompt::PermissionsType::WITHHELD_PERMISSIONS;
+ size_t withheld_permissions_count = prompt.GetPermissionCount(type);
+ if (withheld_permissions_count > 0) {
+ for (size_t i = 0; i < withheld_permissions_count; ++i) {
+ [withheld_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::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.
+ [withheld_children
+ addObject:[self buildItemWithTitle:
+ SysUTF16ToNSString(
+ prompt.GetPermissionsDetails(i, type))
+ cellAttributes:kNoExpandMarker
+ children:nil]];
+ }
+
+ // Add a row for the link.
+ [withheld_children addObject:[self buildDetailToggleItem:type
+ permissionsDetailIndex:i]];
+ }
+ }
+
+ withheld_heading = SysUTF16ToNSString(prompt.GetPermissionsHeading(type));
+ }
+
+ if (permissions_count + withheld_permissions_count == 0) {
[children addObject:
[self buildItemWithTitle:
l10n_util::GetNSString(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)
@@ -635,6 +677,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) {

Powered by Google App Engine
This is Rietveld 408576698