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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 @implementation InspectLinkView |
| 143 - (id)initWithFrame:(NSRect)frame { |
| 144 if (self = [super initWithFrame:frame]) { |
| 145 [self setAutoresizingMask:NSViewWidthSizable]; |
| 146 [self setSubviews:[NSArray array]]; |
| 147 } |
| 148 return self; |
| 149 } |
| 150 |
| 151 - (void)setActionLink:(NSButton*)actionLink { |
| 152 actionLink_ = actionLink; |
| 153 } |
| 154 |
| 155 - (void)setLinkText:(NSString*)linkText { |
| 156 [actionLink_ setTitle:linkText]; |
| 157 [GTMUILocalizerAndLayoutTweaker sizeToFitView:actionLink_]; |
| 158 } |
| 159 |
| 160 - (void)setLinkToolTip:(NSString*)linkToolTip { |
| 161 [actionLink_ setToolTip:linkToolTip]; |
| 162 } |
| 163 |
| 164 - (void)setLinkTarget:(NSObject*)target withAction:(SEL)action { |
| 165 [actionLink_ setTarget:target]; |
| 166 [actionLink_ setAction:action]; |
| 167 } |
| 168 @end |
| 169 |
142 @interface ChosenObjectDeleteButton : HoverImageButton { | 170 @interface ChosenObjectDeleteButton : HoverImageButton { |
143 @private | 171 @private |
144 ChosenObjectInfoPtr objectInfo_; | 172 ChosenObjectInfoPtr objectInfo_; |
145 ChosenObjectDeleteCallback callback_; | 173 ChosenObjectDeleteCallback callback_; |
146 } | 174 } |
147 | 175 |
148 // Designated initializer. Takes ownership of |objectInfo|. | 176 // Designated initializer. Takes ownership of |objectInfo|. |
149 - (instancetype)initWithChosenObject:(ChosenObjectInfoPtr)objectInfo | 177 - (instancetype)initWithChosenObject:(ChosenObjectInfoPtr)objectInfo |
150 atPoint:(NSPoint)point | 178 atPoint:(NSPoint)point |
151 withCallback:(ChosenObjectDeleteCallback)callback; | 179 withCallback:(ChosenObjectDeleteCallback)callback; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 390 |
363 // Create and return a subview for the site settings and add it to the given | 391 // Create and return a subview for the site settings and add it to the given |
364 // |superview|. |superview| retains the new view. | 392 // |superview|. |superview| retains the new view. |
365 - (NSView*)addSiteSettingsSectionToView:(NSView*)superview { | 393 - (NSView*)addSiteSettingsSectionToView:(NSView*)superview { |
366 base::scoped_nsobject<NSView> siteSettingsSectionView( | 394 base::scoped_nsobject<NSView> siteSettingsSectionView( |
367 [[FlippedView alloc] initWithFrame:[superview frame]]); | 395 [[FlippedView alloc] initWithFrame:[superview frame]]); |
368 [superview addSubview:siteSettingsSectionView]; | 396 [superview addSubview:siteSettingsSectionView]; |
369 | 397 |
370 // Initialize the two containers that hold the controls. The initial frames | 398 // Initialize the two containers that hold the controls. The initial frames |
371 // are arbitrary, and will be adjusted after the controls are laid out. | 399 // are arbitrary, and will be adjusted after the controls are laid out. |
372 cookiesView_ = | 400 PageInfoUI::PermissionInfo info; |
373 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; | 401 info.type = CONTENT_SETTINGS_TYPE_COOKIES; |
374 [cookiesView_ setAutoresizingMask:NSViewWidthSizable]; | 402 info.setting = CONTENT_SETTING_ALLOW; |
375 [siteSettingsSectionView addSubview:cookiesView_]; | 403 cookiesView_ = [self |
| 404 addInspectLinkToView:siteSettingsSectionView |
| 405 sectionIcon:PageInfoUI::GetPermissionIcon(info).ToNSImage() |
| 406 sectionTitle:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES) |
| 407 linkText:l10n_util::GetPluralNSStringF( |
| 408 IDS_PAGE_INFO_NUM_COOKIES, 0)]; |
| 409 [cookiesView_ setLinkTarget:self |
| 410 withAction:@selector(showCookiesAndSiteData:)]; |
376 | 411 |
377 permissionsView_ = | 412 permissionsView_ = |
378 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; | 413 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; |
379 [siteSettingsSectionView addSubview:permissionsView_]; | 414 [siteSettingsSectionView addSubview:permissionsView_]; |
380 | 415 |
| 416 // The certificate section is created on demand. |
| 417 certificateView_ = nil; |
| 418 |
381 // Create the link button to view site settings. Its position will be set in | 419 // Create the link button to view site settings. Its position will be set in |
382 // performLayout. | 420 // performLayout. |
383 NSString* siteSettingsButtonText = | 421 NSString* siteSettingsButtonText = |
384 l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK); | 422 l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK); |
385 siteSettingsButton_ = [self addButtonWithText:siteSettingsButtonText | 423 siteSettingsButton_ = [self addButtonWithText:siteSettingsButtonText |
386 toView:siteSettingsSectionView]; | 424 toView:siteSettingsSectionView]; |
387 [GTMUILocalizerAndLayoutTweaker sizeToFitView:siteSettingsButton_]; | 425 [GTMUILocalizerAndLayoutTweaker sizeToFitView:siteSettingsButton_]; |
388 | 426 |
389 [siteSettingsButton_ setTarget:self]; | 427 [siteSettingsButton_ setTarget:self]; |
390 [siteSettingsButton_ setAction:@selector(showSiteSettingsData:)]; | 428 [siteSettingsButton_ setAction:@selector(showSiteSettingsData:)]; |
391 | 429 |
392 return siteSettingsSectionView.get(); | 430 return siteSettingsSectionView.get(); |
393 } | 431 } |
394 | 432 |
| 433 - (InspectLinkView*)addInspectLinkToView:(NSView*)superview |
| 434 sectionIcon:(NSImage*)imageIcon |
| 435 sectionTitle:(const base::string16&)titleText |
| 436 linkText:(NSString*)linkText { |
| 437 // Create the subview. |
| 438 base::scoped_nsobject<InspectLinkView> newView( |
| 439 [[InspectLinkView alloc] initWithFrame:[superview frame]]); |
| 440 [superview addSubview:newView]; |
| 441 |
| 442 bool isRTL = base::i18n::IsRTL(); |
| 443 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); |
| 444 |
| 445 CGFloat viewWidth = NSWidth([newView frame]); |
| 446 |
| 447 // Reset X for the icon. |
| 448 if (isRTL) { |
| 449 controlOrigin.x = |
| 450 viewWidth - kPermissionImageSize - kSectionHorizontalPadding; |
| 451 } |
| 452 |
| 453 NSImageView* imageView = [self addImageWithSize:[imageIcon size] |
| 454 toView:newView |
| 455 atPoint:controlOrigin]; |
| 456 [imageView setImage:imageIcon]; |
| 457 |
| 458 NSButton* actionLink = [self addLinkButtonWithText:linkText toView:newView]; |
| 459 [newView setActionLink:actionLink]; |
| 460 |
| 461 if (isRTL) { |
| 462 controlOrigin.x -= kPermissionImageSpacing; |
| 463 NSTextField* sectionTitle = [self addText:titleText |
| 464 withSize:[NSFont systemFontSize] |
| 465 bold:NO |
| 466 toView:newView |
| 467 atPoint:controlOrigin]; |
| 468 [sectionTitle sizeToFit]; |
| 469 |
| 470 NSPoint sectionTitleOrigin = [sectionTitle frame].origin; |
| 471 sectionTitleOrigin.x -= NSWidth([sectionTitle frame]); |
| 472 [sectionTitle setFrameOrigin:sectionTitleOrigin]; |
| 473 |
| 474 // Align the icon with the text. |
| 475 [self alignPermissionIcon:imageView withTextField:sectionTitle]; |
| 476 |
| 477 controlOrigin.y += |
| 478 NSHeight([sectionTitle frame]) + kPermissionLabelBottomPadding; |
| 479 controlOrigin.x -= NSWidth([actionLink frame]) - kLinkButtonXAdjustment; |
| 480 [actionLink setFrameOrigin:controlOrigin]; |
| 481 } else { |
| 482 controlOrigin.x += kPermissionImageSize + kPermissionImageSpacing; |
| 483 NSTextField* sectionTitle = [self addText:titleText |
| 484 withSize:[NSFont systemFontSize] |
| 485 bold:NO |
| 486 toView:newView |
| 487 atPoint:controlOrigin]; |
| 488 [sectionTitle sizeToFit]; |
| 489 |
| 490 // Align the icon with the text. |
| 491 [self alignPermissionIcon:imageView withTextField:sectionTitle]; |
| 492 |
| 493 controlOrigin.y += |
| 494 NSHeight([sectionTitle frame]) + kPermissionLabelBottomPadding; |
| 495 controlOrigin.x -= kLinkButtonXAdjustment; |
| 496 [actionLink setFrameOrigin:controlOrigin]; |
| 497 } |
| 498 |
| 499 controlOrigin.y += NSHeight([actionLink frame]); |
| 500 [newView setFrameSize:NSMakeSize(NSWidth([newView frame]), controlOrigin.y)]; |
| 501 |
| 502 return newView.get(); |
| 503 } |
| 504 |
395 // Handler for the link button below the list of cookies. | 505 // Handler for the link button below the list of cookies. |
396 - (void)showCookiesAndSiteData:(id)sender { | 506 - (void)showCookiesAndSiteData:(id)sender { |
397 DCHECK(webContents_); | 507 DCHECK(webContents_); |
398 DCHECK(presenter_); | 508 DCHECK(presenter_); |
399 presenter_->RecordPageInfoAction(PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED); | 509 presenter_->RecordPageInfoAction(PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED); |
400 TabDialogs::FromWebContents(webContents_)->ShowCollectedCookies(); | 510 TabDialogs::FromWebContents(webContents_)->ShowCollectedCookies(); |
401 } | 511 } |
402 | 512 |
403 // Handler for the site settings button below the list of permissions. | 513 // Handler for the site settings button below the list of permissions. |
404 - (void)showSiteSettingsData:(id)sender { | 514 - (void)showSiteSettingsData:(id)sender { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 yPos)]; | 633 yPos)]; |
524 yPos = NSMaxY([resetDecisionsButton_ frame]); | 634 yPos = NSMaxY([resetDecisionsButton_ frame]); |
525 } | 635 } |
526 | 636 |
527 // Resize the height based on contents. | 637 // Resize the height based on contents. |
528 [self setHeightOfView:securitySectionView_ to:yPos + kSectionVerticalPadding]; | 638 [self setHeightOfView:securitySectionView_ to:yPos + kSectionVerticalPadding]; |
529 } | 639 } |
530 | 640 |
531 - (void)layoutSiteSettingsSection { | 641 - (void)layoutSiteSettingsSection { |
532 // Start the layout with the first element. Margins are handled by the caller. | 642 // Start the layout with the first element. Margins are handled by the caller. |
533 CGFloat yPos = 0; | 643 CGFloat yPos = kSectionVerticalPadding; |
534 | 644 |
535 yPos = | 645 if (certificateView_) { |
536 [self setYPositionOfView:cookiesView_ to:yPos + kSectionVerticalPadding]; | 646 yPos = [self setYPositionOfView:certificateView_ to:yPos] + |
| 647 kPermissionsVerticalSpacing; |
| 648 } |
| 649 |
| 650 yPos = [self setYPositionOfView:cookiesView_ to:yPos]; |
537 | 651 |
538 if (permissionsPresent_) { | 652 if (permissionsPresent_) { |
539 // Put the permission info just below the link button. | 653 // Put the permission info just below the link button. |
540 yPos = [self setYPositionOfView:permissionsView_ to:yPos]; | 654 yPos = [self setYPositionOfView:permissionsView_ to:yPos]; |
541 } | 655 } |
542 | 656 |
543 yPos = [self layoutViewAtRTLStart:siteSettingsButton_ withYPosition:yPos]; | 657 yPos = [self layoutViewAtRTLStart:siteSettingsButton_ withYPosition:yPos]; |
544 | 658 |
545 // Resize the height based on contents. | 659 // Resize the height based on contents. |
546 [self setHeightOfView:siteSettingsSectionView_ | 660 [self setHeightOfView:siteSettingsSectionView_ |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 buttonFrame.size.width = maxTitleWidth; | 793 buttonFrame.size.width = maxTitleWidth; |
680 | 794 |
681 [button setFrame:buttonFrame]; | 795 [button setFrame:buttonFrame]; |
682 [button setButtonType:NSMomentaryPushInButton]; | 796 [button setButtonType:NSMomentaryPushInButton]; |
683 [button setBezelStyle:NSRegularSquareBezelStyle]; | 797 [button setBezelStyle:NSRegularSquareBezelStyle]; |
684 [view addSubview:button.get()]; | 798 [view addSubview:button.get()]; |
685 | 799 |
686 return button.get(); | 800 return button.get(); |
687 } | 801 } |
688 | 802 |
689 // Set the content of the identity and identity status fields. | 803 // Set the content of the identity and identity status fields, and add the |
| 804 // Certificate view if applicable. |
690 - (void)setIdentityInfo:(const PageInfoUI::IdentityInfo&)identityInfo { | 805 - (void)setIdentityInfo:(const PageInfoUI::IdentityInfo&)identityInfo { |
691 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = | 806 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = |
692 identityInfo.GetSecurityDescription(); | 807 identityInfo.GetSecurityDescription(); |
693 [securitySummaryField_ | 808 [securitySummaryField_ |
694 setStringValue:base::SysUTF16ToNSString(security_description->summary)]; | 809 setStringValue:SysUTF16ToNSString(security_description->summary)]; |
695 | 810 |
696 [securityDetailsField_ | 811 [securityDetailsField_ |
697 setStringValue:SysUTF16ToNSString(security_description->details)]; | 812 setStringValue:SysUTF16ToNSString(security_description->details)]; |
698 | 813 |
699 certificate_ = identityInfo.certificate; | 814 certificate_ = identityInfo.certificate; |
700 | 815 |
701 if (certificate_ && identityInfo.show_ssl_decision_revoke_button) { | 816 if (certificate_) { |
702 resetDecisionsField_ = | 817 if (identityInfo.show_ssl_decision_revoke_button) { |
703 [self addText:base::string16() | 818 resetDecisionsField_ = |
704 withSize:[NSFont smallSystemFontSize] | 819 [self addText:base::string16() |
705 bold:NO | 820 withSize:[NSFont smallSystemFontSize] |
706 toView:securitySectionView_ | 821 bold:NO |
707 atPoint:NSMakePoint(kSectionHorizontalPadding, 0)]; | 822 toView:securitySectionView_ |
708 [resetDecisionsField_ | 823 atPoint:NSMakePoint(kSectionHorizontalPadding, 0)]; |
709 setStringValue:l10n_util::GetNSString( | 824 [resetDecisionsField_ |
710 IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)]; | 825 setStringValue:l10n_util::GetNSString( |
711 [self sizeTextFieldHeightToFit:resetDecisionsField_]; | 826 IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)]; |
| 827 [self sizeTextFieldHeightToFit:resetDecisionsField_]; |
712 | 828 |
713 resetDecisionsButton_ = | 829 resetDecisionsButton_ = |
714 [self addLinkButtonWithText: | 830 [self addLinkButtonWithText: |
715 l10n_util::GetNSString( | 831 l10n_util::GetNSString( |
716 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON) | 832 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON) |
717 toView:securitySectionView_]; | 833 toView:securitySectionView_]; |
718 [resetDecisionsButton_ setTarget:self]; | 834 [resetDecisionsButton_ setTarget:self]; |
719 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)]; | 835 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)]; |
| 836 } |
| 837 |
| 838 if (PageInfoUI::ShouldShowCertificateLink()) { |
| 839 bool isValid = (identityInfo.identity_status != |
| 840 PageInfo::SITE_IDENTITY_STATUS_ERROR); |
| 841 NSString* linkText = l10n_util::GetNSString( |
| 842 isValid ? IDS_PAGE_INFO_CERTIFICATE_VALID_LINK |
| 843 : IDS_PAGE_INFO_CERTIFICATE_INVALID_LINK); |
| 844 |
| 845 certificateView_ = [self |
| 846 addInspectLinkToView:siteSettingsSectionView_ |
| 847 sectionIcon:PageInfoUI::GetCertificateIcon().ToNSImage() |
| 848 sectionTitle:l10n_util::GetStringUTF16( |
| 849 IDS_PAGE_INFO_CERTIFICATE) |
| 850 linkText:linkText]; |
| 851 if (isValid) |
| 852 [certificateView_ |
| 853 setLinkToolTip:l10n_util::GetNSStringF( |
| 854 IDS_PAGE_INFO_CERTIFICATE_VALID_LINK_TOOLTIP, |
| 855 base::UTF8ToUTF16( |
| 856 certificate_->issuer().GetDisplayName()))]; |
| 857 |
| 858 [certificateView_ setLinkTarget:self |
| 859 withAction:@selector(showCertificateInfo:)]; |
| 860 } |
720 } | 861 } |
721 | 862 |
722 [self performLayout]; | 863 [self performLayout]; |
723 } | 864 } |
724 | 865 |
725 // Add a pop-up button for |permissionInfo| to the given view. | 866 // Add a pop-up button for |permissionInfo| to the given view. |
726 - (NSPopUpButton*)addPopUpButtonForPermission: | 867 - (NSPopUpButton*)addPopUpButtonForPermission: |
727 (const PageInfoUI::PermissionInfo&)permissionInfo | 868 (const PageInfoUI::PermissionInfo&)permissionInfo |
728 toView:(NSView*)view | 869 toView:(NSView*)view |
729 atPoint:(NSPoint)point { | 870 atPoint:(NSPoint)point { |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 // Align an image with a text field by vertically centering the image on | 1147 // Align an image with a text field by vertically centering the image on |
1007 // the cap height of the first line of text. | 1148 // the cap height of the first line of text. |
1008 - (void)alignPermissionIcon:(NSImageView*)imageView | 1149 - (void)alignPermissionIcon:(NSImageView*)imageView |
1009 withTextField:(NSTextField*)textField { | 1150 withTextField:(NSTextField*)textField { |
1010 NSRect frame = [imageView frame]; | 1151 NSRect frame = [imageView frame]; |
1011 frame.origin.y += kPermissionIconYAdjustment; | 1152 frame.origin.y += kPermissionIconYAdjustment; |
1012 [imageView setFrame:frame]; | 1153 [imageView setFrame:frame]; |
1013 } | 1154 } |
1014 | 1155 |
1015 - (void)setCookieInfo:(const CookieInfoList&)cookieInfoList { | 1156 - (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 | 1157 // |cookieInfoList| should only ever have 2 items: first- and third-party |
1021 // cookies. | 1158 // cookies. |
1022 DCHECK_EQ(cookieInfoList.size(), 2u); | 1159 DCHECK_EQ(cookieInfoList.size(), 2u); |
1023 | 1160 |
1024 int totalAllowed = 0; | 1161 int totalAllowed = 0; |
1025 for (const auto& i : cookieInfoList) { | 1162 for (const auto& i : cookieInfoList) { |
1026 totalAllowed += i.allowed; | 1163 totalAllowed += i.allowed; |
1027 } | 1164 } |
1028 base::string16 label_text = | |
1029 l10n_util::GetPluralStringFUTF16(IDS_PAGE_INFO_NUM_COOKIES, totalAllowed); | |
1030 | 1165 |
1031 base::string16 sectionTitle = | 1166 [cookiesView_ setLinkText:l10n_util::GetPluralNSStringF( |
1032 l10n_util::GetStringUTF16(IDS_PAGE_INFO_TITLE_SITE_DATA); | 1167 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]; | 1168 [self performLayout]; |
1108 } | 1169 } |
1109 | 1170 |
1110 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList | 1171 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList |
1111 andChosenObjects:(ChosenObjectInfoList)chosenObjectInfoList { | 1172 andChosenObjects:(ChosenObjectInfoList)chosenObjectInfoList { |
1112 [permissionsView_ setSubviews:[NSArray array]]; | 1173 [permissionsView_ setSubviews:[NSArray array]]; |
1113 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); | 1174 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); |
1114 | 1175 |
1115 permissionsPresent_ = YES; | 1176 permissionsPresent_ = YES; |
1116 | 1177 |
1117 if (permissionInfoList.size() > 0 || chosenObjectInfoList.size() > 0) { | 1178 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) { | 1179 for (const auto& permission : permissionInfoList) { |
1122 controlOrigin.y += kPermissionsVerticalSpacing; | 1180 controlOrigin.y += kPermissionsVerticalSpacing; |
1123 NSPoint rowBottomRight = [self addPermission:permission | 1181 NSPoint rowBottomRight = [self addPermission:permission |
1124 toView:permissionsView_ | 1182 toView:permissionsView_ |
1125 atPoint:controlOrigin]; | 1183 atPoint:controlOrigin]; |
1126 controlOrigin.y = rowBottomRight.y; | 1184 controlOrigin.y = rowBottomRight.y; |
1127 } | 1185 } |
1128 | 1186 |
1129 for (auto& object : chosenObjectInfoList) { | 1187 for (auto& object : chosenObjectInfoList) { |
1130 controlOrigin.y += kPermissionsVerticalSpacing; | 1188 controlOrigin.y += kPermissionsVerticalSpacing; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) { | 1277 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) { |
1220 [bubble_controller_ setCookieInfo:cookie_info_list]; | 1278 [bubble_controller_ setCookieInfo:cookie_info_list]; |
1221 } | 1279 } |
1222 | 1280 |
1223 void PageInfoUIBridge::SetPermissionInfo( | 1281 void PageInfoUIBridge::SetPermissionInfo( |
1224 const PermissionInfoList& permission_info_list, | 1282 const PermissionInfoList& permission_info_list, |
1225 ChosenObjectInfoList chosen_object_info_list) { | 1283 ChosenObjectInfoList chosen_object_info_list) { |
1226 [bubble_controller_ setPermissionInfo:permission_info_list | 1284 [bubble_controller_ setPermissionInfo:permission_info_list |
1227 andChosenObjects:std::move(chosen_object_info_list)]; | 1285 andChosenObjects:std::move(chosen_object_info_list)]; |
1228 } | 1286 } |
OLD | NEW |