| 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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 atPoint:point]; | 858 atPoint:point]; |
| 856 [label sizeToFit]; | 859 [label sizeToFit]; |
| 857 | 860 |
| 858 position = NSMakePoint(NSMaxX([label frame]), | 861 position = NSMakePoint(NSMaxX([label frame]), |
| 859 point.y + kPermissionPopupButtonYAdjustment); | 862 point.y + kPermissionPopupButtonYAdjustment); |
| 860 | 863 |
| 861 button = [self addPopUpButtonForPermission:permissionInfo | 864 button = [self addPopUpButtonForPermission:permissionInfo |
| 862 toView:view | 865 toView:view |
| 863 atPoint:position]; | 866 atPoint:position]; |
| 864 } | 867 } |
| 868 [label setToolTip:base::SysUTF16ToNSString(labelText)]; |
| 865 | 869 |
| 866 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; | 870 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; |
| 867 | 871 |
| 868 // Adjust the vertical position of the button so that its title text is | 872 // Adjust the vertical position of the button so that its title text is |
| 869 // aligned with the label. Assumes that the text is the same size in both. | 873 // aligned with the label. Assumes that the text is the same size in both. |
| 870 // Also adjust the horizontal position to remove excess space due to the | 874 // Also adjust the horizontal position to remove excess space due to the |
| 871 // invisible bezel. | 875 // invisible bezel. |
| 872 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; | 876 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; |
| 873 if (isRTL) { | 877 if (isRTL) { |
| 874 position.x = kSectionHorizontalPadding; | 878 position.x = kSectionHorizontalPadding; |
| 875 } else { | 879 } else { |
| 876 position.x = kDefaultWindowWidth - kSectionHorizontalPadding - | 880 position.x = kDefaultWindowWidth - kSectionHorizontalPadding - |
| 877 [button frame].size.width; | 881 [button frame].size.width; |
| 878 } | 882 } |
| 879 position.y -= titleRect.origin.y; | 883 position.y -= titleRect.origin.y; |
| 880 [button setFrameOrigin:position]; | 884 [button setFrameOrigin:position]; |
| 881 | 885 |
| 886 // Truncate the label if it's too wide. |
| 887 // This is a workaround for https://crbug.com/654268 until MacViews ships. |
| 888 NSRect labelFrame = [label frame]; |
| 889 if (isRTL) { |
| 890 CGFloat maxLabelWidth = NSMaxX(labelFrame) - NSMaxX([button frame]) - |
| 891 kMinSeparationBetweenLabelAndMenu; |
| 892 if (NSWidth(labelFrame) > maxLabelWidth) { |
| 893 labelFrame.origin.x = NSMaxX(labelFrame) - maxLabelWidth; |
| 894 labelFrame.size.width = maxLabelWidth; |
| 895 [label setFrame:labelFrame]; |
| 896 [[label cell] setLineBreakMode:NSLineBreakByTruncatingTail]; |
| 897 } |
| 898 } else { |
| 899 CGFloat maxLabelWidth = NSMinX([button frame]) - NSMinX(labelFrame) - |
| 900 kMinSeparationBetweenLabelAndMenu; |
| 901 if (NSWidth(labelFrame) > maxLabelWidth) { |
| 902 labelFrame.size.width = maxLabelWidth; |
| 903 [label setFrame:labelFrame]; |
| 904 [[label cell] setLineBreakMode:NSLineBreakByTruncatingTail]; |
| 905 } |
| 906 } |
| 907 |
| 882 // Align the icon with the text. | 908 // Align the icon with the text. |
| 883 [self alignPermissionIcon:imageView withTextField:label]; | 909 [self alignPermissionIcon:imageView withTextField:label]; |
| 884 | 910 |
| 885 // Permissions specified by policy or an extension cannot be changed. | 911 // Permissions specified by policy or an extension cannot be changed. |
| 886 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || | 912 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || |
| 887 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { | 913 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { |
| 888 [button setEnabled:NO]; | 914 [button setEnabled:NO]; |
| 889 } | 915 } |
| 890 | 916 |
| 891 NSRect buttonFrame = [button frame]; | 917 NSRect buttonFrame = [button frame]; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 void WebsiteSettingsUIBridge::SetPermissionInfo( | 1223 void WebsiteSettingsUIBridge::SetPermissionInfo( |
| 1198 const PermissionInfoList& permission_info_list, | 1224 const PermissionInfoList& permission_info_list, |
| 1199 const ChosenObjectInfoList& chosen_object_info_list) { | 1225 const ChosenObjectInfoList& chosen_object_info_list) { |
| 1200 [bubble_controller_ setPermissionInfo:permission_info_list | 1226 [bubble_controller_ setPermissionInfo:permission_info_list |
| 1201 andChosenObjects:chosen_object_info_list]; | 1227 andChosenObjects:chosen_object_info_list]; |
| 1202 } | 1228 } |
| 1203 | 1229 |
| 1204 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { | 1230 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { |
| 1205 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) | 1231 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) |
| 1206 } | 1232 } |
| OLD | NEW |