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

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: Rebase with review comments. Created 3 years, 9 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 // Show the reason for the permission decision in a new row if it did not come
907 // from the user.
903 NSRect buttonFrame = [button frame]; 908 NSRect buttonFrame = [button frame];
904 return NSMakePoint(NSMaxX(buttonFrame), NSMaxY(buttonFrame)); 909 int maxY = NSMaxY(buttonFrame);
lgarron 2017/03/29 05:49:26 I know the existing code uses maxY, but mainly to
Patti Lor 2017/03/30 03:27:29 Done, thanks for the suggestions. I added a commen
910 base::string16 reason = PageInfoUI::PermissionDecisionReasonToUIString(
911 [self profile], permissionInfo, url_);
912 if (!reason.empty()) {
913 point.y = position.y + kPermissionsDecisionVerticalSpacing +
914 label.frame.size.height;
915 label = [self addText:reason
916 withSize:[NSFont systemFontSize]
lgarron 2017/03/29 05:49:26 Looking at the mocks, it seems to be this should b
Patti Lor 2017/03/30 03:27:29 I think there was a misunderstanding here - by moc
lgarron 2017/04/05 00:37:46 Ah. So, this is partially my fault. Per the specs
Patti Lor 2017/04/05 01:02:43 Thanks for clarifying & following up on the font s
917 bold:NO
918 toView:view
919 atPoint:point];
920 label.textColor = skia::SkColorToSRGBNSColor(SK_ColorGRAY);
lgarron 2017/03/29 05:49:26 Could you share the color across platforms by e.g.
Patti Lor 2017/03/30 03:27:29 Done.
921 maxY += label.frame.size.height;
922 }
923
924 return NSMakePoint(NSMaxX(buttonFrame), maxY);
905 } 925 }
906 926
907 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the 927 // 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 928 // last UI element added (either the permission button, in LTR, or the text
909 // label, in RTL). 929 // label, in RTL).
910 - (NSPoint)addChosenObject:(ChosenObjectInfoPtr)objectInfo 930 - (NSPoint)addChosenObject:(ChosenObjectInfoPtr)objectInfo
911 toView:(NSView*)view 931 toView:(NSView*)view
912 atPoint:(NSPoint)point { 932 atPoint:(NSPoint)point {
913 base::string16 labelText = l10n_util::GetStringFUTF16( 933 base::string16 labelText = l10n_util::GetStringFUTF16(
914 objectInfo->ui_info.label_string_id, 934 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) { 1215 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) {
1196 [bubble_controller_ setCookieInfo:cookie_info_list]; 1216 [bubble_controller_ setCookieInfo:cookie_info_list];
1197 } 1217 }
1198 1218
1199 void PageInfoUIBridge::SetPermissionInfo( 1219 void PageInfoUIBridge::SetPermissionInfo(
1200 const PermissionInfoList& permission_info_list, 1220 const PermissionInfoList& permission_info_list,
1201 ChosenObjectInfoList chosen_object_info_list) { 1221 ChosenObjectInfoList chosen_object_info_list) {
1202 [bubble_controller_ setPermissionInfo:permission_info_list 1222 [bubble_controller_ setPermissionInfo:permission_info_list
1203 andChosenObjects:std::move(chosen_object_info_list)]; 1223 andChosenObjects:std::move(chosen_object_info_list)];
1204 } 1224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698