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

Side by Side Diff: chrome/browser/ui/cocoa/page_info/page_info_bubble_controller.mm

Issue 2846913002: Add a Certificate Viewer link to the Page Info dropdown (Closed)
Patch Set: Address review feedback Created 3 years, 7 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (location_bar) { 132 if (location_bar) {
133 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint(); 133 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint();
134 origin = ui::ConvertPointFromWindowToScreen(parent, bubble_point); 134 origin = ui::ConvertPointFromWindowToScreen(parent, bubble_point);
135 } 135 }
136 } 136 }
137 return origin; 137 return origin;
138 } 138 }
139 139
140 } // namespace 140 } // namespace
141 141
142 // The |InspectLinkView| objects are used to show the Cookie and Certificate
143 // status and a link to inspect the underlying data.
144 @interface InspectLinkView : FlippedView
145 @end
146
147 @implementation InspectLinkView {
148 NSButton* actionLink_;
149 }
150
151 - (id)initWithFrame:(NSRect)frame {
152 if (self = [super initWithFrame:frame]) {
153 [self setAutoresizingMask:NSViewWidthSizable];
154 }
155 return self;
156 }
157
158 - (void)setActionLink:(NSButton*)actionLink {
159 actionLink_ = actionLink;
160 }
161
162 - (void)setLinkText:(NSString*)linkText {
163 [actionLink_ setTitle:linkText];
164 [GTMUILocalizerAndLayoutTweaker sizeToFitView:actionLink_];
165 }
166
167 - (void)setLinkToolTip:(NSString*)linkToolTip {
168 [actionLink_ setToolTip:linkToolTip];
169 }
170
171 - (void)setLinkTarget:(NSObject*)target withAction:(SEL)action {
172 [actionLink_ setTarget:target];
173 [actionLink_ setAction:action];
174 }
175 @end
176
142 @interface ChosenObjectDeleteButton : HoverImageButton { 177 @interface ChosenObjectDeleteButton : HoverImageButton {
143 @private 178 @private
144 ChosenObjectInfoPtr objectInfo_; 179 ChosenObjectInfoPtr objectInfo_;
145 ChosenObjectDeleteCallback callback_; 180 ChosenObjectDeleteCallback callback_;
146 } 181 }
147 182
148 // Designated initializer. Takes ownership of |objectInfo|. 183 // Designated initializer. Takes ownership of |objectInfo|.
149 - (instancetype)initWithChosenObject:(ChosenObjectInfoPtr)objectInfo 184 - (instancetype)initWithChosenObject:(ChosenObjectInfoPtr)objectInfo
150 atPoint:(NSPoint)point 185 atPoint:(NSPoint)point
151 withCallback:(ChosenObjectDeleteCallback)callback; 186 withCallback:(ChosenObjectDeleteCallback)callback;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 397
363 // Create and return a subview for the site settings and add it to the given 398 // Create and return a subview for the site settings and add it to the given
364 // |superview|. |superview| retains the new view. 399 // |superview|. |superview| retains the new view.
365 - (NSView*)addSiteSettingsSectionToView:(NSView*)superview { 400 - (NSView*)addSiteSettingsSectionToView:(NSView*)superview {
366 base::scoped_nsobject<NSView> siteSettingsSectionView( 401 base::scoped_nsobject<NSView> siteSettingsSectionView(
367 [[FlippedView alloc] initWithFrame:[superview frame]]); 402 [[FlippedView alloc] initWithFrame:[superview frame]]);
368 [superview addSubview:siteSettingsSectionView]; 403 [superview addSubview:siteSettingsSectionView];
369 404
370 // Initialize the two containers that hold the controls. The initial frames 405 // Initialize the two containers that hold the controls. The initial frames
371 // are arbitrary, and will be adjusted after the controls are laid out. 406 // are arbitrary, and will be adjusted after the controls are laid out.
372 cookiesView_ = 407 PageInfoUI::PermissionInfo info;
373 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; 408 info.type = CONTENT_SETTINGS_TYPE_COOKIES;
374 [cookiesView_ setAutoresizingMask:NSViewWidthSizable]; 409 info.setting = CONTENT_SETTING_ALLOW;
375 [siteSettingsSectionView addSubview:cookiesView_]; 410 cookiesView_ = [self
411 addInspectLinkToView:siteSettingsSectionView
412 sectionIcon:PageInfoUI::GetPermissionIcon(info).ToNSImage()
413 sectionTitle:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES)
414 linkText:l10n_util::GetPluralNSStringF(
415 IDS_PAGE_INFO_NUM_COOKIES, 0)];
416 [cookiesView_ setLinkTarget:self
417 withAction:@selector(showCookiesAndSiteData:)];
376 418
377 permissionsView_ = 419 permissionsView_ =
378 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; 420 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease];
379 [siteSettingsSectionView addSubview:permissionsView_]; 421 [siteSettingsSectionView addSubview:permissionsView_];
380 422
423 // The certificate section is created on demand.
424 certificateView_ = nil;
425
381 // Create the link button to view site settings. Its position will be set in 426 // Create the link button to view site settings. Its position will be set in
382 // performLayout. 427 // performLayout.
383 NSString* siteSettingsButtonText = 428 NSString* siteSettingsButtonText =
384 l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK); 429 l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK);
385 siteSettingsButton_ = [self addButtonWithText:siteSettingsButtonText 430 siteSettingsButton_ = [self addButtonWithText:siteSettingsButtonText
386 toView:siteSettingsSectionView]; 431 toView:siteSettingsSectionView];
387 [GTMUILocalizerAndLayoutTweaker sizeToFitView:siteSettingsButton_]; 432 [GTMUILocalizerAndLayoutTweaker sizeToFitView:siteSettingsButton_];
388 433
389 [siteSettingsButton_ setTarget:self]; 434 [siteSettingsButton_ setTarget:self];
390 [siteSettingsButton_ setAction:@selector(showSiteSettingsData:)]; 435 [siteSettingsButton_ setAction:@selector(showSiteSettingsData:)];
391 436
392 return siteSettingsSectionView.get(); 437 return siteSettingsSectionView.get();
393 } 438 }
394 439
440 - (InspectLinkView*)addInspectLinkToView:(NSView*)superview
441 sectionIcon:(NSImage*)imageIcon
442 sectionTitle:(const base::string16&)titleText
443 linkText:(NSString*)linkText {
444 // Create the subview.
445 base::scoped_nsobject<InspectLinkView> newView(
446 [[InspectLinkView alloc] initWithFrame:[superview frame]]);
447 [superview addSubview:newView];
448
449 bool isRTL = base::i18n::IsRTL();
450 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0);
451
452 CGFloat viewWidth = NSWidth([newView frame]);
453
454 // Reset X for the icon.
455 if (isRTL) {
456 controlOrigin.x =
457 viewWidth - kPermissionImageSize - kSectionHorizontalPadding;
458 }
459
460 NSImageView* imageView = [self addImageWithSize:[imageIcon size]
461 toView:newView
462 atPoint:controlOrigin];
463 [imageView setImage:imageIcon];
464
465 NSButton* actionLink = [self addLinkButtonWithText:linkText toView:newView];
466 [newView setActionLink:actionLink];
467
468 if (isRTL) {
469 controlOrigin.x -= kPermissionImageSpacing;
470 NSTextField* sectionTitle = [self addText:titleText
471 withSize:[NSFont systemFontSize]
472 bold:NO
473 toView:newView
474 atPoint:controlOrigin];
475 [sectionTitle sizeToFit];
476
477 NSPoint sectionTitleOrigin = [sectionTitle frame].origin;
478 sectionTitleOrigin.x -= NSWidth([sectionTitle frame]);
479 [sectionTitle setFrameOrigin:sectionTitleOrigin];
480
481 // Align the icon with the text.
482 [self alignPermissionIcon:imageView withTextField:sectionTitle];
483
484 controlOrigin.y +=
485 NSHeight([sectionTitle frame]) + kPermissionLabelBottomPadding;
486 controlOrigin.x -= NSWidth([actionLink frame]) - kLinkButtonXAdjustment;
487 [actionLink setFrameOrigin:controlOrigin];
488 } else {
489 controlOrigin.x += kPermissionImageSize + kPermissionImageSpacing;
490 NSTextField* sectionTitle = [self addText:titleText
491 withSize:[NSFont systemFontSize]
492 bold:NO
493 toView:newView
494 atPoint:controlOrigin];
495 [sectionTitle sizeToFit];
496
497 // Align the icon with the text.
498 [self alignPermissionIcon:imageView withTextField:sectionTitle];
499
500 controlOrigin.y +=
501 NSHeight([sectionTitle frame]) + kPermissionLabelBottomPadding;
502 controlOrigin.x -= kLinkButtonXAdjustment;
503 [actionLink setFrameOrigin:controlOrigin];
504 }
505
506 controlOrigin.y += NSHeight([actionLink frame]);
507 [newView setFrameSize:NSMakeSize(NSWidth([newView frame]), controlOrigin.y)];
508
509 return newView.get();
510 }
511
395 // Handler for the link button below the list of cookies. 512 // Handler for the link button below the list of cookies.
396 - (void)showCookiesAndSiteData:(id)sender { 513 - (void)showCookiesAndSiteData:(id)sender {
397 DCHECK(webContents_); 514 DCHECK(webContents_);
398 DCHECK(presenter_); 515 DCHECK(presenter_);
399 presenter_->RecordPageInfoAction(PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED); 516 presenter_->RecordPageInfoAction(PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED);
400 TabDialogs::FromWebContents(webContents_)->ShowCollectedCookies(); 517 TabDialogs::FromWebContents(webContents_)->ShowCollectedCookies();
401 } 518 }
402 519
403 // Handler for the site settings button below the list of permissions. 520 // Handler for the site settings button below the list of permissions.
404 - (void)showSiteSettingsData:(id)sender { 521 - (void)showSiteSettingsData:(id)sender {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 yPos)]; 640 yPos)];
524 yPos = NSMaxY([resetDecisionsButton_ frame]); 641 yPos = NSMaxY([resetDecisionsButton_ frame]);
525 } 642 }
526 643
527 // Resize the height based on contents. 644 // Resize the height based on contents.
528 [self setHeightOfView:securitySectionView_ to:yPos + kSectionVerticalPadding]; 645 [self setHeightOfView:securitySectionView_ to:yPos + kSectionVerticalPadding];
529 } 646 }
530 647
531 - (void)layoutSiteSettingsSection { 648 - (void)layoutSiteSettingsSection {
532 // Start the layout with the first element. Margins are handled by the caller. 649 // Start the layout with the first element. Margins are handled by the caller.
533 CGFloat yPos = 0; 650 CGFloat yPos = kSectionVerticalPadding;
534 651
535 yPos = 652 if (certificateView_) {
536 [self setYPositionOfView:cookiesView_ to:yPos + kSectionVerticalPadding]; 653 yPos = [self setYPositionOfView:certificateView_ to:yPos] +
654 kPermissionsVerticalSpacing;
655 }
656
657 yPos = [self setYPositionOfView:cookiesView_ to:yPos];
537 658
538 if (permissionsPresent_) { 659 if (permissionsPresent_) {
539 // Put the permission info just below the link button. 660 // Put the permission info just below the link button.
540 yPos = [self setYPositionOfView:permissionsView_ to:yPos]; 661 yPos = [self setYPositionOfView:permissionsView_ to:yPos];
541 } 662 }
542 663
543 yPos = [self layoutViewAtRTLStart:siteSettingsButton_ withYPosition:yPos]; 664 yPos = [self layoutViewAtRTLStart:siteSettingsButton_ withYPosition:yPos];
544 665
545 // Resize the height based on contents. 666 // Resize the height based on contents.
546 [self setHeightOfView:siteSettingsSectionView_ 667 [self setHeightOfView:siteSettingsSectionView_
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 buttonFrame.size.width = maxTitleWidth; 800 buttonFrame.size.width = maxTitleWidth;
680 801
681 [button setFrame:buttonFrame]; 802 [button setFrame:buttonFrame];
682 [button setButtonType:NSMomentaryPushInButton]; 803 [button setButtonType:NSMomentaryPushInButton];
683 [button setBezelStyle:NSRegularSquareBezelStyle]; 804 [button setBezelStyle:NSRegularSquareBezelStyle];
684 [view addSubview:button.get()]; 805 [view addSubview:button.get()];
685 806
686 return button.get(); 807 return button.get();
687 } 808 }
688 809
689 // Set the content of the identity and identity status fields. 810 // Set the content of the identity and identity status fields, and add the
811 // Certificate view if applicable.
690 - (void)setIdentityInfo:(const PageInfoUI::IdentityInfo&)identityInfo { 812 - (void)setIdentityInfo:(const PageInfoUI::IdentityInfo&)identityInfo {
691 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = 813 std::unique_ptr<PageInfoUI::SecurityDescription> security_description =
692 identityInfo.GetSecurityDescription(); 814 identityInfo.GetSecurityDescription();
693 [securitySummaryField_ 815 [securitySummaryField_
694 setStringValue:base::SysUTF16ToNSString(security_description->summary)]; 816 setStringValue:SysUTF16ToNSString(security_description->summary)];
695 817
696 [securityDetailsField_ 818 [securityDetailsField_
697 setStringValue:SysUTF16ToNSString(security_description->details)]; 819 setStringValue:SysUTF16ToNSString(security_description->details)];
698 820
699 certificate_ = identityInfo.certificate; 821 certificate_ = identityInfo.certificate;
700 822
701 if (certificate_ && identityInfo.show_ssl_decision_revoke_button) { 823 if (certificate_) {
702 resetDecisionsField_ = 824 if (identityInfo.show_ssl_decision_revoke_button) {
703 [self addText:base::string16() 825 resetDecisionsField_ =
704 withSize:[NSFont smallSystemFontSize] 826 [self addText:base::string16()
705 bold:NO 827 withSize:[NSFont smallSystemFontSize]
706 toView:securitySectionView_ 828 bold:NO
707 atPoint:NSMakePoint(kSectionHorizontalPadding, 0)]; 829 toView:securitySectionView_
708 [resetDecisionsField_ 830 atPoint:NSMakePoint(kSectionHorizontalPadding, 0)];
709 setStringValue:l10n_util::GetNSString( 831 [resetDecisionsField_
710 IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)]; 832 setStringValue:l10n_util::GetNSString(
711 [self sizeTextFieldHeightToFit:resetDecisionsField_]; 833 IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)];
834 [self sizeTextFieldHeightToFit:resetDecisionsField_];
712 835
713 resetDecisionsButton_ = 836 resetDecisionsButton_ =
714 [self addLinkButtonWithText: 837 [self addLinkButtonWithText:
715 l10n_util::GetNSString( 838 l10n_util::GetNSString(
716 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON) 839 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON)
717 toView:securitySectionView_]; 840 toView:securitySectionView_];
718 [resetDecisionsButton_ setTarget:self]; 841 [resetDecisionsButton_ setTarget:self];
719 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)]; 842 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)];
843 }
844
845 if (PageInfoUI::ShouldShowCertificateLink()) {
846 bool isValid = (identityInfo.identity_status !=
847 PageInfo::SITE_IDENTITY_STATUS_ERROR);
848 NSString* linkText = l10n_util::GetNSString(
849 isValid ? IDS_PAGE_INFO_CERTIFICATE_VALID_LINK
850 : IDS_PAGE_INFO_CERTIFICATE_INVALID_LINK);
851
852 certificateView_ = [self
853 addInspectLinkToView:siteSettingsSectionView_
854 sectionIcon:PageInfoUI::GetCertificateIcon().ToNSImage()
855 sectionTitle:l10n_util::GetStringUTF16(
856 IDS_PAGE_INFO_CERTIFICATE)
857 linkText:linkText];
858 if (isValid) {
859 [certificateView_
860 setLinkToolTip:l10n_util::GetNSStringF(
861 IDS_PAGE_INFO_CERTIFICATE_VALID_LINK_TOOLTIP,
862 base::UTF8ToUTF16(
863 certificate_->issuer().GetDisplayName()))];
864 }
865
866 [certificateView_ setLinkTarget:self
867 withAction:@selector(showCertificateInfo:)];
868 }
720 } 869 }
721 870
722 [self performLayout]; 871 [self performLayout];
723 } 872 }
724 873
725 // Add a pop-up button for |permissionInfo| to the given view. 874 // Add a pop-up button for |permissionInfo| to the given view.
726 - (NSPopUpButton*)addPopUpButtonForPermission: 875 - (NSPopUpButton*)addPopUpButtonForPermission:
727 (const PageInfoUI::PermissionInfo&)permissionInfo 876 (const PageInfoUI::PermissionInfo&)permissionInfo
728 toView:(NSView*)view 877 toView:(NSView*)view
729 atPoint:(NSPoint)point { 878 atPoint:(NSPoint)point {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 // Align an image with a text field by vertically centering the image on 1155 // Align an image with a text field by vertically centering the image on
1007 // the cap height of the first line of text. 1156 // the cap height of the first line of text.
1008 - (void)alignPermissionIcon:(NSImageView*)imageView 1157 - (void)alignPermissionIcon:(NSImageView*)imageView
1009 withTextField:(NSTextField*)textField { 1158 withTextField:(NSTextField*)textField {
1010 NSRect frame = [imageView frame]; 1159 NSRect frame = [imageView frame];
1011 frame.origin.y += kPermissionIconYAdjustment; 1160 frame.origin.y += kPermissionIconYAdjustment;
1012 [imageView setFrame:frame]; 1161 [imageView setFrame:frame];
1013 } 1162 }
1014 1163
1015 - (void)setCookieInfo:(const CookieInfoList&)cookieInfoList { 1164 - (void)setCookieInfo:(const CookieInfoList&)cookieInfoList {
1016 // A result of re-ordering of the permissions (crbug.com/444244) is
1017 // that sometimes permissions may not be displayed at all, so it's
1018 // incorrect to check they are set before the cookie info.
1019
1020 // |cookieInfoList| should only ever have 2 items: first- and third-party 1165 // |cookieInfoList| should only ever have 2 items: first- and third-party
1021 // cookies. 1166 // cookies.
1022 DCHECK_EQ(cookieInfoList.size(), 2u); 1167 DCHECK_EQ(cookieInfoList.size(), 2u);
1023 1168
1024 int totalAllowed = 0; 1169 int totalAllowed = 0;
1025 for (const auto& i : cookieInfoList) { 1170 for (const auto& i : cookieInfoList) {
1026 totalAllowed += i.allowed; 1171 totalAllowed += i.allowed;
1027 } 1172 }
1028 base::string16 label_text =
1029 l10n_util::GetPluralStringFUTF16(IDS_PAGE_INFO_NUM_COOKIES, totalAllowed);
1030 1173
1031 base::string16 sectionTitle = 1174 [cookiesView_ setLinkText:l10n_util::GetPluralNSStringF(
1032 l10n_util::GetStringUTF16(IDS_PAGE_INFO_TITLE_SITE_DATA); 1175 IDS_PAGE_INFO_NUM_COOKIES, totalAllowed)];
1033 bool isRTL = base::i18n::IsRTL();
1034
1035 [cookiesView_ setSubviews:[NSArray array]];
1036 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0);
1037
1038 CGFloat viewWidth = NSWidth([cookiesView_ frame]);
1039
1040 // Reset X for the cookie image.
1041 if (isRTL) {
1042 controlOrigin.x = viewWidth - kPermissionImageSize -
1043 kPermissionImageSpacing - kSectionHorizontalPadding;
1044 }
1045
1046 PageInfoUI::PermissionInfo info;
1047 info.type = CONTENT_SETTINGS_TYPE_COOKIES;
1048 info.setting = CONTENT_SETTING_ALLOW;
1049 // info.default_setting, info.source, and info.is_incognito have not been set,
1050 // but GetPermissionIcon doesn't use any of those.
1051 NSImage* image = PageInfoUI::GetPermissionIcon(info).ToNSImage();
1052 NSImageView* imageView = [self addImageWithSize:[image size]
1053 toView:cookiesView_
1054 atPoint:controlOrigin];
1055 [imageView setImage:image];
1056
1057 NSButton* cookiesButton =
1058 [self addLinkButtonWithText:base::SysUTF16ToNSString(label_text)
1059 toView:cookiesView_];
1060 [cookiesButton setTarget:self];
1061 [cookiesButton setAction:@selector(showCookiesAndSiteData:)];
1062
1063 if (isRTL) {
1064 controlOrigin.x -= kPermissionImageSpacing;
1065 NSTextField* cookiesLabel =
1066 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES)
1067 withSize:[NSFont systemFontSize]
1068 bold:NO
1069 toView:cookiesView_
1070 atPoint:controlOrigin];
1071 [cookiesLabel sizeToFit];
1072
1073 NSPoint cookiesLabelOrigin = [cookiesLabel frame].origin;
1074 cookiesLabelOrigin.x -= NSWidth([cookiesLabel frame]);
1075 [cookiesLabel setFrameOrigin:cookiesLabelOrigin];
1076
1077 // Align the icon with the text.
1078 [self alignPermissionIcon:imageView withTextField:cookiesLabel];
1079
1080 controlOrigin.y +=
1081 NSHeight([cookiesLabel frame]) + kPermissionLabelBottomPadding;
1082 controlOrigin.x -= NSWidth([cookiesButton frame]) - kLinkButtonXAdjustment;
1083 [cookiesButton setFrameOrigin:controlOrigin];
1084 } else {
1085 controlOrigin.x += kPermissionImageSize + kPermissionImageSpacing;
1086 NSTextField* cookiesLabel =
1087 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES)
1088 withSize:[NSFont systemFontSize]
1089 bold:NO
1090 toView:cookiesView_
1091 atPoint:controlOrigin];
1092 [cookiesLabel sizeToFit];
1093
1094 controlOrigin.y +=
1095 NSHeight([cookiesLabel frame]) + kPermissionLabelBottomPadding;
1096 controlOrigin.x -= kLinkButtonXAdjustment;
1097 [cookiesButton setFrameOrigin:controlOrigin];
1098
1099 // Align the icon with the text.
1100 [self alignPermissionIcon:imageView withTextField:cookiesLabel];
1101 }
1102
1103 controlOrigin.y += NSHeight([cookiesButton frame]);
1104 [cookiesView_
1105 setFrameSize:NSMakeSize(NSWidth([cookiesView_ frame]), controlOrigin.y)];
1106
1107 [self performLayout]; 1176 [self performLayout];
1108 } 1177 }
1109 1178
1110 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList 1179 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList
1111 andChosenObjects:(ChosenObjectInfoList)chosenObjectInfoList { 1180 andChosenObjects:(ChosenObjectInfoList)chosenObjectInfoList {
1112 [permissionsView_ setSubviews:[NSArray array]]; 1181 [permissionsView_ setSubviews:[NSArray array]];
1113 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); 1182 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0);
1114 1183
1115 permissionsPresent_ = YES; 1184 permissionsPresent_ = YES;
1116 1185
1117 if (permissionInfoList.size() > 0 || chosenObjectInfoList.size() > 0) { 1186 if (permissionInfoList.size() > 0 || chosenObjectInfoList.size() > 0) {
1118 base::string16 sectionTitle =
1119 l10n_util::GetStringUTF16(IDS_PAGE_INFO_TITLE_SITE_PERMISSIONS);
1120
1121 for (const auto& permission : permissionInfoList) { 1187 for (const auto& permission : permissionInfoList) {
1122 controlOrigin.y += kPermissionsVerticalSpacing; 1188 controlOrigin.y += kPermissionsVerticalSpacing;
1123 NSPoint rowBottomRight = [self addPermission:permission 1189 NSPoint rowBottomRight = [self addPermission:permission
1124 toView:permissionsView_ 1190 toView:permissionsView_
1125 atPoint:controlOrigin]; 1191 atPoint:controlOrigin];
1126 controlOrigin.y = rowBottomRight.y; 1192 controlOrigin.y = rowBottomRight.y;
1127 } 1193 }
1128 1194
1129 for (auto& object : chosenObjectInfoList) { 1195 for (auto& object : chosenObjectInfoList) {
1130 controlOrigin.y += kPermissionsVerticalSpacing; 1196 controlOrigin.y += kPermissionsVerticalSpacing;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) { 1285 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) {
1220 [bubble_controller_ setCookieInfo:cookie_info_list]; 1286 [bubble_controller_ setCookieInfo:cookie_info_list];
1221 } 1287 }
1222 1288
1223 void PageInfoUIBridge::SetPermissionInfo( 1289 void PageInfoUIBridge::SetPermissionInfo(
1224 const PermissionInfoList& permission_info_list, 1290 const PermissionInfoList& permission_info_list,
1225 ChosenObjectInfoList chosen_object_info_list) { 1291 ChosenObjectInfoList chosen_object_info_list) {
1226 [bubble_controller_ setPermissionInfo:permission_info_list 1292 [bubble_controller_ setPermissionInfo:permission_info_list
1227 andChosenObjects:std::move(chosen_object_info_list)]; 1293 andChosenObjects:std::move(chosen_object_info_list)];
1228 } 1294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698