| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 if (location_bar) { | 127 if (location_bar) { |
| 128 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint(); | 128 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint(); |
| 129 origin = ui::ConvertPointFromWindowToScreen(parent, bubble_point); | 129 origin = ui::ConvertPointFromWindowToScreen(parent, bubble_point); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 return origin; | 132 return origin; |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace | 135 } // namespace |
| 136 | 136 |
| 137 @implementation InspectLinkView |
| 138 - (id)initWithFrame:(NSRect)frame { |
| 139 if (self = [super initWithFrame:frame]) { |
| 140 [self setAutoresizingMask:NSViewWidthSizable]; |
| 141 [self setSubviews:[NSArray array]]; |
| 142 } |
| 143 return self; |
| 144 } |
| 145 |
| 146 - (void)setActionLink:(NSButton*)actionLink { |
| 147 actionLink_ = actionLink; |
| 148 } |
| 149 |
| 150 - (void)setLinkText:(NSString*)linkText { |
| 151 [actionLink_ setTitle:linkText]; |
| 152 [GTMUILocalizerAndLayoutTweaker sizeToFitView:actionLink_]; |
| 153 } |
| 154 |
| 155 - (void)setLinkToolTip:(NSString*)linkToolTip { |
| 156 [actionLink_ setToolTip:linkToolTip]; |
| 157 } |
| 158 |
| 159 - (void)setLinkTarget:(NSObject*)target withAction:(SEL)action { |
| 160 [actionLink_ setTarget:target]; |
| 161 [actionLink_ setAction:action]; |
| 162 } |
| 163 @end |
| 164 |
| 137 @interface ChosenObjectDeleteButton : HoverImageButton { | 165 @interface ChosenObjectDeleteButton : HoverImageButton { |
| 138 @private | 166 @private |
| 139 ChosenObjectInfoPtr objectInfo_; | 167 ChosenObjectInfoPtr objectInfo_; |
| 140 ChosenObjectDeleteCallback callback_; | 168 ChosenObjectDeleteCallback callback_; |
| 141 } | 169 } |
| 142 | 170 |
| 143 // Designated initializer. Takes ownership of |objectInfo|. | 171 // Designated initializer. Takes ownership of |objectInfo|. |
| 144 - (instancetype)initWithChosenObject:(ChosenObjectInfoPtr)objectInfo | 172 - (instancetype)initWithChosenObject:(ChosenObjectInfoPtr)objectInfo |
| 145 atPoint:(NSPoint)point | 173 atPoint:(NSPoint)point |
| 146 withCallback:(ChosenObjectDeleteCallback)callback; | 174 withCallback:(ChosenObjectDeleteCallback)callback; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 385 |
| 358 // Create and return a subview for the site settings and add it to the given | 386 // Create and return a subview for the site settings and add it to the given |
| 359 // |superview|. |superview| retains the new view. | 387 // |superview|. |superview| retains the new view. |
| 360 - (NSView*)addSiteSettingsSectionToView:(NSView*)superview { | 388 - (NSView*)addSiteSettingsSectionToView:(NSView*)superview { |
| 361 base::scoped_nsobject<NSView> siteSettingsSectionView( | 389 base::scoped_nsobject<NSView> siteSettingsSectionView( |
| 362 [[FlippedView alloc] initWithFrame:[superview frame]]); | 390 [[FlippedView alloc] initWithFrame:[superview frame]]); |
| 363 [superview addSubview:siteSettingsSectionView]; | 391 [superview addSubview:siteSettingsSectionView]; |
| 364 | 392 |
| 365 // Initialize the two containers that hold the controls. The initial frames | 393 // Initialize the two containers that hold the controls. The initial frames |
| 366 // are arbitrary, and will be adjusted after the controls are laid out. | 394 // are arbitrary, and will be adjusted after the controls are laid out. |
| 367 cookiesView_ = | 395 PageInfoUI::PermissionInfo info; |
| 368 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; | 396 info.type = CONTENT_SETTINGS_TYPE_COOKIES; |
| 369 [cookiesView_ setAutoresizingMask:NSViewWidthSizable]; | 397 info.setting = CONTENT_SETTING_ALLOW; |
| 370 [siteSettingsSectionView addSubview:cookiesView_]; | 398 cookiesView_ = [self |
| 399 addInspectLinkToView:siteSettingsSectionView |
| 400 sectionIcon:PageInfoUI::GetPermissionIcon(info).ToNSImage() |
| 401 sectionTitle:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES) |
| 402 linkText:l10n_util::GetPluralNSStringF( |
| 403 IDS_PAGE_INFO_NUM_COOKIES, 0)]; |
| 404 [cookiesView_ setLinkTarget:self |
| 405 withAction:@selector(showCookiesAndSiteData:)]; |
| 371 | 406 |
| 372 permissionsView_ = | 407 permissionsView_ = |
| 373 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; | 408 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; |
| 374 [siteSettingsSectionView addSubview:permissionsView_]; | 409 [siteSettingsSectionView addSubview:permissionsView_]; |
| 375 | 410 |
| 411 // The certificate section is created on demand. |
| 412 certificateView_ = nil; |
| 413 |
| 376 // Create the link button to view site settings. Its position will be set in | 414 // Create the link button to view site settings. Its position will be set in |
| 377 // performLayout. | 415 // performLayout. |
| 378 NSString* siteSettingsButtonText = | 416 NSString* siteSettingsButtonText = |
| 379 l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK); | 417 l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK); |
| 380 siteSettingsButton_ = [self addButtonWithText:siteSettingsButtonText | 418 siteSettingsButton_ = [self addButtonWithText:siteSettingsButtonText |
| 381 toView:siteSettingsSectionView]; | 419 toView:siteSettingsSectionView]; |
| 382 [GTMUILocalizerAndLayoutTweaker sizeToFitView:siteSettingsButton_]; | 420 [GTMUILocalizerAndLayoutTweaker sizeToFitView:siteSettingsButton_]; |
| 383 | 421 |
| 384 [siteSettingsButton_ setTarget:self]; | 422 [siteSettingsButton_ setTarget:self]; |
| 385 [siteSettingsButton_ setAction:@selector(showSiteSettingsData:)]; | 423 [siteSettingsButton_ setAction:@selector(showSiteSettingsData:)]; |
| 386 | 424 |
| 387 return siteSettingsSectionView.get(); | 425 return siteSettingsSectionView.get(); |
| 388 } | 426 } |
| 389 | 427 |
| 428 - (InspectLinkView*)addInspectLinkToView:(NSView*)superview |
| 429 sectionIcon:(NSImage*)imageIcon |
| 430 sectionTitle:(const base::string16&)titleText |
| 431 linkText:(NSString*)linkText { |
| 432 // Create the subview. |
| 433 base::scoped_nsobject<InspectLinkView> newView( |
| 434 [[InspectLinkView alloc] initWithFrame:[superview frame]]); |
| 435 [superview addSubview:newView]; |
| 436 |
| 437 bool isRTL = base::i18n::IsRTL(); |
| 438 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); |
| 439 |
| 440 CGFloat viewWidth = NSWidth([newView frame]); |
| 441 |
| 442 // Reset X for the icon. |
| 443 if (isRTL) { |
| 444 controlOrigin.x = |
| 445 viewWidth - kPermissionImageSize - kSectionHorizontalPadding; |
| 446 } |
| 447 |
| 448 NSImageView* imageView = [self addImageWithSize:[imageIcon size] |
| 449 toView:newView |
| 450 atPoint:controlOrigin]; |
| 451 [imageView setImage:imageIcon]; |
| 452 |
| 453 NSButton* actionLink = [self addLinkButtonWithText:linkText toView:newView]; |
| 454 [newView setActionLink:actionLink]; |
| 455 |
| 456 if (isRTL) { |
| 457 controlOrigin.x -= kPermissionImageSpacing; |
| 458 NSTextField* sectionTitle = [self addText:titleText |
| 459 withSize:[NSFont systemFontSize] |
| 460 bold:NO |
| 461 toView:newView |
| 462 atPoint:controlOrigin]; |
| 463 [sectionTitle sizeToFit]; |
| 464 |
| 465 NSPoint sectionTitleOrigin = [sectionTitle frame].origin; |
| 466 sectionTitleOrigin.x -= NSWidth([sectionTitle frame]); |
| 467 [sectionTitle setFrameOrigin:sectionTitleOrigin]; |
| 468 |
| 469 // Align the icon with the text. |
| 470 [self alignPermissionIcon:imageView withTextField:sectionTitle]; |
| 471 |
| 472 controlOrigin.y += NSHeight([sectionTitle frame]); |
| 473 controlOrigin.x -= NSWidth([actionLink frame]) - kLinkButtonXAdjustment; |
| 474 [actionLink setFrameOrigin:controlOrigin]; |
| 475 } else { |
| 476 controlOrigin.x += kPermissionImageSize + kPermissionImageSpacing; |
| 477 NSTextField* sectionTitle = [self addText:titleText |
| 478 withSize:[NSFont systemFontSize] |
| 479 bold:NO |
| 480 toView:newView |
| 481 atPoint:controlOrigin]; |
| 482 [sectionTitle sizeToFit]; |
| 483 |
| 484 // Align the icon with the text. |
| 485 [self alignPermissionIcon:imageView withTextField:sectionTitle]; |
| 486 |
| 487 controlOrigin.y += NSHeight([sectionTitle frame]); |
| 488 controlOrigin.x -= kLinkButtonXAdjustment; |
| 489 [actionLink setFrameOrigin:controlOrigin]; |
| 490 } |
| 491 |
| 492 controlOrigin.y += NSHeight([actionLink frame]); |
| 493 [newView setFrameSize:NSMakeSize(NSWidth([newView frame]), controlOrigin.y)]; |
| 494 |
| 495 return newView.get(); |
| 496 } |
| 497 |
| 390 // Handler for the link button below the list of cookies. | 498 // Handler for the link button below the list of cookies. |
| 391 - (void)showCookiesAndSiteData:(id)sender { | 499 - (void)showCookiesAndSiteData:(id)sender { |
| 392 DCHECK(webContents_); | 500 DCHECK(webContents_); |
| 393 DCHECK(presenter_); | 501 DCHECK(presenter_); |
| 394 presenter_->RecordPageInfoAction(PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED); | 502 presenter_->RecordPageInfoAction(PageInfo::PAGE_INFO_COOKIES_DIALOG_OPENED); |
| 395 TabDialogs::FromWebContents(webContents_)->ShowCollectedCookies(); | 503 TabDialogs::FromWebContents(webContents_)->ShowCollectedCookies(); |
| 396 } | 504 } |
| 397 | 505 |
| 398 // Handler for the site settings button below the list of permissions. | 506 // Handler for the site settings button below the list of permissions. |
| 399 - (void)showSiteSettingsData:(id)sender { | 507 - (void)showSiteSettingsData:(id)sender { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 yPos)]; | 626 yPos)]; |
| 519 yPos = NSMaxY([resetDecisionsButton_ frame]); | 627 yPos = NSMaxY([resetDecisionsButton_ frame]); |
| 520 } | 628 } |
| 521 | 629 |
| 522 // Resize the height based on contents. | 630 // Resize the height based on contents. |
| 523 [self setHeightOfView:securitySectionView_ to:yPos + kSectionVerticalPadding]; | 631 [self setHeightOfView:securitySectionView_ to:yPos + kSectionVerticalPadding]; |
| 524 } | 632 } |
| 525 | 633 |
| 526 - (void)layoutSiteSettingsSection { | 634 - (void)layoutSiteSettingsSection { |
| 527 // Start the layout with the first element. Margins are handled by the caller. | 635 // Start the layout with the first element. Margins are handled by the caller. |
| 528 CGFloat yPos = 0; | 636 CGFloat yPos = kSectionVerticalPadding; |
| 529 | 637 |
| 530 yPos = | 638 if (certificateView_) { |
| 531 [self setYPositionOfView:cookiesView_ to:yPos + kSectionVerticalPadding]; | 639 yPos = [self setYPositionOfView:certificateView_ to:yPos] + |
| 640 kPermissionsVerticalSpacing; |
| 641 } |
| 642 |
| 643 yPos = [self setYPositionOfView:cookiesView_ to:yPos]; |
| 532 | 644 |
| 533 if (permissionsPresent_) { | 645 if (permissionsPresent_) { |
| 534 // Put the permission info just below the link button. | 646 // Put the permission info just below the link button. |
| 535 yPos = [self setYPositionOfView:permissionsView_ to:yPos]; | 647 yPos = [self setYPositionOfView:permissionsView_ to:yPos]; |
| 536 } | 648 } |
| 537 | 649 |
| 538 yPos = [self layoutViewAtRTLStart:siteSettingsButton_ withYPosition:yPos]; | 650 yPos = [self layoutViewAtRTLStart:siteSettingsButton_ withYPosition:yPos]; |
| 539 | 651 |
| 540 // Resize the height based on contents. | 652 // Resize the height based on contents. |
| 541 [self setHeightOfView:siteSettingsSectionView_ | 653 [self setHeightOfView:siteSettingsSectionView_ |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 buttonFrame.size.width = maxTitleWidth; | 786 buttonFrame.size.width = maxTitleWidth; |
| 675 | 787 |
| 676 [button setFrame:buttonFrame]; | 788 [button setFrame:buttonFrame]; |
| 677 [button setButtonType:NSMomentaryPushInButton]; | 789 [button setButtonType:NSMomentaryPushInButton]; |
| 678 [button setBezelStyle:NSRegularSquareBezelStyle]; | 790 [button setBezelStyle:NSRegularSquareBezelStyle]; |
| 679 [view addSubview:button.get()]; | 791 [view addSubview:button.get()]; |
| 680 | 792 |
| 681 return button.get(); | 793 return button.get(); |
| 682 } | 794 } |
| 683 | 795 |
| 684 // Set the content of the identity and identity status fields. | 796 // Set the content of the identity and identity status fields, and add the |
| 797 // Certificate view if applicable. |
| 685 - (void)setIdentityInfo:(const PageInfoUI::IdentityInfo&)identityInfo { | 798 - (void)setIdentityInfo:(const PageInfoUI::IdentityInfo&)identityInfo { |
| 686 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = | 799 std::unique_ptr<PageInfoUI::SecurityDescription> security_description = |
| 687 identityInfo.GetSecurityDescription(); | 800 identityInfo.GetSecurityDescription(); |
| 688 [securitySummaryField_ | 801 [securitySummaryField_ |
| 689 setStringValue:base::SysUTF16ToNSString(security_description->summary)]; | 802 setStringValue:SysUTF16ToNSString(security_description->summary)]; |
| 690 | 803 |
| 691 [securityDetailsField_ | 804 [securityDetailsField_ |
| 692 setStringValue:SysUTF16ToNSString(security_description->details)]; | 805 setStringValue:SysUTF16ToNSString(security_description->details)]; |
| 693 | 806 |
| 694 certificate_ = identityInfo.certificate; | 807 certificate_ = identityInfo.certificate; |
| 695 | 808 |
| 696 if (certificate_ && identityInfo.show_ssl_decision_revoke_button) { | 809 if (certificate_) { |
| 697 resetDecisionsField_ = | 810 if (identityInfo.show_ssl_decision_revoke_button) { |
| 698 [self addText:base::string16() | 811 resetDecisionsField_ = |
| 699 withSize:[NSFont smallSystemFontSize] | 812 [self addText:base::string16() |
| 700 bold:NO | 813 withSize:[NSFont smallSystemFontSize] |
| 701 toView:securitySectionView_ | 814 bold:NO |
| 702 atPoint:NSMakePoint(kSectionHorizontalPadding, 0)]; | 815 toView:securitySectionView_ |
| 703 [resetDecisionsField_ | 816 atPoint:NSMakePoint(kSectionHorizontalPadding, 0)]; |
| 704 setStringValue:l10n_util::GetNSString( | 817 [resetDecisionsField_ |
| 705 IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)]; | 818 setStringValue:l10n_util::GetNSString( |
| 706 [self sizeTextFieldHeightToFit:resetDecisionsField_]; | 819 IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)]; |
| 820 [self sizeTextFieldHeightToFit:resetDecisionsField_]; |
| 707 | 821 |
| 708 resetDecisionsButton_ = | 822 resetDecisionsButton_ = |
| 709 [self addLinkButtonWithText: | 823 [self addLinkButtonWithText: |
| 710 l10n_util::GetNSString( | 824 l10n_util::GetNSString( |
| 711 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON) | 825 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON) |
| 712 toView:securitySectionView_]; | 826 toView:securitySectionView_]; |
| 713 [resetDecisionsButton_ setTarget:self]; | 827 [resetDecisionsButton_ setTarget:self]; |
| 714 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)]; | 828 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)]; |
| 829 } |
| 830 |
| 831 if (PageInfoUI::ShouldShowCertificateLink()) { |
| 832 bool isValid = (identityInfo.identity_status != |
| 833 PageInfo::SITE_IDENTITY_STATUS_ERROR); |
| 834 NSString* linkText = l10n_util::GetNSString( |
| 835 isValid ? IDS_PAGE_INFO_CERTIFICATE_VALID_LINK |
| 836 : IDS_PAGE_INFO_CERTIFICATE_INVALID_LINK); |
| 837 |
| 838 certificateView_ = [self |
| 839 addInspectLinkToView:siteSettingsSectionView_ |
| 840 sectionIcon:PageInfoUI::GetCertificateIcon().ToNSImage() |
| 841 sectionTitle:l10n_util::GetStringUTF16( |
| 842 IDS_PAGE_INFO_CERTIFICATE) |
| 843 linkText:linkText]; |
| 844 if (isValid) |
| 845 [certificateView_ |
| 846 setLinkToolTip: |
| 847 l10n_util::GetNSStringF( |
| 848 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_VERIFIED, |
| 849 base::UTF8ToUTF16( |
| 850 certificate_->issuer().GetDisplayName()))]; |
| 851 |
| 852 [certificateView_ setLinkTarget:self |
| 853 withAction:@selector(showCertificateInfo:)]; |
| 854 } |
| 715 } | 855 } |
| 716 | 856 |
| 717 [self performLayout]; | 857 [self performLayout]; |
| 718 } | 858 } |
| 719 | 859 |
| 720 // Add a pop-up button for |permissionInfo| to the given view. | 860 // Add a pop-up button for |permissionInfo| to the given view. |
| 721 - (NSPopUpButton*)addPopUpButtonForPermission: | 861 - (NSPopUpButton*)addPopUpButtonForPermission: |
| 722 (const PageInfoUI::PermissionInfo&)permissionInfo | 862 (const PageInfoUI::PermissionInfo&)permissionInfo |
| 723 toView:(NSView*)view | 863 toView:(NSView*)view |
| 724 atPoint:(NSPoint)point { | 864 atPoint:(NSPoint)point { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 // Align an image with a text field by vertically centering the image on | 1123 // Align an image with a text field by vertically centering the image on |
| 984 // the cap height of the first line of text. | 1124 // the cap height of the first line of text. |
| 985 - (void)alignPermissionIcon:(NSImageView*)imageView | 1125 - (void)alignPermissionIcon:(NSImageView*)imageView |
| 986 withTextField:(NSTextField*)textField { | 1126 withTextField:(NSTextField*)textField { |
| 987 NSRect frame = [imageView frame]; | 1127 NSRect frame = [imageView frame]; |
| 988 frame.origin.y += kPermissionIconYAdjustment; | 1128 frame.origin.y += kPermissionIconYAdjustment; |
| 989 [imageView setFrame:frame]; | 1129 [imageView setFrame:frame]; |
| 990 } | 1130 } |
| 991 | 1131 |
| 992 - (void)setCookieInfo:(const CookieInfoList&)cookieInfoList { | 1132 - (void)setCookieInfo:(const CookieInfoList&)cookieInfoList { |
| 993 // A result of re-ordering of the permissions (crbug.com/444244) is | |
| 994 // that sometimes permissions may not be displayed at all, so it's | |
| 995 // incorrect to check they are set before the cookie info. | |
| 996 | |
| 997 // |cookieInfoList| should only ever have 2 items: first- and third-party | 1133 // |cookieInfoList| should only ever have 2 items: first- and third-party |
| 998 // cookies. | 1134 // cookies. |
| 999 DCHECK_EQ(cookieInfoList.size(), 2u); | 1135 DCHECK_EQ(cookieInfoList.size(), 2u); |
| 1000 | 1136 |
| 1001 int totalAllowed = 0; | 1137 int totalAllowed = 0; |
| 1002 for (const auto& i : cookieInfoList) { | 1138 for (const auto& i : cookieInfoList) { |
| 1003 totalAllowed += i.allowed; | 1139 totalAllowed += i.allowed; |
| 1004 } | 1140 } |
| 1005 base::string16 label_text = | |
| 1006 l10n_util::GetPluralStringFUTF16(IDS_PAGE_INFO_NUM_COOKIES, totalAllowed); | |
| 1007 | 1141 |
| 1008 base::string16 sectionTitle = | 1142 [cookiesView_ setLinkText:l10n_util::GetPluralNSStringF( |
| 1009 l10n_util::GetStringUTF16(IDS_PAGE_INFO_TITLE_SITE_DATA); | 1143 IDS_PAGE_INFO_NUM_COOKIES, totalAllowed)]; |
| 1010 bool isRTL = base::i18n::IsRTL(); | |
| 1011 | |
| 1012 [cookiesView_ setSubviews:[NSArray array]]; | |
| 1013 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); | |
| 1014 | |
| 1015 CGFloat viewWidth = NSWidth([cookiesView_ frame]); | |
| 1016 | |
| 1017 // Reset X for the cookie image. | |
| 1018 if (isRTL) { | |
| 1019 controlOrigin.x = viewWidth - kPermissionImageSize - | |
| 1020 kPermissionImageSpacing - kSectionHorizontalPadding; | |
| 1021 } | |
| 1022 | |
| 1023 PageInfoUI::PermissionInfo info; | |
| 1024 info.type = CONTENT_SETTINGS_TYPE_COOKIES; | |
| 1025 info.setting = CONTENT_SETTING_ALLOW; | |
| 1026 // info.default_setting, info.source, and info.is_incognito have not been set, | |
| 1027 // but GetPermissionIcon doesn't use any of those. | |
| 1028 NSImage* image = PageInfoUI::GetPermissionIcon(info).ToNSImage(); | |
| 1029 NSImageView* imageView = [self addImageWithSize:[image size] | |
| 1030 toView:cookiesView_ | |
| 1031 atPoint:controlOrigin]; | |
| 1032 [imageView setImage:image]; | |
| 1033 | |
| 1034 NSButton* cookiesButton = | |
| 1035 [self addLinkButtonWithText:base::SysUTF16ToNSString(label_text) | |
| 1036 toView:cookiesView_]; | |
| 1037 [cookiesButton setTarget:self]; | |
| 1038 [cookiesButton setAction:@selector(showCookiesAndSiteData:)]; | |
| 1039 | |
| 1040 if (isRTL) { | |
| 1041 controlOrigin.x -= kPermissionImageSpacing; | |
| 1042 NSTextField* cookiesLabel = | |
| 1043 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES) | |
| 1044 withSize:[NSFont systemFontSize] | |
| 1045 bold:NO | |
| 1046 toView:cookiesView_ | |
| 1047 atPoint:controlOrigin]; | |
| 1048 [cookiesLabel sizeToFit]; | |
| 1049 | |
| 1050 NSPoint cookiesLabelOrigin = [cookiesLabel frame].origin; | |
| 1051 cookiesLabelOrigin.x -= NSWidth([cookiesLabel frame]); | |
| 1052 [cookiesLabel setFrameOrigin:cookiesLabelOrigin]; | |
| 1053 | |
| 1054 // Align the icon with the text. | |
| 1055 [self alignPermissionIcon:imageView withTextField:cookiesLabel]; | |
| 1056 | |
| 1057 controlOrigin.y += NSHeight([cookiesLabel frame]); | |
| 1058 controlOrigin.x -= NSWidth([cookiesButton frame]) - kLinkButtonXAdjustment; | |
| 1059 [cookiesButton setFrameOrigin:controlOrigin]; | |
| 1060 } else { | |
| 1061 controlOrigin.x += kPermissionImageSize + kPermissionImageSpacing; | |
| 1062 NSTextField* cookiesLabel = | |
| 1063 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES) | |
| 1064 withSize:[NSFont systemFontSize] | |
| 1065 bold:NO | |
| 1066 toView:cookiesView_ | |
| 1067 atPoint:controlOrigin]; | |
| 1068 [cookiesLabel sizeToFit]; | |
| 1069 | |
| 1070 controlOrigin.y += NSHeight([cookiesLabel frame]); | |
| 1071 controlOrigin.x -= kLinkButtonXAdjustment; | |
| 1072 [cookiesButton setFrameOrigin:controlOrigin]; | |
| 1073 | |
| 1074 // Align the icon with the text. | |
| 1075 [self alignPermissionIcon:imageView withTextField:cookiesLabel]; | |
| 1076 } | |
| 1077 | |
| 1078 controlOrigin.y += NSHeight([cookiesButton frame]); | |
| 1079 [cookiesView_ | |
| 1080 setFrameSize:NSMakeSize(NSWidth([cookiesView_ frame]), controlOrigin.y)]; | |
| 1081 | |
| 1082 [self performLayout]; | 1144 [self performLayout]; |
| 1083 } | 1145 } |
| 1084 | 1146 |
| 1085 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList | 1147 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList |
| 1086 andChosenObjects:(ChosenObjectInfoList)chosenObjectInfoList { | 1148 andChosenObjects:(ChosenObjectInfoList)chosenObjectInfoList { |
| 1087 [permissionsView_ setSubviews:[NSArray array]]; | 1149 [permissionsView_ setSubviews:[NSArray array]]; |
| 1088 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); | 1150 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); |
| 1089 | 1151 |
| 1090 permissionsPresent_ = YES; | 1152 permissionsPresent_ = YES; |
| 1091 | 1153 |
| 1092 if (permissionInfoList.size() > 0 || chosenObjectInfoList.size() > 0) { | 1154 if (permissionInfoList.size() > 0 || chosenObjectInfoList.size() > 0) { |
| 1093 base::string16 sectionTitle = | |
| 1094 l10n_util::GetStringUTF16(IDS_PAGE_INFO_TITLE_SITE_PERMISSIONS); | |
| 1095 | |
| 1096 for (const auto& permission : permissionInfoList) { | 1155 for (const auto& permission : permissionInfoList) { |
| 1097 controlOrigin.y += kPermissionsVerticalSpacing; | 1156 controlOrigin.y += kPermissionsVerticalSpacing; |
| 1098 NSPoint rowBottomRight = [self addPermission:permission | 1157 NSPoint rowBottomRight = [self addPermission:permission |
| 1099 toView:permissionsView_ | 1158 toView:permissionsView_ |
| 1100 atPoint:controlOrigin]; | 1159 atPoint:controlOrigin]; |
| 1101 controlOrigin.y = rowBottomRight.y; | 1160 controlOrigin.y = rowBottomRight.y; |
| 1102 } | 1161 } |
| 1103 | 1162 |
| 1104 for (auto& object : chosenObjectInfoList) { | 1163 for (auto& object : chosenObjectInfoList) { |
| 1105 controlOrigin.y += kPermissionsVerticalSpacing; | 1164 controlOrigin.y += kPermissionsVerticalSpacing; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) { | 1253 void PageInfoUIBridge::SetCookieInfo(const CookieInfoList& cookie_info_list) { |
| 1195 [bubble_controller_ setCookieInfo:cookie_info_list]; | 1254 [bubble_controller_ setCookieInfo:cookie_info_list]; |
| 1196 } | 1255 } |
| 1197 | 1256 |
| 1198 void PageInfoUIBridge::SetPermissionInfo( | 1257 void PageInfoUIBridge::SetPermissionInfo( |
| 1199 const PermissionInfoList& permission_info_list, | 1258 const PermissionInfoList& permission_info_list, |
| 1200 ChosenObjectInfoList chosen_object_info_list) { | 1259 ChosenObjectInfoList chosen_object_info_list) { |
| 1201 [bubble_controller_ setPermissionInfo:permission_info_list | 1260 [bubble_controller_ setPermissionInfo:permission_info_list |
| 1202 andChosenObjects:std::move(chosen_object_info_list)]; | 1261 andChosenObjects:std::move(chosen_object_info_list)]; |
| 1203 } | 1262 } |
| OLD | NEW |