Chromium Code Reviews| 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/website_settings/website_settings_bubble_contro ller.h" | 5 #import "chrome/browser/ui/cocoa/website_settings/website_settings_bubble_contro ller.h" |
| 6 | 6 |
| 7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 const CGFloat kSecurityParagraphSpacing = 12; | 78 const CGFloat kSecurityParagraphSpacing = 12; |
| 79 | 79 |
| 80 // Site Settings Section ------------------------------------------------------- | 80 // Site Settings Section ------------------------------------------------------- |
| 81 | 81 |
| 82 // Square size of the permission images. | 82 // Square size of the permission images. |
| 83 const CGFloat kPermissionImageSize = 16; | 83 const CGFloat kPermissionImageSize = 16; |
| 84 | 84 |
| 85 // Spacing between a permission image and the text. | 85 // Spacing between a permission image and the text. |
| 86 const CGFloat kPermissionImageSpacing = 6; | 86 const CGFloat kPermissionImageSpacing = 6; |
| 87 | 87 |
| 88 // Minimum distance between the label and its corresponding menu. | |
| 89 const CGFloat kMinSeparationBetweenLabelAndMenu = 16; | |
| 90 | |
| 88 // Square size of the permission delete button image. | 91 // Square size of the permission delete button image. |
| 89 const CGFloat kPermissionDeleteImageSize = 16; | 92 const CGFloat kPermissionDeleteImageSize = 16; |
| 90 | 93 |
| 91 // The spacing between individual permissions. | 94 // The spacing between individual permissions. |
| 92 const CGFloat kPermissionsVerticalSpacing = 16; | 95 const CGFloat kPermissionsVerticalSpacing = 16; |
| 93 | 96 |
| 94 // Amount to lower each permission icon to align the icon baseline with the | 97 // Amount to lower each permission icon to align the icon baseline with the |
| 95 // label text. | 98 // label text. |
| 96 const CGFloat kPermissionIconYAdjustment = 1; | 99 const CGFloat kPermissionIconYAdjustment = 1; |
| 97 | 100 |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 atPoint:point]; | 860 atPoint:point]; |
| 858 [label sizeToFit]; | 861 [label sizeToFit]; |
| 859 | 862 |
| 860 position = NSMakePoint(NSMaxX([label frame]), | 863 position = NSMakePoint(NSMaxX([label frame]), |
| 861 point.y + kPermissionPopupButtonYAdjustment); | 864 point.y + kPermissionPopupButtonYAdjustment); |
| 862 | 865 |
| 863 button = [self addPopUpButtonForPermission:permissionInfo | 866 button = [self addPopUpButtonForPermission:permissionInfo |
| 864 toView:view | 867 toView:view |
| 865 atPoint:position]; | 868 atPoint:position]; |
| 866 } | 869 } |
| 870 [label setToolTip:base::SysUTF16ToNSString(labelText)]; | |
| 867 | 871 |
| 868 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; | 872 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; |
| 869 | 873 |
| 870 // Adjust the vertical position of the button so that its title text is | 874 // Adjust the vertical position of the button so that its title text is |
| 871 // aligned with the label. Assumes that the text is the same size in both. | 875 // aligned with the label. Assumes that the text is the same size in both. |
| 872 // Also adjust the horizontal position to remove excess space due to the | 876 // Also adjust the horizontal position to remove excess space due to the |
| 873 // invisible bezel. | 877 // invisible bezel. |
| 874 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; | 878 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; |
| 875 if (isRTL) { | 879 if (isRTL) { |
| 876 position.x = kSectionHorizontalPadding; | 880 position.x = kSectionHorizontalPadding; |
| 877 } else { | 881 } else { |
| 878 position.x = kDefaultWindowWidth - kSectionHorizontalPadding - | 882 position.x = kDefaultWindowWidth - kSectionHorizontalPadding - |
| 879 [button frame].size.width; | 883 [button frame].size.width; |
| 880 } | 884 } |
| 881 position.y -= titleRect.origin.y; | 885 position.y -= titleRect.origin.y; |
| 882 [button setFrameOrigin:position]; | 886 [button setFrameOrigin:position]; |
| 883 | 887 |
| 888 // Truncate the label if it's too wide. | |
| 889 // This is a workaround for https://crbug.com/654268 until MacViews ships. | |
| 890 NSRect labelFrame = [label frame]; | |
| 891 if (isRTL) { | |
| 892 CGFloat maxLabelWidth = NSMaxX(labelFrame) - NSMaxX([button frame]) - | |
| 893 kMinSeparationBetweenLabelAndMenu; | |
| 894 if (NSWidth(labelFrame) > maxLabelWidth) { | |
| 895 labelFrame.origin.x = NSMaxX(labelFrame) - maxLabelWidth; | |
| 896 labelFrame.size.width = maxLabelWidth; | |
| 897 [label setFrame:labelFrame]; | |
|
Robert Sesek
2016/11/03 00:04:31
These two lines are duplicated within the two bran
lgarron
2016/11/03 00:05:21
They are conditional within both branches. Do you
lgarron
2016/11/03 00:15:00
Note that putting this inside the conditional insi
| |
| 898 [[label cell] setLineBreakMode:NSLineBreakByTruncatingTail]; | |
| 899 } | |
| 900 } else { | |
| 901 CGFloat maxLabelWidth = NSMinX([button frame]) - NSMinX(labelFrame) - | |
| 902 kMinSeparationBetweenLabelAndMenu; | |
| 903 if (NSWidth(labelFrame) > maxLabelWidth) { | |
| 904 labelFrame.size.width = maxLabelWidth; | |
| 905 [label setFrame:labelFrame]; | |
| 906 [[label cell] setLineBreakMode:NSLineBreakByTruncatingTail]; | |
| 907 } | |
| 908 } | |
| 909 | |
| 884 // Align the icon with the text. | 910 // Align the icon with the text. |
| 885 [self alignPermissionIcon:imageView withTextField:label]; | 911 [self alignPermissionIcon:imageView withTextField:label]; |
| 886 | 912 |
| 887 // Permissions specified by policy or an extension cannot be changed. | 913 // Permissions specified by policy or an extension cannot be changed. |
| 888 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || | 914 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || |
| 889 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { | 915 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { |
| 890 [button setEnabled:NO]; | 916 [button setEnabled:NO]; |
| 891 } | 917 } |
| 892 | 918 |
| 893 NSRect buttonFrame = [button frame]; | 919 NSRect buttonFrame = [button frame]; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1199 void WebsiteSettingsUIBridge::SetPermissionInfo( | 1225 void WebsiteSettingsUIBridge::SetPermissionInfo( |
| 1200 const PermissionInfoList& permission_info_list, | 1226 const PermissionInfoList& permission_info_list, |
| 1201 ChosenObjectInfoList chosen_object_info_list) { | 1227 ChosenObjectInfoList chosen_object_info_list) { |
| 1202 [bubble_controller_ setPermissionInfo:permission_info_list | 1228 [bubble_controller_ setPermissionInfo:permission_info_list |
| 1203 andChosenObjects:std::move(chosen_object_info_list)]; | 1229 andChosenObjects:std::move(chosen_object_info_list)]; |
| 1204 } | 1230 } |
| 1205 | 1231 |
| 1206 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { | 1232 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { |
| 1207 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) | 1233 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) |
| 1208 } | 1234 } |
| OLD | NEW |