OLD | NEW |
---|---|
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/website_settings_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/page_info/website_settings_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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 | 88 |
89 // Minimum distance between the label and its corresponding menu. | 89 // Minimum distance between the label and its corresponding menu. |
90 const CGFloat kMinSeparationBetweenLabelAndMenu = 16; | 90 const CGFloat kMinSeparationBetweenLabelAndMenu = 16; |
91 | 91 |
92 // Square size of the permission delete button image. | 92 // Square size of the permission delete button image. |
93 const CGFloat kPermissionDeleteImageSize = 16; | 93 const CGFloat kPermissionDeleteImageSize = 16; |
94 | 94 |
95 // The spacing between individual permissions. | 95 // The spacing between individual permissions. |
96 const CGFloat kPermissionsVerticalSpacing = 16; | 96 const CGFloat kPermissionsVerticalSpacing = 16; |
97 | 97 |
98 // The spacing between permissions and their decision description labels. | |
99 const CGFloat kPermissionsDecisionVerticalSpacing = 4; | |
100 | |
98 // Amount to lower each permission icon to align the icon baseline with the | 101 // Amount to lower each permission icon to align the icon baseline with the |
99 // label text. | 102 // label text. |
100 const CGFloat kPermissionIconYAdjustment = 1; | 103 const CGFloat kPermissionIconYAdjustment = 1; |
101 | 104 |
102 // Amount to lower each permission popup button to make its text align with the | 105 // Amount to lower each permission popup button to make its text align with the |
103 // permission label. | 106 // permission label. |
104 const CGFloat kPermissionPopupButtonYAdjustment = 3; | 107 const CGFloat kPermissionPopupButtonYAdjustment = 3; |
105 | 108 |
106 // Internal Page Bubble -------------------------------------------------------- | 109 // Internal Page Bubble -------------------------------------------------------- |
107 | 110 |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
904 | 907 |
905 // Align the icon with the text. | 908 // Align the icon with the text. |
906 [self alignPermissionIcon:imageView withTextField:label]; | 909 [self alignPermissionIcon:imageView withTextField:label]; |
907 | 910 |
908 // Permissions specified by policy or an extension cannot be changed. | 911 // Permissions specified by policy or an extension cannot be changed. |
909 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || | 912 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || |
910 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { | 913 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { |
911 [button setEnabled:NO]; | 914 [button setEnabled:NO]; |
912 } | 915 } |
913 | 916 |
917 // Show the permission decision reason, if it was not the user. | |
dominickn
2017/03/26 23:46:24
"Show the reason for the permission decision in a
Patti Lor
2017/03/27 05:52:40
Done.
| |
914 NSRect buttonFrame = [button frame]; | 918 NSRect buttonFrame = [button frame]; |
915 return NSMakePoint(NSMaxX(buttonFrame), NSMaxY(buttonFrame)); | 919 int maxY = NSMaxY(buttonFrame); |
920 base::string16 reason = WebsiteSettingsUI::PermissionDecisionReasonToString( | |
921 [self profile], permissionInfo, url_); | |
922 if (!reason.empty()) { | |
923 point.y = position.y + kPermissionsDecisionVerticalSpacing + | |
924 label.frame.size.height; | |
925 label = [self addText:reason | |
926 withSize:[NSFont systemFontSize] | |
927 bold:NO | |
928 toView:view | |
929 atPoint:point]; | |
930 label.textColor = skia::SkColorToSRGBNSColor(SK_ColorGRAY); | |
931 maxY += label.frame.size.height; | |
932 } | |
933 | |
934 return NSMakePoint(NSMaxX(buttonFrame), maxY); | |
916 } | 935 } |
917 | 936 |
918 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the | 937 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the |
919 // last UI element added (either the permission button, in LTR, or the text | 938 // last UI element added (either the permission button, in LTR, or the text |
920 // label, in RTL). | 939 // label, in RTL). |
921 - (NSPoint)addChosenObject:(ChosenObjectInfoPtr)objectInfo | 940 - (NSPoint)addChosenObject:(ChosenObjectInfoPtr)objectInfo |
922 toView:(NSView*)view | 941 toView:(NSView*)view |
923 atPoint:(NSPoint)point { | 942 atPoint:(NSPoint)point { |
924 base::string16 labelText = l10n_util::GetStringFUTF16( | 943 base::string16 labelText = l10n_util::GetStringFUTF16( |
925 objectInfo->ui_info.label_string_id, | 944 objectInfo->ui_info.label_string_id, |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1212 const CookieInfoList& cookie_info_list) { | 1231 const CookieInfoList& cookie_info_list) { |
1213 [bubble_controller_ setCookieInfo:cookie_info_list]; | 1232 [bubble_controller_ setCookieInfo:cookie_info_list]; |
1214 } | 1233 } |
1215 | 1234 |
1216 void WebsiteSettingsUIBridge::SetPermissionInfo( | 1235 void WebsiteSettingsUIBridge::SetPermissionInfo( |
1217 const PermissionInfoList& permission_info_list, | 1236 const PermissionInfoList& permission_info_list, |
1218 ChosenObjectInfoList chosen_object_info_list) { | 1237 ChosenObjectInfoList chosen_object_info_list) { |
1219 [bubble_controller_ setPermissionInfo:permission_info_list | 1238 [bubble_controller_ setPermissionInfo:permission_info_list |
1220 andChosenObjects:std::move(chosen_object_info_list)]; | 1239 andChosenObjects:std::move(chosen_object_info_list)]; |
1221 } | 1240 } |
OLD | NEW |