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/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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 | 906 |
907 // Update |point| to match the y of the bottomost UI element added (|button|). | 907 // Update |point| to match the y of the bottomost UI element added (|button|). |
908 NSRect buttonFrame = [button frame]; | 908 NSRect buttonFrame = [button frame]; |
909 point.y = NSMaxY(labelFrame) + kPermissionLabelBottomPadding; | 909 point.y = NSMaxY(labelFrame) + kPermissionLabelBottomPadding; |
910 | 910 |
911 // Show the reason for the permission decision in a new row if it did not come | 911 // Show the reason for the permission decision in a new row if it did not come |
912 // from the user. | 912 // from the user. |
913 base::string16 reason = PageInfoUI::PermissionDecisionReasonToUIString( | 913 base::string16 reason = PageInfoUI::PermissionDecisionReasonToUIString( |
914 [self profile], permissionInfo, url_); | 914 [self profile], permissionInfo, url_); |
915 if (!reason.empty()) { | 915 if (!reason.empty()) { |
| 916 // Do this even in RTL to make sure -addText sets the right width for the |
| 917 // permission decision reason label. |
| 918 point.x = kSectionHorizontalPadding + kPermissionImageSize + |
| 919 kPermissionImageSpacing; |
| 920 |
916 label = [self addText:reason | 921 label = [self addText:reason |
917 withSize:[NSFont smallSystemFontSize] | 922 withSize:[NSFont smallSystemFontSize] |
918 bold:NO | 923 bold:NO |
919 toView:view | 924 toView:view |
920 atPoint:point]; | 925 atPoint:point]; |
| 926 if (isRTL) { |
| 927 [label setAlignment:NSRightTextAlignment]; |
| 928 // Shift the reason left to align the permission label and the permission |
| 929 // decision reason's right edges. |
| 930 point.x -= (kPermissionImageSize + kPermissionImageSpacing); |
| 931 [label setFrameOrigin:point]; |
| 932 } |
| 933 |
921 label.textColor = skia::SkColorToSRGBNSColor( | 934 label.textColor = skia::SkColorToSRGBNSColor( |
922 PageInfoUI::GetPermissionDecisionTextColor()); | 935 PageInfoUI::GetPermissionDecisionTextColor()); |
923 point.y += NSHeight(label.frame); | 936 point.y += NSHeight(label.frame); |
924 } | 937 } |
925 | 938 |
926 return NSMakePoint(NSMaxX(buttonFrame), point.y); | 939 return NSMakePoint(NSMaxX(buttonFrame), point.y); |
927 } | 940 } |
928 | 941 |
929 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the | 942 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the |
930 // last UI element added (either the permission button, in LTR, or the text | 943 // last UI element added (either the permission button, in LTR, or the text |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) { | 1232 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) { |
1220 [bubble_controller_ setCookieInfo:cookie_info_list]; | 1233 [bubble_controller_ setCookieInfo:cookie_info_list]; |
1221 } | 1234 } |
1222 | 1235 |
1223 void PageInfoUIBridge::SetPermissionInfo( | 1236 void PageInfoUIBridge::SetPermissionInfo( |
1224 const PermissionInfoList& permission_info_list, | 1237 const PermissionInfoList& permission_info_list, |
1225 ChosenObjectInfoList chosen_object_info_list) { | 1238 ChosenObjectInfoList chosen_object_info_list) { |
1226 [bubble_controller_ setPermissionInfo:permission_info_list | 1239 [bubble_controller_ setPermissionInfo:permission_info_list |
1227 andChosenObjects:std::move(chosen_object_info_list)]; | 1240 andChosenObjects:std::move(chosen_object_info_list)]; |
1228 } | 1241 } |
OLD | NEW |