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

Side by Side Diff: chrome/browser/ui/cocoa/page_info/page_info_bubble_controller.mm

Issue 2743423004: Permissions: Show the reason for permission decisions made on the user's behalf. (Closed)
Patch Set: Review comments. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/page_info/page_info_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/page_info/page_info_bubble_controller.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 // Minimum distance between the label and its corresponding menu. 88 // Minimum distance between the label and its corresponding menu.
89 const CGFloat kMinSeparationBetweenLabelAndMenu = 16; 89 const CGFloat kMinSeparationBetweenLabelAndMenu = 16;
90 90
91 // Square size of the permission delete button image. 91 // Square size of the permission delete button image.
92 const CGFloat kPermissionDeleteImageSize = 16; 92 const CGFloat kPermissionDeleteImageSize = 16;
93 93
94 // The spacing between individual permissions. 94 // The spacing between individual permissions.
95 const CGFloat kPermissionsVerticalSpacing = 16; 95 const CGFloat kPermissionsVerticalSpacing = 16;
96 96
97 // The spacing between permissions and their decision description labels.
98 const CGFloat kPermissionsDecisionVerticalSpacing = 4;
99
97 // Amount to lower each permission icon to align the icon baseline with the 100 // Amount to lower each permission icon to align the icon baseline with the
98 // label text. 101 // label text.
99 const CGFloat kPermissionIconYAdjustment = 1; 102 const CGFloat kPermissionIconYAdjustment = 1;
100 103
101 // Amount to lower each permission popup button to make its text align with the 104 // Amount to lower each permission popup button to make its text align with the
102 // permission label. 105 // permission label.
103 const CGFloat kPermissionPopupButtonYAdjustment = 3; 106 const CGFloat kPermissionPopupButtonYAdjustment = 3;
104 107
105 // Internal Page Bubble -------------------------------------------------------- 108 // Internal Page Bubble --------------------------------------------------------
106 109
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 896
894 // Align the icon with the text. 897 // Align the icon with the text.
895 [self alignPermissionIcon:imageView withTextField:label]; 898 [self alignPermissionIcon:imageView withTextField:label];
896 899
897 // Permissions specified by policy or an extension cannot be changed. 900 // Permissions specified by policy or an extension cannot be changed.
898 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || 901 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION ||
899 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { 902 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) {
900 [button setEnabled:NO]; 903 [button setEnabled:NO];
901 } 904 }
902 905
906 // Update |point| to match the y of the bottomost UI element added (|button|).
903 NSRect buttonFrame = [button frame]; 907 NSRect buttonFrame = [button frame];
904 return NSMakePoint(NSMaxX(buttonFrame), NSMaxY(buttonFrame)); 908 point.y = NSMaxY(buttonFrame);
909
910 // Show the reason for the permission decision in a new row if it did not come
911 // from the user.
912 base::string16 reason = PageInfoUI::PermissionDecisionReasonToUIString(
913 [self profile], permissionInfo, url_);
914 if (!reason.empty()) {
915 point.y += kPermissionsDecisionVerticalSpacing;
916 label = [self addText:reason
917 withSize:[NSFont systemFontSize]
918 bold:NO
919 toView:view
920 atPoint:point];
921 label.textColor = skia::SkColorToSRGBNSColor(
922 PageInfoUI::GetPermissionDecisionTextColor());
923 point.y += NSHeight(label.frame);
924 }
925
926 return NSMakePoint(NSMaxX(buttonFrame), point.y);
905 } 927 }
906 928
907 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the 929 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the
908 // last UI element added (either the permission button, in LTR, or the text 930 // last UI element added (either the permission button, in LTR, or the text
909 // label, in RTL). 931 // label, in RTL).
910 - (NSPoint)addChosenObject:(ChosenObjectInfoPtr)objectInfo 932 - (NSPoint)addChosenObject:(ChosenObjectInfoPtr)objectInfo
911 toView:(NSView*)view 933 toView:(NSView*)view
912 atPoint:(NSPoint)point { 934 atPoint:(NSPoint)point {
913 base::string16 labelText = l10n_util::GetStringFUTF16( 935 base::string16 labelText = l10n_util::GetStringFUTF16(
914 objectInfo->ui_info.label_string_id, 936 objectInfo->ui_info.label_string_id,
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) { 1217 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) {
1196 [bubble_controller_ setCookieInfo:cookie_info_list]; 1218 [bubble_controller_ setCookieInfo:cookie_info_list];
1197 } 1219 }
1198 1220
1199 void PageInfoUIBridge::SetPermissionInfo( 1221 void PageInfoUIBridge::SetPermissionInfo(
1200 const PermissionInfoList& permission_info_list, 1222 const PermissionInfoList& permission_info_list,
1201 ChosenObjectInfoList chosen_object_info_list) { 1223 ChosenObjectInfoList chosen_object_info_list) {
1202 [bubble_controller_ setPermissionInfo:permission_info_list 1224 [bubble_controller_ setPermissionInfo:permission_info_list
1203 andChosenObjects:std::move(chosen_object_info_list)]; 1225 andChosenObjects:std::move(chosen_object_info_list)];
1204 } 1226 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/ui/cocoa/page_info/page_info_bubble_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698