Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 52 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 53 #include "ui/resources/grit/ui_resources.h" | 53 #include "ui/resources/grit/ui_resources.h" |
| 54 | 54 |
| 55 using ChosenObjectInfoPtr = | 55 using ChosenObjectInfoPtr = |
| 56 std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo>; | 56 std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo>; |
| 57 using ChosenObjectDeleteCallback = | 57 using ChosenObjectDeleteCallback = |
| 58 base::Callback<void(const WebsiteSettingsUI::ChosenObjectInfo&)>; | 58 base::Callback<void(const WebsiteSettingsUI::ChosenObjectInfo&)>; |
| 59 | 59 |
| 60 namespace { | 60 namespace { |
| 61 | 61 |
| 62 // The default width of the window, in view coordinates. It may be larger to | |
| 63 // fit the content. | |
| 64 const CGFloat kDefaultWindowWidth = 310; | |
| 65 | |
| 66 // Padding between the window frame and content. | |
| 67 const CGFloat kFramePadding = 20; | |
| 68 | |
| 69 // Padding between the window frame and content. | |
| 70 const CGFloat kVerticalSectionMargin = 16; | |
| 71 | |
| 72 // Padding between the window frame and content for the internal page bubble. | |
| 73 const CGFloat kInternalPageFramePadding = 10; | |
| 74 | |
| 75 // Spacing between the identity field and the security summary. | |
| 76 const CGFloat kSpacingBeforeSecuritySummary = 2; | |
| 77 | |
| 78 // Spacing between the security summary and the reset decisions button. | |
| 79 const CGFloat kSpacingBeforeResetDecisionsButton = 8; | |
| 80 | |
| 81 // Spacing between parts of the site settings section. | |
| 82 const CGFloat kSiteSettingsSectionSpacing = 2; | |
| 83 | |
| 84 // Spacing between the image and text for internal pages. | |
| 85 const CGFloat kInternalPageImageSpacing = 10; | |
| 86 | |
| 87 // Square size of the permission images. | |
| 88 const CGFloat kPermissionImageSize = 19; | |
| 89 | |
| 90 // Square size of the permission delete button image. | |
| 91 const CGFloat kPermissionDeleteImageSize = 16; | |
| 92 | |
| 93 // Vertical adjustment for the permission images. They have an extra pixel of | |
| 94 // padding on the bottom edge. | |
| 95 const CGFloat kPermissionImageYAdjust = 1; | |
| 96 | |
| 97 // Spacing between a permission image and the text. | |
| 98 const CGFloat kPermissionImageSpacing = 3; | |
| 99 | |
| 100 // The spacing between individual items in the Permissions tab. | |
| 101 const CGFloat kPermissionsTabSpacing = 12; | |
| 102 | |
| 103 // Extra spacing after a headline on the Permissions tab. | |
| 104 const CGFloat kPermissionsHeadlineSpacing = 2; | |
| 105 | |
| 106 // The amount of horizontal space between a permission label and the popup. | |
| 107 const CGFloat kPermissionPopUpXSpacing = 3; | |
| 108 | |
| 109 // The amount of padding to *remove* when placing | |
| 110 // |IDS_WEBSITE_SETTINGS_{FIRST,THIRD}_PARTY_SITE_DATA| next to each other. | |
| 111 const CGFloat kTextLabelXPadding = 5; | |
| 112 | |
| 113 // NOTE: This assumes that there will never be more than one website settings | 62 // NOTE: This assumes that there will never be more than one website settings |
| 114 // popup shown, and that the one that is shown is associated with the current | 63 // popup shown, and that the one that is shown is associated with the current |
| 115 // window. This matches the behaviour in views: see WebsiteSettingsPopupView. | 64 // window. This matches the behaviour in views: see WebsiteSettingsPopupView. |
| 116 bool g_is_popup_showing = false; | 65 bool g_is_popup_showing = false; |
| 117 | 66 |
| 67 /**************** General ****************/ | |
| 68 | |
| 69 // The default width of the window, in view coordinates. It may be larger to | |
| 70 // fit the content. | |
| 71 const CGFloat kDefaultWindowWidth = 320; | |
| 72 | |
| 73 // Padding around each section | |
| 74 const CGFloat kSectionVerticalPadding = 20; | |
| 75 const CGFloat kSectionHorizontalPadding = 16; | |
| 76 | |
| 77 /**************** Security Section ****************/ | |
| 78 | |
| 79 // Tweak to move the security summary up. | |
| 80 const CGFloat kSecuritySummaryYAdjustment = -6; | |
| 81 | |
| 82 // Spacing between security summary, security details, and cert decisions text. | |
| 83 const CGFloat kSecurityParagraphSpacing = 12; | |
| 84 | |
| 85 /**************** Site Settings Section ****************/ | |
| 86 | |
| 87 // The amount of padding to *remove* when placing | |
| 88 // |IDS_WEBSITE_SETTINGS_{FIRST,THIRD}_PARTY_SITE_DATA| next to each other. | |
| 89 const CGFloat kCookieCountXAdjustment = 5; | |
| 90 | |
| 91 // Square size of the permission images. | |
| 92 const CGFloat kPermissionImageSize = 16; | |
| 93 | |
| 94 // Spacing between a permission image and the text. | |
| 95 const CGFloat kPermissionImageSpacing = 6; | |
| 96 | |
| 97 // Square size of the permission delete button image. | |
| 98 const CGFloat kPermissionDeleteImageSize = 16; | |
| 99 | |
| 100 // The spacing between individual permissions. | |
| 101 const CGFloat kPermissionsVerticalSpacing = 16; | |
| 102 | |
| 103 // Amount to lower each permission popup button to make its text align with the | |
| 104 // permission label. | |
| 105 const CGFloat kPermissionPopupButtonYAdjustment = 3; | |
| 106 | |
| 107 /**************** Internal Page Bubble ****************/ | |
| 108 | |
| 109 // Padding between the window frame and content for the internal page bubble. | |
| 110 const CGFloat kInternalPageFramePadding = 10; | |
| 111 | |
| 112 // Spacing between the image and text for internal pages. | |
| 113 const CGFloat kInternalPageImageSpacing = 10; | |
| 114 | |
| 118 // Takes in the parent window, which should be a BrowserWindow, and gets the | 115 // Takes in the parent window, which should be a BrowserWindow, and gets the |
| 119 // proper anchor point for the bubble. The returned point is in screen | 116 // proper anchor point for the bubble. The returned point is in screen |
| 120 // coordinates. | 117 // coordinates. |
| 121 NSPoint AnchorPointForWindow(NSWindow* parent) { | 118 NSPoint AnchorPointForWindow(NSWindow* parent) { |
| 122 BrowserWindowController* controller = [parent windowController]; | 119 BrowserWindowController* controller = [parent windowController]; |
| 123 NSPoint origin = NSZeroPoint; | 120 NSPoint origin = NSZeroPoint; |
| 124 if ([controller isKindOfClass:[BrowserWindowController class]]) { | 121 if ([controller isKindOfClass:[BrowserWindowController class]]) { |
| 125 LocationBarViewMac* location_bar = [controller locationBarBridge]; | 122 LocationBarViewMac* location_bar = [controller locationBarBridge]; |
| 126 if (location_bar) { | 123 if (location_bar) { |
| 127 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint(); | 124 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint(); |
| 128 origin = ui::ConvertPointFromWindowToScreen(parent, bubble_point); | 125 origin = ui::ConvertPointFromWindowToScreen(parent, bubble_point); |
| 129 } | 126 } |
| 130 } | 127 } |
| 131 return origin; | 128 return origin; |
| 132 } | 129 } |
| 133 | 130 |
| 131 // Copied from omnibox_view_mac.mm | |
| 132 NSColor* ColorWithRGBBytes(int rr, int gg, int bb) { | |
| 133 DCHECK_LE(rr, 255); | |
| 134 DCHECK_LE(bb, 255); | |
| 135 DCHECK_LE(gg, 255); | |
| 136 return [NSColor colorWithCalibratedRed:static_cast<float>(rr) / 255.0 | |
| 137 green:static_cast<float>(gg) / 255.0 | |
| 138 blue:static_cast<float>(bb) / 255.0 | |
| 139 alpha:1.0]; | |
| 140 } | |
| 141 | |
| 134 } // namespace | 142 } // namespace |
| 135 | 143 |
| 136 @interface ChosenObjectDeleteButton : HoverImageButton { | 144 @interface ChosenObjectDeleteButton : HoverImageButton { |
| 137 @private | 145 @private |
| 138 ChosenObjectInfoPtr objectInfo_; | 146 ChosenObjectInfoPtr objectInfo_; |
| 139 ChosenObjectDeleteCallback callback_; | 147 ChosenObjectDeleteCallback callback_; |
| 140 } | 148 } |
| 141 | 149 |
| 142 // Designated initializer. Takes ownership of |objectInfo|. | 150 // Designated initializer. Takes ownership of |objectInfo|. |
| 143 - (instancetype)initWithChosenObject:(ChosenObjectInfoPtr)objectInfo | 151 - (instancetype)initWithChosenObject:(ChosenObjectInfoPtr)objectInfo |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 // results when the image, at 26x26, was taller than (or just slightly | 281 // results when the image, at 26x26, was taller than (or just slightly |
| 274 // shorter) than the text, but produced incorrect results once the icon | 282 // shorter) than the text, but produced incorrect results once the icon |
| 275 // shrank to 16x16. The icon should now always be shorter than the text. | 283 // shrank to 16x16. The icon should now always be shorter than the text. |
| 276 // See crbug.com/572044 . | 284 // See crbug.com/572044 . |
| 277 NSRect textFrame = [textField frame]; | 285 NSRect textFrame = [textField frame]; |
| 278 imageFrame.origin.y += (NSHeight(textFrame) - NSHeight(imageFrame)) / 2; | 286 imageFrame.origin.y += (NSHeight(textFrame) - NSHeight(imageFrame)) / 2; |
| 279 [imageView setFrame:imageFrame]; | 287 [imageView setFrame:imageFrame]; |
| 280 | 288 |
| 281 // Adjust the contentView to fit everything. | 289 // Adjust the contentView to fit everything. |
| 282 CGFloat maxY = std::max(NSMaxY(imageFrame), NSMaxY(textFrame)); | 290 CGFloat maxY = std::max(NSMaxY(imageFrame), NSMaxY(textFrame)); |
| 283 [contentView_ setFrame:NSMakeRect( | 291 [contentView_ setFrame:NSMakeRect(0, 0, [self defaultWindowWidth], |
| 284 0, 0, [self defaultWindowWidth], maxY + kInternalPageFramePadding)]; | 292 maxY + kInternalPageFramePadding)]; |
| 285 | 293 |
| 286 [self sizeAndPositionWindow]; | 294 [self sizeAndPositionWindow]; |
| 287 } | 295 } |
| 288 | 296 |
| 289 // Create the subviews for the website settings bubble. | 297 // Create the subviews for the website settings bubble. |
| 290 - (void)initializeContents { | 298 - (void)initializeContents { |
| 291 securitySectionView_ = [self addSecuritySectionToView:contentView_]; | 299 securitySectionView_ = [self addSecuritySectionToView:contentView_]; |
| 292 separatorAfterSecuritySection_ = [self addSeparatorToView:contentView_]; | 300 separatorAfterSecuritySection_ = [self addSeparatorToView:contentView_]; |
| 293 siteSettingsSectionView_ = [self addSiteSettingsSectionToView:contentView_]; | 301 siteSettingsSectionView_ = [self addSiteSettingsSectionToView:contentView_]; |
| 294 | 302 |
| 295 [self performLayout]; | 303 [self performLayout]; |
| 296 } | 304 } |
| 297 | 305 |
| 298 // Create and return a subview for the security section and add it to the given | 306 // Create and return a subview for the security section and add it to the given |
| 299 // |superview|. |superview| retains the new view. | 307 // |superview|. |superview| retains the new view. |
| 300 - (NSView*)addSecuritySectionToView:(NSView*)superview { | 308 - (NSView*)addSecuritySectionToView:(NSView*)superview { |
| 301 base::scoped_nsobject<NSView> securitySectionView( | 309 base::scoped_nsobject<NSView> securitySectionView( |
| 302 [[FlippedView alloc] initWithFrame:[superview frame]]); | 310 [[FlippedView alloc] initWithFrame:[superview frame]]); |
| 303 [superview addSubview:securitySectionView]; | 311 [superview addSubview:securitySectionView]; |
| 304 | 312 |
| 305 // Create a controlOrigin to place the text fields. The y value doesn't | 313 // Create a controlOrigin to place the text fields. The y value doesn't |
| 306 // matter, because the correct value is calculated in -performLayout. | 314 // matter, because the correct value is calculated in -performLayout. |
| 307 NSPoint controlOrigin = NSMakePoint(kFramePadding, 0); | 315 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); |
| 308 | |
| 309 // Create a text field (empty for now) to show the site identity. | |
| 310 identityField_ = [self addText:base::string16() | |
| 311 withSize:[NSFont systemFontSize] | |
| 312 bold:YES | |
| 313 toView:securitySectionView | |
| 314 atPoint:controlOrigin]; | |
| 315 | 316 |
| 316 // Create a text field for the security summary (private/not private/etc.). | 317 // Create a text field for the security summary (private/not private/etc.). |
| 317 securitySummaryField_ = [self addText:base::string16() | 318 securitySummaryField_ = [self addText:base::string16() |
| 319 withSize:[NSFont systemFontSize] | |
| 320 bold:NO | |
| 321 toView:securitySectionView | |
| 322 atPoint:controlOrigin]; | |
| 323 | |
| 324 securityDetailsField_ = [self addText:base::string16() | |
| 318 withSize:[NSFont smallSystemFontSize] | 325 withSize:[NSFont smallSystemFontSize] |
| 319 bold:NO | 326 bold:NO |
| 320 toView:securitySectionView | 327 toView:securitySectionView |
| 321 atPoint:controlOrigin]; | 328 atPoint:controlOrigin]; |
| 322 | 329 |
| 323 resetDecisionsButton_ = nil; // This will be created only if necessary. | 330 // These will be created only if necessary. |
| 331 resetDecisionsField_ = nil; | |
| 332 resetDecisionsButton_ = nil; | |
| 324 | 333 |
| 325 NSString* securityDetailsButtonText = | 334 NSString* securityDetailsButtonText = |
| 326 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_DETAILS_LINK); | 335 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_DETAILS_LINK); |
| 327 // Note: The security details button may be removed from the superview in | 336 // Note: The security details button may be removed from the superview in |
| 328 // -performLayout in order to hide it (depending on the connection). | 337 // -performLayout in order to hide it (depending on the connection). |
| 329 securityDetailsButton_ = [self addLinkButtonWithText:securityDetailsButtonText | 338 securityDetailsButton_ = [self addLinkButtonWithText:securityDetailsButtonText |
| 330 toView:securitySectionView]; | 339 toView:securitySectionView]; |
| 331 [securityDetailsButton_ setTarget:self]; | 340 [securityDetailsButton_ setTarget:self]; |
| 332 [securityDetailsButton_ setAction:@selector(showSecurityDetails:)]; | 341 [securityDetailsButton_ setAction:@selector(showSecurityDetails:)]; |
| 333 | 342 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 351 permissionsView_ = | 360 permissionsView_ = |
| 352 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; | 361 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; |
| 353 [siteSettingsSectionView addSubview:permissionsView_]; | 362 [siteSettingsSectionView addSubview:permissionsView_]; |
| 354 | 363 |
| 355 // Create the link button to view site settings. Its position will be set in | 364 // Create the link button to view site settings. Its position will be set in |
| 356 // performLayout. | 365 // performLayout. |
| 357 NSString* siteSettingsButtonText = | 366 NSString* siteSettingsButtonText = |
| 358 l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK); | 367 l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK); |
| 359 siteSettingsButton_ = [self addLinkButtonWithText:siteSettingsButtonText | 368 siteSettingsButton_ = [self addLinkButtonWithText:siteSettingsButtonText |
| 360 toView:siteSettingsSectionView]; | 369 toView:siteSettingsSectionView]; |
| 370 NSFont* font = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]]; | |
| 371 [siteSettingsButton_ setFont:font]; | |
| 372 [GTMUILocalizerAndLayoutTweaker sizeToFitView:siteSettingsButton_]; | |
| 373 | |
| 361 [siteSettingsButton_ setTarget:self]; | 374 [siteSettingsButton_ setTarget:self]; |
| 362 [siteSettingsButton_ setAction:@selector(showSiteSettingsData:)]; | 375 [siteSettingsButton_ setAction:@selector(showSiteSettingsData:)]; |
| 363 | 376 |
| 364 return siteSettingsSectionView.get(); | 377 return siteSettingsSectionView.get(); |
| 365 } | 378 } |
| 366 | 379 |
| 367 // Handler for the link button below the list of cookies. | 380 // Handler for the link button below the list of cookies. |
| 368 - (void)showCookiesAndSiteData:(id)sender { | 381 - (void)showCookiesAndSiteData:(id)sender { |
| 369 DCHECK(webContents_); | 382 DCHECK(webContents_); |
| 370 DCHECK(presenter_); | 383 DCHECK(presenter_); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 | 456 |
| 444 // Set the width of the content view now, so that all the text fields will | 457 // Set the width of the content view now, so that all the text fields will |
| 445 // be sized to fit before their heights and vertical positions are adjusted. | 458 // be sized to fit before their heights and vertical positions are adjusted. |
| 446 [self setWidthOfView:contentView_ to:contentWidth]; | 459 [self setWidthOfView:contentView_ to:contentWidth]; |
| 447 [self setWidthOfView:securitySectionView_ to:contentWidth]; | 460 [self setWidthOfView:securitySectionView_ to:contentWidth]; |
| 448 [self setWidthOfView:siteSettingsSectionView_ to:contentWidth]; | 461 [self setWidthOfView:siteSettingsSectionView_ to:contentWidth]; |
| 449 | 462 |
| 450 CGFloat yPos = info_bubble::kBubbleArrowHeight; | 463 CGFloat yPos = info_bubble::kBubbleArrowHeight; |
| 451 | 464 |
| 452 [self layoutSecuritySection]; | 465 [self layoutSecuritySection]; |
| 453 yPos = [self setYPositionOfView:securitySectionView_ to:yPos + kFramePadding]; | 466 yPos = [self setYPositionOfView:securitySectionView_ to:yPos]; |
| 454 | 467 |
| 455 yPos = [self setYPositionOfView:separatorAfterSecuritySection_ | 468 yPos = [self setYPositionOfView:separatorAfterSecuritySection_ |
| 456 to:yPos + kVerticalSectionMargin]; | 469 to:yPos + kSectionHorizontalPadding]; |
| 457 | 470 |
| 458 [self layoutSiteSettingsSection]; | 471 [self layoutSiteSettingsSection]; |
| 459 yPos = [self setYPositionOfView:siteSettingsSectionView_ | 472 yPos = [self setYPositionOfView:siteSettingsSectionView_ |
| 460 to:yPos + kVerticalSectionMargin]; | 473 to:yPos + kSectionHorizontalPadding]; |
| 461 | 474 |
| 462 [contentView_ setFrame:NSMakeRect(0, 0, NSWidth([contentView_ frame]), | 475 [contentView_ setFrame:NSMakeRect(0, 0, NSWidth([contentView_ frame]), |
| 463 yPos + kFramePadding)]; | 476 yPos + kSectionVerticalPadding)]; |
| 464 | 477 |
| 465 [self sizeAndPositionWindow]; | 478 [self sizeAndPositionWindow]; |
| 466 } | 479 } |
| 467 | 480 |
| 468 - (void)layoutSecuritySection { | 481 - (void)layoutSecuritySection { |
| 469 // Start the layout with the first element. Margins are handled by the caller. | 482 // Start the layout with the first element. Margins are handled by the caller. |
| 470 CGFloat yPos = 0; | 483 CGFloat yPos = 0; |
| 471 | 484 |
| 472 [self sizeTextFieldHeightToFit:identityField_]; | |
| 473 yPos = [self setYPositionOfView:identityField_ to:yPos]; | |
| 474 | |
| 475 [self sizeTextFieldHeightToFit:securitySummaryField_]; | 485 [self sizeTextFieldHeightToFit:securitySummaryField_]; |
| 476 yPos = [self setYPositionOfView:securitySummaryField_ | 486 yPos = [self setYPositionOfView:securitySummaryField_ |
| 477 to:yPos + kSpacingBeforeSecuritySummary]; | 487 to:yPos + kSectionVerticalPadding + |
| 488 kSecuritySummaryYAdjustment]; | |
| 489 | |
| 490 [self sizeTextFieldHeightToFit:securityDetailsField_]; | |
| 491 yPos = [self setYPositionOfView:securityDetailsField_ | |
| 492 to:yPos + kSecurityParagraphSpacing]; | |
| 478 | 493 |
| 479 if (isDevToolsDisabled_ && certificateId_ == 0) { | 494 if (isDevToolsDisabled_ && certificateId_ == 0) { |
| 480 // -removeFromSuperview is idempotent. | 495 // -removeFromSuperview is idempotent. |
| 481 [securityDetailsButton_ removeFromSuperview]; | 496 [securityDetailsButton_ removeFromSuperview]; |
| 482 } else { | 497 } else { |
| 483 // -addSubview is idempotent. | 498 // -addSubview is idempotent. |
| 484 [securitySectionView_ addSubview:securityDetailsButton_]; | 499 [securitySectionView_ addSubview:securityDetailsButton_]; |
| 485 yPos = [self setYPositionOfView:securityDetailsButton_ to:yPos]; | 500 yPos = [self setYPositionOfView:securityDetailsButton_ to:yPos]; |
| 486 } | 501 } |
| 487 | 502 |
| 488 if (resetDecisionsButton_) { | 503 if (resetDecisionsButton_) { |
| 489 yPos = [self setYPositionOfView:resetDecisionsButton_ | 504 DCHECK(resetDecisionsField_); |
| 490 to:yPos + kSpacingBeforeResetDecisionsButton]; | 505 yPos = [self setYPositionOfView:resetDecisionsField_ |
| 506 to:yPos + kSecurityParagraphSpacing]; | |
| 507 yPos = [self setYPositionOfView:resetDecisionsButton_ to:yPos]; | |
| 491 } | 508 } |
| 492 | 509 |
| 493 // Resize the height based on contents. | 510 // Resize the height based on contents. |
| 494 [self setHeightOfView:securitySectionView_ to:yPos]; | 511 [self setHeightOfView:securitySectionView_ to:yPos]; |
| 495 } | 512 } |
| 496 | 513 |
| 497 - (void)layoutSiteSettingsSection { | 514 - (void)layoutSiteSettingsSection { |
| 498 // Start the layout with the first element. Margins are handled by the caller. | 515 // Start the layout with the first element. Margins are handled by the caller. |
| 499 CGFloat yPos = 0; | 516 CGFloat yPos = 0; |
| 500 | 517 |
| 501 yPos = [self setYPositionOfView:cookiesView_ to:yPos]; | 518 yPos = [self setYPositionOfView:cookiesView_ to:yPos]; |
| 502 | 519 |
| 503 if (permissionsPresent_) { | 520 if (permissionsPresent_) { |
| 504 // Put the permission info just below the link button. | 521 // Put the permission info just below the link button. |
| 505 yPos = [self setYPositionOfView:permissionsView_ | 522 yPos = [self setYPositionOfView:permissionsView_ to:yPos]; |
| 506 to:yPos + kSiteSettingsSectionSpacing]; | |
| 507 } | 523 } |
| 508 | 524 |
| 509 // Put the link button for site settings just below the permissions. | 525 // Put the link button for site settings just below the permissions. |
| 510 // TODO(lgarron): set the position of this based on RTL/LTR. | 526 // TODO(lgarron): set the position of this based on RTL/LTR. |
| 511 // http://code.google.com/p/chromium/issues/detail?id=525304 | 527 // http://code.google.com/p/chromium/issues/detail?id=525304 |
| 512 yPos += kSiteSettingsSectionSpacing; | 528 CGFloat xPos = kDefaultWindowWidth - kSectionVerticalPadding - |
| 513 [siteSettingsButton_ setFrameOrigin:NSMakePoint(kFramePadding, yPos)]; | 529 NSWidth([siteSettingsButton_ frame]); |
| 530 [siteSettingsButton_ setFrameOrigin:NSMakePoint(xPos, yPos)]; | |
| 514 yPos = NSMaxY([siteSettingsButton_ frame]); | 531 yPos = NSMaxY([siteSettingsButton_ frame]); |
| 515 | 532 |
| 516 // Resize the height based on contents. | 533 // Resize the height based on contents. |
| 517 [self setHeightOfView:siteSettingsSectionView_ to:yPos]; | 534 [self setHeightOfView:siteSettingsSectionView_ to:yPos]; |
| 518 } | 535 } |
| 519 | 536 |
| 520 // Adjust the size of the window to match the size of the content, and position | 537 // Adjust the size of the window to match the size of the content, and position |
| 521 // the bubble anchor appropriately. | 538 // the bubble anchor appropriately. |
| 522 - (void)sizeAndPositionWindow { | 539 - (void)sizeAndPositionWindow { |
| 523 NSRect windowFrame = [contentView_ frame]; | 540 NSRect windowFrame = [contentView_ frame]; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 | 575 |
| 559 // Create a new text field and add it to the given array of subviews. | 576 // Create a new text field and add it to the given array of subviews. |
| 560 // The array will retain a reference to the object. | 577 // The array will retain a reference to the object. |
| 561 - (NSTextField*)addText:(const base::string16&)text | 578 - (NSTextField*)addText:(const base::string16&)text |
| 562 withSize:(CGFloat)fontSize | 579 withSize:(CGFloat)fontSize |
| 563 bold:(BOOL)bold | 580 bold:(BOOL)bold |
| 564 toView:(NSView*)view | 581 toView:(NSView*)view |
| 565 atPoint:(NSPoint)point { | 582 atPoint:(NSPoint)point { |
| 566 // Size the text to take up the full available width, with some padding. | 583 // Size the text to take up the full available width, with some padding. |
| 567 // The height is arbitrary as it will be adjusted later. | 584 // The height is arbitrary as it will be adjusted later. |
| 568 CGFloat width = NSWidth([view frame]) - point.x - kFramePadding; | 585 CGFloat width = NSWidth([view frame]) - point.x - kSectionHorizontalPadding; |
| 569 NSRect frame = NSMakeRect(point.x, point.y, width, 100); | 586 NSRect frame = NSMakeRect(point.x, point.y, width, 100); |
| 570 base::scoped_nsobject<NSTextField> textField( | 587 base::scoped_nsobject<NSTextField> textField( |
| 571 [[NSTextField alloc] initWithFrame:frame]); | 588 [[NSTextField alloc] initWithFrame:frame]); |
| 572 [self configureTextFieldAsLabel:textField.get()]; | 589 [self configureTextFieldAsLabel:textField.get()]; |
| 573 [textField setStringValue:base::SysUTF16ToNSString(text)]; | 590 [textField setStringValue:base::SysUTF16ToNSString(text)]; |
| 574 NSFont* font = bold ? [NSFont boldSystemFontOfSize:fontSize] | 591 NSFont* font = bold ? [NSFont boldSystemFontOfSize:fontSize] |
| 575 : [NSFont systemFontOfSize:fontSize]; | 592 : [NSFont systemFontOfSize:fontSize]; |
| 576 [textField setFont:font]; | 593 [textField setFont:font]; |
| 577 [self sizeTextFieldHeightToFit:textField]; | 594 [self sizeTextFieldHeightToFit:textField]; |
| 578 [textField setAutoresizingMask:NSViewWidthSizable]; | 595 [textField setAutoresizingMask:NSViewWidthSizable]; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 598 // Use an arbitrary position; it will be adjusted in performLayout. | 615 // Use an arbitrary position; it will be adjusted in performLayout. |
| 599 NSBox* spacer = [self | 616 NSBox* spacer = [self |
| 600 horizontalSeparatorWithFrame:NSMakeRect(0, 0, NSWidth([view frame]), 0)]; | 617 horizontalSeparatorWithFrame:NSMakeRect(0, 0, NSWidth([view frame]), 0)]; |
| 601 [view addSubview:spacer]; | 618 [view addSubview:spacer]; |
| 602 return spacer; | 619 return spacer; |
| 603 } | 620 } |
| 604 | 621 |
| 605 // Add a link button with the given text to |view|. | 622 // Add a link button with the given text to |view|. |
| 606 - (NSButton*)addLinkButtonWithText:(NSString*)text toView:(NSView*)view { | 623 - (NSButton*)addLinkButtonWithText:(NSString*)text toView:(NSView*)view { |
| 607 // Frame size is arbitrary; it will be adjusted by the layout tweaker. | 624 // Frame size is arbitrary; it will be adjusted by the layout tweaker. |
| 608 NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10); | 625 NSRect frame = NSMakeRect(kSectionHorizontalPadding, 0, 100, 10); |
| 609 base::scoped_nsobject<NSButton> button( | 626 base::scoped_nsobject<NSButton> button( |
| 610 [[NSButton alloc] initWithFrame:frame]); | 627 [[NSButton alloc] initWithFrame:frame]); |
| 611 base::scoped_nsobject<HyperlinkButtonCell> cell( | 628 base::scoped_nsobject<HyperlinkButtonCell> cell( |
| 612 [[HyperlinkButtonCell alloc] initTextCell:text]); | 629 [[HyperlinkButtonCell alloc] initTextCell:text]); |
| 613 [cell setControlSize:NSSmallControlSize]; | 630 [cell setControlSize:NSSmallControlSize]; |
| 614 [button setCell:cell.get()]; | 631 [button setCell:cell.get()]; |
| 615 [button setButtonType:NSMomentaryPushInButton]; | 632 [button setButtonType:NSMomentaryPushInButton]; |
| 616 [button setBezelStyle:NSRegularSquareBezelStyle]; | 633 [button setBezelStyle:NSRegularSquareBezelStyle]; |
| 617 [view addSubview:button.get()]; | 634 [view addSubview:button.get()]; |
| 618 | 635 |
| 619 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; | 636 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; |
| 620 return button.get(); | 637 return button.get(); |
| 621 } | 638 } |
| 622 | 639 |
| 623 // Create and return a button with the specified text and add it to the given | 640 // Create and return a button with the specified text and add it to the given |
| 624 // |view|. |view| retains the new button. | 641 // |view|. |view| retains the new button. |
| 625 - (NSButton*)addButtonWithText:(NSString*)text toView:(NSView*)view { | 642 - (NSButton*)addButtonWithText:(NSString*)text toView:(NSView*)view { |
| 626 NSRect containerFrame = [view frame]; | 643 NSRect containerFrame = [view frame]; |
| 627 // Frame size is arbitrary; it will be adjusted by the layout tweaker. | 644 // Frame size is arbitrary; it will be adjusted by the layout tweaker. |
| 628 NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10); | 645 NSRect frame = NSMakeRect(kSectionHorizontalPadding, 0, 100, 10); |
| 629 base::scoped_nsobject<NSButton> button( | 646 base::scoped_nsobject<NSButton> button( |
| 630 [[NSButton alloc] initWithFrame:frame]); | 647 [[NSButton alloc] initWithFrame:frame]); |
| 631 | 648 |
| 632 // Determine the largest possible size for this button. The size is the width | 649 // Determine the largest possible size for this button. The size is the width |
| 633 // of the connection section minus the padding on both sides minus the | 650 // of the connection section minus the padding on both sides minus the |
| 634 // connection image size and spacing. | 651 // connection image size and spacing. |
| 635 // TODO(lgarron): handle this sizing in -performLayout. | 652 // TODO(lgarron): handle this sizing in -performLayout. |
| 636 CGFloat maxTitleWidth = containerFrame.size.width - kFramePadding * 2; | 653 CGFloat maxTitleWidth = |
| 654 containerFrame.size.width - kSectionHorizontalPadding * 2; | |
| 637 | 655 |
| 638 base::scoped_nsobject<NSButtonCell> cell( | 656 base::scoped_nsobject<NSButtonCell> cell( |
| 639 [[NSButtonCell alloc] initTextCell:text]); | 657 [[NSButtonCell alloc] initTextCell:text]); |
| 640 [button setCell:cell.get()]; | 658 [button setCell:cell.get()]; |
| 641 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; | 659 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; |
| 642 | 660 |
| 643 // Ensure the containing view is large enough to contain the button with its | 661 // Ensure the containing view is large enough to contain the button with its |
| 644 // widest possible title. | 662 // widest possible title. |
| 645 NSRect buttonFrame = [button frame]; | 663 NSRect buttonFrame = [button frame]; |
| 646 buttonFrame.size.width = maxTitleWidth; | 664 buttonFrame.size.width = maxTitleWidth; |
| 647 | 665 |
| 648 [button setFrame:buttonFrame]; | 666 [button setFrame:buttonFrame]; |
| 649 [button setButtonType:NSMomentaryPushInButton]; | 667 [button setButtonType:NSMomentaryPushInButton]; |
| 650 [button setBezelStyle:NSRegularSquareBezelStyle]; | 668 [button setBezelStyle:NSRegularSquareBezelStyle]; |
| 651 [view addSubview:button.get()]; | 669 [view addSubview:button.get()]; |
| 652 | 670 |
| 653 return button.get(); | 671 return button.get(); |
| 654 } | 672 } |
| 655 | 673 |
| 656 // Set the content of the identity and identity status fields. | 674 // Set the content of the identity and identity status fields. |
| 657 - (void)setIdentityInfo:(const WebsiteSettingsUI::IdentityInfo&)identityInfo { | 675 - (void)setIdentityInfo:(const WebsiteSettingsUI::IdentityInfo&)identityInfo { |
| 658 [identityField_ | 676 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = |
| 659 setStringValue:base::SysUTF8ToNSString(identityInfo.site_identity)]; | 677 identityInfo.GetSecurityDescription(); |
| 660 [securitySummaryField_ setStringValue:base::SysUTF16ToNSString( | 678 [securitySummaryField_ |
| 661 identityInfo.GetSecuritySummary())]; | 679 setStringValue:base::SysUTF16ToNSString(security_description->summary)]; |
| 680 | |
| 681 switch (security_description->summary_style) { | |
| 682 case WebsiteSettingsUI::STYLE_DEFAULT: | |
| 683 break; | |
| 684 case WebsiteSettingsUI::STYLE_GREEN: | |
| 685 [securitySummaryField_ setTextColor:ColorWithRGBBytes(0x0B, 0x80, 0x43)]; | |
|
Robert Sesek
2016/06/29 18:22:06
Are these colors going to be the same on Mac and o
lgarron
2016/06/29 20:04:41
Sharing sounds good. iOS seems to have a utility f
Robert Sesek
2016/06/29 20:15:02
Did you check skia_utils_mac.h? ;-)
lgarron
2016/07/08 17:47:08
I didn't find it. ;-)
Thanks for the pointer; I've
| |
| 686 break; | |
| 687 case WebsiteSettingsUI::STYLE_YELLOW: | |
| 688 [securitySummaryField_ setTextColor:ColorWithRGBBytes(0xF1, 0x9D, 0x28)]; | |
| 689 break; | |
| 690 case WebsiteSettingsUI::STYLE_RED: | |
| 691 [securitySummaryField_ setTextColor:ColorWithRGBBytes(0xC5, 0x39, 0x29)]; | |
| 692 break; | |
| 693 } | |
| 694 | |
| 695 [securityDetailsField_ | |
| 696 setStringValue:SysUTF16ToNSString(security_description->details)]; | |
| 662 | 697 |
| 663 certificateId_ = identityInfo.cert_id; | 698 certificateId_ = identityInfo.cert_id; |
| 664 | 699 |
| 665 if (certificateId_ && identityInfo.show_ssl_decision_revoke_button) { | 700 if (certificateId_ && identityInfo.show_ssl_decision_revoke_button) { |
| 666 NSString* text = l10n_util::GetNSString( | 701 resetDecisionsField_ = |
| 667 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON); | 702 [self addText:base::string16() |
| 703 withSize:[NSFont smallSystemFontSize] | |
| 704 bold:NO | |
| 705 toView:securitySectionView_ | |
| 706 atPoint:NSMakePoint(kSectionHorizontalPadding, 0)]; | |
| 707 [resetDecisionsField_ | |
| 708 setStringValue:l10n_util::GetNSString( | |
| 709 IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)]; | |
| 710 [self sizeTextFieldHeightToFit:resetDecisionsField_]; | |
| 711 | |
| 668 resetDecisionsButton_ = | 712 resetDecisionsButton_ = |
| 669 [self addButtonWithText:text toView:securitySectionView_]; | 713 [self addLinkButtonWithText: |
| 714 l10n_util::GetNSString( | |
| 715 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON) | |
| 716 toView:securitySectionView_]; | |
| 670 [resetDecisionsButton_ setTarget:self]; | 717 [resetDecisionsButton_ setTarget:self]; |
| 671 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)]; | 718 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)]; |
| 672 } | 719 } |
| 673 | 720 |
| 674 [self performLayout]; | 721 [self performLayout]; |
| 675 } | 722 } |
| 676 | 723 |
| 677 // Add a pop-up button for |permissionInfo| to the given view. | 724 // Add a pop-up button for |permissionInfo| to the given view. |
| 678 - (NSPopUpButton*)addPopUpButtonForPermission: | 725 - (NSPopUpButton*)addPopUpButtonForPermission: |
| 679 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo | 726 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo |
| 680 toView:(NSView*)view | 727 toView:(NSView*)view |
| 681 atPoint:(NSPoint)point { | 728 atPoint:(NSPoint)point { |
| 682 | 729 |
| 683 GURL url = webContents_ ? webContents_->GetURL() : GURL(); | 730 GURL url = webContents_ ? webContents_->GetURL() : GURL(); |
| 684 __block WebsiteSettingsBubbleController* weakSelf = self; | 731 __block WebsiteSettingsBubbleController* weakSelf = self; |
| 685 PermissionMenuModel::ChangeCallback callback = | 732 PermissionMenuModel::ChangeCallback callback = |
| 686 base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) { | 733 base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) { |
| 687 [weakSelf onPermissionChanged:permission.type to:permission.setting]; | 734 [weakSelf onPermissionChanged:permission.type to:permission.setting]; |
| 688 }); | 735 }); |
| 689 base::scoped_nsobject<PermissionSelectorButton> button( | 736 base::scoped_nsobject<PermissionSelectorButton> button( |
| 690 [[PermissionSelectorButton alloc] initWithPermissionInfo:permissionInfo | 737 [[PermissionSelectorButton alloc] initWithPermissionInfo:permissionInfo |
| 691 forURL:url | 738 forURL:url |
| 692 withCallback:callback]); | 739 withCallback:callback]); |
| 740 | |
| 693 // Determine the largest possible size for this button. | 741 // Determine the largest possible size for this button. |
| 694 CGFloat maxTitleWidth = [button | 742 CGFloat maxTitleWidth = [button |
| 695 maxTitleWidthForContentSettingsType:permissionInfo.type | 743 maxTitleWidthForContentSettingsType:permissionInfo.type |
| 696 withDefaultSetting:permissionInfo.default_setting]; | 744 withDefaultSetting:permissionInfo.default_setting]; |
| 697 | 745 |
| 698 // Ensure the containing view is large enough to contain the button with its | 746 // Ensure the containing view is large enough to contain the button with its |
| 699 // widest possible title. | 747 // widest possible title. |
| 700 NSRect containerFrame = [view frame]; | 748 NSRect containerFrame = [view frame]; |
| 701 containerFrame.size.width = std::max( | 749 containerFrame.size.width = |
| 702 NSWidth(containerFrame), point.x + maxTitleWidth + kFramePadding); | 750 std::max(NSWidth(containerFrame), |
| 751 point.x + maxTitleWidth + kSectionHorizontalPadding); | |
| 703 [view setFrame:containerFrame]; | 752 [view setFrame:containerFrame]; |
| 704 [view addSubview:button.get()]; | 753 [view addSubview:button.get()]; |
| 705 return button.get(); | 754 return button.get(); |
| 706 } | 755 } |
| 707 | 756 |
| 708 // Add a delete button for |objectInfo| to the given view. | 757 // Add a delete button for |objectInfo| to the given view. |
| 709 - (NSButton*)addDeleteButtonForChosenObject:(ChosenObjectInfoPtr)objectInfo | 758 - (NSButton*)addDeleteButtonForChosenObject:(ChosenObjectInfoPtr)objectInfo |
| 710 toView:(NSView*)view | 759 toView:(NSView*)view |
| 711 atPoint:(NSPoint)point { | 760 atPoint:(NSPoint)point { |
| 712 __block WebsiteSettingsBubbleController* weakSelf = self; | 761 __block WebsiteSettingsBubbleController* weakSelf = self; |
| 713 auto callback = | 762 auto callback = |
| 714 base::BindBlock(^(const WebsiteSettingsUI::ChosenObjectInfo& objectInfo) { | 763 base::BindBlock(^(const WebsiteSettingsUI::ChosenObjectInfo& objectInfo) { |
| 715 [weakSelf onChosenObjectDeleted:objectInfo]; | 764 [weakSelf onChosenObjectDeleted:objectInfo]; |
| 716 }); | 765 }); |
| 717 base::scoped_nsobject<ChosenObjectDeleteButton> button( | 766 base::scoped_nsobject<ChosenObjectDeleteButton> button( |
| 718 [[ChosenObjectDeleteButton alloc] | 767 [[ChosenObjectDeleteButton alloc] |
| 719 initWithChosenObject:std::move(objectInfo) | 768 initWithChosenObject:std::move(objectInfo) |
| 720 atPoint:point | 769 atPoint:point |
| 721 withCallback:callback]); | 770 withCallback:callback]); |
| 722 | 771 |
| 723 // Ensure the containing view is large enough to contain the button. | 772 // Ensure the containing view is large enough to contain the button. |
| 724 NSRect containerFrame = [view frame]; | 773 NSRect containerFrame = [view frame]; |
| 725 containerFrame.size.width = | 774 containerFrame.size.width = |
| 726 std::max(NSWidth(containerFrame), | 775 std::max(NSWidth(containerFrame), point.x + kPermissionDeleteImageSize + |
| 727 point.x + kPermissionDeleteImageSize + kFramePadding); | 776 kSectionHorizontalPadding); |
| 728 [view setFrame:containerFrame]; | 777 [view setFrame:containerFrame]; |
| 729 [view addSubview:button.get()]; | 778 [view addSubview:button.get()]; |
| 730 return button.get(); | 779 return button.get(); |
| 731 } | 780 } |
| 732 | 781 |
| 733 // Called when the user changes the setting of a permission. | 782 // Called when the user changes the setting of a permission. |
| 734 - (void)onPermissionChanged:(ContentSettingsType)permissionType | 783 - (void)onPermissionChanged:(ContentSettingsType)permissionType |
| 735 to:(ContentSetting)newSetting { | 784 to:(ContentSetting)newSetting { |
| 736 if (presenter_) | 785 if (presenter_) |
| 737 presenter_->OnSitePermissionChanged(permissionType, newSetting); | 786 presenter_->OnSitePermissionChanged(permissionType, newSetting); |
| 738 } | 787 } |
| 739 | 788 |
| 740 // Called when the user revokes permission for a previously chosen object. | 789 // Called when the user revokes permission for a previously chosen object. |
| 741 - (void)onChosenObjectDeleted:(const WebsiteSettingsUI::ChosenObjectInfo&)info { | 790 - (void)onChosenObjectDeleted:(const WebsiteSettingsUI::ChosenObjectInfo&)info { |
| 742 if (presenter_) | 791 if (presenter_) |
| 743 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); | 792 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); |
| 744 } | 793 } |
| 745 | 794 |
| 746 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the | 795 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the |
| 747 // last UI element added (either the permission button, in LTR, or the text | 796 // last UI element added (either the permission button, in LTR, or the text |
| 748 // label, in RTL). | 797 // label, in RTL). |
| 749 - (NSPoint)addPermission: | 798 - (NSPoint)addPermission: |
| 750 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo | 799 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo |
| 751 toView:(NSView*)view | 800 toView:(NSView*)view |
| 752 atPoint:(NSPoint)point { | 801 atPoint:(NSPoint)point { |
| 753 base::string16 labelText = | 802 base::string16 labelText = |
| 754 WebsiteSettingsUI::PermissionTypeToUIString(permissionInfo.type) + | 803 WebsiteSettingsUI::PermissionTypeToUIString(permissionInfo.type); |
| 755 base::ASCIIToUTF16(":"); | |
| 756 bool isRTL = | 804 bool isRTL = |
| 757 base::i18n::RIGHT_TO_LEFT == base::i18n::GetStringDirection(labelText); | 805 base::i18n::RIGHT_TO_LEFT == base::i18n::GetStringDirection(labelText); |
| 758 base::scoped_nsobject<NSImage> image( | 806 base::scoped_nsobject<NSImage> image( |
| 759 [WebsiteSettingsUI::GetPermissionIcon(permissionInfo).ToNSImage() | 807 [WebsiteSettingsUI::GetPermissionIcon(permissionInfo).ToNSImage() |
| 760 retain]); | 808 retain]); |
| 761 | 809 |
| 762 NSPoint position; | 810 NSPoint position; |
| 763 NSImageView* imageView; | 811 NSImageView* imageView; |
| 764 NSPopUpButton* button; | 812 NSPopUpButton* button; |
| 765 NSTextField* label; | 813 NSTextField* label; |
| 766 | 814 |
| 767 CGFloat viewWidth = NSWidth([view frame]); | 815 CGFloat viewWidth = NSWidth([view frame]); |
| 768 | 816 |
| 769 if (isRTL) { | 817 if (isRTL) { |
| 770 point.x = NSWidth([view frame]) - kPermissionImageSize - | 818 point.x = NSWidth([view frame]) - kPermissionImageSize - |
| 771 kPermissionImageSpacing - kFramePadding; | 819 kPermissionImageSpacing - kSectionHorizontalPadding; |
| 772 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; | 820 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; |
| 773 [imageView setImage:image]; | 821 [imageView setImage:image]; |
| 774 point.x -= kPermissionImageSpacing; | 822 point.x -= kPermissionImageSpacing; |
| 775 | 823 |
| 776 label = [self addText:labelText | 824 label = [self addText:labelText |
| 777 withSize:[NSFont smallSystemFontSize] | 825 withSize:[NSFont systemFontSize] |
| 778 bold:NO | 826 bold:NO |
| 779 toView:view | 827 toView:view |
| 780 atPoint:point]; | 828 atPoint:point]; |
| 781 [label sizeToFit]; | 829 [label sizeToFit]; |
| 782 point.x -= NSWidth([label frame]); | 830 point.x -= NSWidth([label frame]); |
| 783 [label setFrameOrigin:point]; | 831 [label setFrameOrigin:point]; |
| 784 | 832 |
| 785 position = NSMakePoint(point.x, point.y); | 833 position = |
| 834 NSMakePoint(point.x, point.y + kPermissionPopupButtonYAdjustment); | |
| 786 button = [self addPopUpButtonForPermission:permissionInfo | 835 button = [self addPopUpButtonForPermission:permissionInfo |
| 787 toView:view | 836 toView:view |
| 788 atPoint:position]; | 837 atPoint:position]; |
| 789 position.x -= NSWidth([button frame]); | 838 position.x -= NSWidth([button frame]); |
| 790 [button setFrameOrigin:position]; | 839 [button setFrameOrigin:position]; |
| 791 } else { | 840 } else { |
| 792 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; | 841 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; |
| 793 [imageView setImage:image]; | 842 [imageView setImage:image]; |
| 794 point.x += kPermissionImageSize + kPermissionImageSpacing; | 843 point.x += kPermissionImageSize + kPermissionImageSpacing; |
| 795 | 844 |
| 796 label = [self addText:labelText | 845 label = [self addText:labelText |
| 797 withSize:[NSFont smallSystemFontSize] | 846 withSize:[NSFont systemFontSize] |
| 798 bold:NO | 847 bold:NO |
| 799 toView:view | 848 toView:view |
| 800 atPoint:point]; | 849 atPoint:point]; |
| 801 [label sizeToFit]; | 850 [label sizeToFit]; |
| 802 | 851 |
| 803 position = NSMakePoint(NSMaxX([label frame]), point.y); | 852 position = NSMakePoint(NSMaxX([label frame]), |
| 853 point.y + kPermissionPopupButtonYAdjustment); | |
| 854 | |
| 804 button = [self addPopUpButtonForPermission:permissionInfo | 855 button = [self addPopUpButtonForPermission:permissionInfo |
| 805 toView:view | 856 toView:view |
| 806 atPoint:position]; | 857 atPoint:position]; |
| 807 } | 858 } |
| 808 | 859 |
| 809 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; | 860 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; |
| 810 | 861 |
| 811 // Adjust the vertical position of the button so that its title text is | 862 // Adjust the vertical position of the button so that its title text is |
| 812 // aligned with the label. Assumes that the text is the same size in both. | 863 // aligned with the label. Assumes that the text is the same size in both. |
| 813 // Also adjust the horizontal position to remove excess space due to the | 864 // Also adjust the horizontal position to remove excess space due to the |
| 814 // invisible bezel. | 865 // invisible bezel. |
| 815 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; | 866 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; |
| 816 if (isRTL) { | 867 if (isRTL) { |
| 817 position.x += kPermissionPopUpXSpacing; | 868 position.x = kSectionHorizontalPadding; |
| 818 } else { | 869 } else { |
| 819 position.x -= titleRect.origin.x - kPermissionPopUpXSpacing; | 870 position.x = kDefaultWindowWidth - kSectionHorizontalPadding - |
| 871 [button frame].size.width; | |
| 820 } | 872 } |
| 821 position.y -= titleRect.origin.y; | 873 position.y -= titleRect.origin.y; |
| 822 [button setFrameOrigin:position]; | 874 [button setFrameOrigin:position]; |
| 823 | 875 |
| 824 // Align the icon with the text. | 876 // Align the icon with the text. |
| 825 [self alignPermissionIcon:imageView withTextField:label]; | 877 [self alignPermissionIcon:imageView withTextField:label]; |
| 826 | 878 |
| 827 // Permissions specified by policy or an extension cannot be changed. | 879 // Permissions specified by policy or an extension cannot be changed. |
| 828 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || | 880 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || |
| 829 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { | 881 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 851 | 903 |
| 852 NSPoint position; | 904 NSPoint position; |
| 853 NSImageView* imageView; | 905 NSImageView* imageView; |
| 854 NSButton* button; | 906 NSButton* button; |
| 855 NSTextField* label; | 907 NSTextField* label; |
| 856 | 908 |
| 857 CGFloat viewWidth = NSWidth([view frame]); | 909 CGFloat viewWidth = NSWidth([view frame]); |
| 858 | 910 |
| 859 if (isRTL) { | 911 if (isRTL) { |
| 860 point.x = NSWidth([view frame]) - kPermissionImageSize - | 912 point.x = NSWidth([view frame]) - kPermissionImageSize - |
| 861 kPermissionImageSpacing - kFramePadding; | 913 kPermissionImageSpacing - kSectionHorizontalPadding; |
| 862 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; | 914 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; |
| 863 [imageView setImage:image]; | 915 [imageView setImage:image]; |
| 864 point.x -= kPermissionImageSpacing; | 916 point.x -= kPermissionImageSpacing; |
| 865 | 917 |
| 866 label = [self addText:labelText | 918 label = [self addText:labelText |
| 867 withSize:[NSFont smallSystemFontSize] | 919 withSize:[NSFont smallSystemFontSize] |
| 868 bold:NO | 920 bold:NO |
| 869 toView:view | 921 toView:view |
| 870 atPoint:point]; | 922 atPoint:point]; |
| 871 [label sizeToFit]; | 923 [label sizeToFit]; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 897 } | 949 } |
| 898 | 950 |
| 899 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; | 951 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; |
| 900 | 952 |
| 901 // Adjust the vertical position of the button so that its title text is | 953 // Adjust the vertical position of the button so that its title text is |
| 902 // aligned with the label. Assumes that the text is the same size in both. | 954 // aligned with the label. Assumes that the text is the same size in both. |
| 903 // Also adjust the horizontal position to remove excess space due to the | 955 // Also adjust the horizontal position to remove excess space due to the |
| 904 // invisible bezel. | 956 // invisible bezel. |
| 905 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; | 957 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; |
| 906 if (isRTL) { | 958 if (isRTL) { |
| 907 position.x += kPermissionPopUpXSpacing; | 959 // position.x += BYEkPermissionPopUpXSpacing; // TODO |
|
Robert Sesek
2016/06/29 18:22:06
?
lgarron
2016/06/29 20:04:41
I did a lot of simplifications of constants. This
| |
| 908 } else { | |
| 909 position.x -= titleRect.origin.x - kPermissionPopUpXSpacing; | |
| 910 } | 960 } |
| 911 position.y -= titleRect.origin.y; | 961 position.y -= titleRect.origin.y; |
| 912 [button setFrameOrigin:position]; | 962 [button setFrameOrigin:position]; |
| 913 | 963 |
| 914 // Align the icon with the text. | 964 // Align the icon with the text. |
| 915 [self alignPermissionIcon:imageView withTextField:label]; | 965 [self alignPermissionIcon:imageView withTextField:label]; |
| 916 | 966 |
| 917 NSRect buttonFrame = [button frame]; | 967 NSRect buttonFrame = [button frame]; |
| 918 return NSMakePoint(NSMaxX(buttonFrame), NSMaxY(buttonFrame)); | 968 return NSMakePoint(NSMaxX(buttonFrame), NSMaxY(buttonFrame)); |
| 919 } | 969 } |
| 920 | 970 |
| 921 // Align an image with a text field by vertically centering the image on | 971 // Align an image with a text field by vertically centering the image on |
| 922 // the cap height of the first line of text. | 972 // the cap height of the first line of text. |
| 923 - (void)alignPermissionIcon:(NSImageView*)imageView | 973 - (void)alignPermissionIcon:(NSImageView*)imageView |
| 924 withTextField:(NSTextField*)textField { | 974 withTextField:(NSTextField*)textField { |
| 925 NSFont* font = [textField font]; | 975 NSFont* font = [textField font]; |
| 926 | 976 |
| 927 // Calculate the offset from the top of the text field. | 977 // Calculate the offset from the top of the text field. |
| 928 CGFloat capHeight = [font capHeight]; | 978 CGFloat capHeight = [font capHeight]; |
| 929 CGFloat offset = (kPermissionImageSize - capHeight) / 2 - | 979 CGFloat offset = |
| 930 ([font ascender] - capHeight) - kPermissionImageYAdjust; | 980 (kPermissionImageSize - capHeight) / 2 - ([font ascender] - capHeight); |
| 931 | 981 |
| 932 NSRect frame = [imageView frame]; | 982 NSRect frame = [imageView frame]; |
| 933 frame.origin.y -= offset; | 983 frame.origin.y -= offset; |
| 934 [imageView setFrame:frame]; | 984 [imageView setFrame:frame]; |
| 935 } | 985 } |
| 936 | 986 |
| 937 - (void)setCookieInfo:(const CookieInfoList&)cookieInfoList { | 987 - (void)setCookieInfo:(const CookieInfoList&)cookieInfoList { |
| 938 // A result of re-ordering of the permissions (crbug.com/444244) is | 988 // A result of re-ordering of the permissions (crbug.com/444244) is |
| 939 // that sometimes permissions may not be displayed at all, so it's | 989 // that sometimes permissions may not be displayed at all, so it's |
| 940 // incorrect to check they are set before the cookie info. | 990 // incorrect to check they are set before the cookie info. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 953 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA, i.allowed); | 1003 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA, i.allowed); |
| 954 } | 1004 } |
| 955 } | 1005 } |
| 956 | 1006 |
| 957 base::string16 sectionTitle = | 1007 base::string16 sectionTitle = |
| 958 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA); | 1008 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA); |
| 959 bool isRTL = base::i18n::RIGHT_TO_LEFT == | 1009 bool isRTL = base::i18n::RIGHT_TO_LEFT == |
| 960 base::i18n::GetStringDirection(firstPartyLabelText); | 1010 base::i18n::GetStringDirection(firstPartyLabelText); |
| 961 | 1011 |
| 962 [cookiesView_ setSubviews:[NSArray array]]; | 1012 [cookiesView_ setSubviews:[NSArray array]]; |
| 963 NSPoint controlOrigin = NSMakePoint(kFramePadding, 0); | 1013 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); |
| 964 | 1014 |
| 965 NSTextField* label; | 1015 NSTextField* label; |
| 966 | 1016 |
| 967 CGFloat viewWidth = NSWidth([cookiesView_ frame]); | 1017 CGFloat viewWidth = NSWidth([cookiesView_ frame]); |
| 968 | 1018 |
| 969 NSTextField* header = [self addText:sectionTitle | |
| 970 withSize:[NSFont smallSystemFontSize] | |
| 971 bold:YES | |
| 972 toView:cookiesView_ | |
| 973 atPoint:controlOrigin]; | |
| 974 [header sizeToFit]; | |
| 975 | |
| 976 if (isRTL) { | |
| 977 controlOrigin.x = viewWidth - kFramePadding - NSWidth([header frame]); | |
| 978 [header setFrameOrigin:controlOrigin]; | |
| 979 } | |
| 980 controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing; | |
| 981 controlOrigin.y += kPermissionsTabSpacing; | |
| 982 | |
| 983 // Reset X for the cookie image. | 1019 // Reset X for the cookie image. |
| 984 if (isRTL) { | 1020 if (isRTL) { |
| 985 controlOrigin.x = viewWidth - kPermissionImageSize - | 1021 controlOrigin.x = viewWidth - kPermissionImageSize - |
| 986 kPermissionImageSpacing - kFramePadding; | 1022 kPermissionImageSpacing - kSectionHorizontalPadding; |
| 987 } | 1023 } |
| 988 | 1024 |
| 989 WebsiteSettingsUI::PermissionInfo info; | 1025 WebsiteSettingsUI::PermissionInfo info; |
| 990 info.type = CONTENT_SETTINGS_TYPE_COOKIES; | 1026 info.type = CONTENT_SETTINGS_TYPE_COOKIES; |
| 991 info.setting = CONTENT_SETTING_ALLOW; | 1027 info.setting = CONTENT_SETTING_ALLOW; |
| 992 // info.default_setting, info.source, and info.is_incognito have not been set, | 1028 // info.default_setting, info.source, and info.is_incognito have not been set, |
| 993 // but GetPermissionIcon doesn't use any of those. | 1029 // but GetPermissionIcon doesn't use any of those. |
| 994 NSImage* image = WebsiteSettingsUI::GetPermissionIcon(info).ToNSImage(); | 1030 NSImage* image = WebsiteSettingsUI::GetPermissionIcon(info).ToNSImage(); |
| 995 NSImageView* imageView = [self addImageWithSize:[image size] | 1031 NSImageView* imageView = [self addImageWithSize:[image size] |
| 996 toView:cookiesView_ | 1032 toView:cookiesView_ |
| 997 atPoint:controlOrigin]; | 1033 atPoint:controlOrigin]; |
| 998 [imageView setImage:image]; | 1034 [imageView setImage:image]; |
| 999 | 1035 |
| 1000 base::string16 comma = base::ASCIIToUTF16(", "); | 1036 base::string16 comma = base::ASCIIToUTF16(", "); |
| 1001 NSString* cookieButtonText = base::SysUTF16ToNSString(firstPartyLabelText); | 1037 NSString* cookieButtonText = base::SysUTF16ToNSString(firstPartyLabelText); |
| 1002 | 1038 |
| 1039 NSButton* cookiesButton = | |
| 1040 [self addLinkButtonWithText:cookieButtonText toView:cookiesView_]; | |
| 1041 [cookiesButton setTarget:self]; | |
| 1042 [cookiesButton setAction:@selector(showCookiesAndSiteData:)]; | |
| 1043 | |
| 1003 if (isRTL) { | 1044 if (isRTL) { |
| 1004 NSButton* cookiesButton = | 1045 controlOrigin.x -= kPermissionImageSpacing; |
| 1005 [self addLinkButtonWithText:cookieButtonText toView:cookiesView_]; | 1046 NSTextField* cookiesLabel = |
| 1006 [cookiesButton setTarget:self]; | 1047 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES) |
| 1007 [cookiesButton setAction:@selector(showCookiesAndSiteData:)]; | 1048 withSize:[NSFont systemFontSize] |
| 1049 bold:NO | |
| 1050 toView:cookiesView_ | |
| 1051 atPoint:controlOrigin]; | |
| 1052 [cookiesLabel sizeToFit]; | |
| 1053 | |
| 1054 NSPoint cookiesLabelOrigin = [cookiesLabel frame].origin; | |
| 1055 cookiesLabelOrigin.x -= NSWidth([cookiesLabel frame]); | |
| 1056 [cookiesLabel setFrameOrigin:cookiesLabelOrigin]; | |
| 1057 | |
| 1058 // Align the icon with the text. | |
| 1059 [self alignPermissionIcon:imageView withTextField:cookiesLabel]; | |
| 1060 | |
| 1061 controlOrigin.y += NSHeight([cookiesLabel frame]); | |
| 1008 controlOrigin.x -= NSWidth([cookiesButton frame]); | 1062 controlOrigin.x -= NSWidth([cookiesButton frame]); |
| 1009 [cookiesButton setFrameOrigin:controlOrigin]; | 1063 [cookiesButton setFrameOrigin:controlOrigin]; |
| 1010 | 1064 |
| 1011 label = [self addText:comma + thirdPartyLabelText | 1065 label = [self addText:comma + thirdPartyLabelText |
| 1012 withSize:[NSFont smallSystemFontSize] | 1066 withSize:[NSFont smallSystemFontSize] |
| 1013 bold:NO | 1067 bold:NO |
| 1014 toView:cookiesView_ | 1068 toView:cookiesView_ |
| 1015 atPoint:controlOrigin]; | 1069 atPoint:controlOrigin]; |
| 1016 [label sizeToFit]; | 1070 [label sizeToFit]; |
| 1017 controlOrigin.x -= NSWidth([label frame]) - kTextLabelXPadding; | 1071 controlOrigin.x -= NSWidth([label frame]) - kCookieCountXAdjustment; |
| 1018 [label setFrameOrigin:controlOrigin]; | 1072 [label setFrameOrigin:controlOrigin]; |
| 1019 } else { | 1073 } else { |
| 1020 controlOrigin.x += kPermissionImageSize + kPermissionImageSpacing; | 1074 controlOrigin.x += kPermissionImageSize + kPermissionImageSpacing; |
| 1075 NSTextField* cookiesLabel = | |
| 1076 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES) | |
| 1077 withSize:[NSFont systemFontSize] | |
| 1078 bold:NO | |
| 1079 toView:cookiesView_ | |
| 1080 atPoint:controlOrigin]; | |
| 1021 | 1081 |
| 1022 NSButton* cookiesButton = | 1082 controlOrigin.y += NSHeight([cookiesLabel frame]); |
| 1023 [self addLinkButtonWithText:cookieButtonText toView:cookiesView_]; | |
| 1024 [cookiesButton setTarget:self]; | |
| 1025 [cookiesButton setAction:@selector(showCookiesAndSiteData:)]; | |
| 1026 [cookiesButton setFrameOrigin:controlOrigin]; | 1083 [cookiesButton setFrameOrigin:controlOrigin]; |
| 1027 | 1084 |
| 1028 controlOrigin.x += NSWidth([cookiesButton frame]) - kTextLabelXPadding; | 1085 // Align the icon with the text. |
| 1086 [self alignPermissionIcon:imageView withTextField:cookiesLabel]; | |
| 1087 | |
| 1088 controlOrigin.x += NSWidth([cookiesButton frame]) - kCookieCountXAdjustment; | |
| 1029 | 1089 |
| 1030 label = [self addText:comma + thirdPartyLabelText | 1090 label = [self addText:comma + thirdPartyLabelText |
| 1031 withSize:[NSFont smallSystemFontSize] | 1091 withSize:[NSFont smallSystemFontSize] |
| 1032 bold:NO | 1092 bold:NO |
| 1033 toView:cookiesView_ | 1093 toView:cookiesView_ |
| 1034 atPoint:controlOrigin]; | 1094 atPoint:controlOrigin]; |
| 1035 [label sizeToFit]; | 1095 [label sizeToFit]; |
| 1036 } | 1096 } |
| 1037 | 1097 |
| 1038 // Align the icon with the text. | 1098 controlOrigin.y += NSHeight([label frame]); |
| 1039 [self alignPermissionIcon:imageView withTextField:label]; | |
| 1040 | 1099 |
| 1041 controlOrigin.y += NSHeight([label frame]) + kPermissionsTabSpacing; | 1100 [cookiesView_ |
| 1042 | 1101 setFrameSize:NSMakeSize(NSWidth([cookiesView_ frame]), controlOrigin.y)]; |
| 1043 [cookiesView_ setFrameSize: | |
| 1044 NSMakeSize(NSWidth([cookiesView_ frame]), controlOrigin.y)]; | |
| 1045 | 1102 |
| 1046 [self performLayout]; | 1103 [self performLayout]; |
| 1047 } | 1104 } |
| 1048 | 1105 |
| 1049 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList | 1106 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList |
| 1050 andChosenObjects:(const ChosenObjectInfoList&)chosenObjectInfoList { | 1107 andChosenObjects:(const ChosenObjectInfoList&)chosenObjectInfoList { |
| 1051 [permissionsView_ setSubviews:[NSArray array]]; | 1108 [permissionsView_ setSubviews:[NSArray array]]; |
| 1052 NSPoint controlOrigin = NSMakePoint(kFramePadding, 0); | 1109 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); |
| 1053 | 1110 |
| 1054 permissionsPresent_ = YES; | 1111 permissionsPresent_ = YES; |
| 1055 | 1112 |
| 1056 if (permissionInfoList.size() > 0 || chosenObjectInfoList.size() > 0) { | 1113 if (permissionInfoList.size() > 0 || chosenObjectInfoList.size() > 0) { |
| 1057 base::string16 sectionTitle = l10n_util::GetStringUTF16( | 1114 base::string16 sectionTitle = l10n_util::GetStringUTF16( |
| 1058 IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); | 1115 IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); |
| 1059 bool isRTL = base::i18n::RIGHT_TO_LEFT == | |
| 1060 base::i18n::GetStringDirection(sectionTitle); | |
| 1061 NSTextField* header = [self addText:sectionTitle | |
| 1062 withSize:[NSFont smallSystemFontSize] | |
| 1063 bold:YES | |
| 1064 toView:permissionsView_ | |
| 1065 atPoint:controlOrigin]; | |
| 1066 [header sizeToFit]; | |
| 1067 if (isRTL) { | |
| 1068 controlOrigin.x = NSWidth([permissionsView_ frame]) - kFramePadding - | |
| 1069 NSWidth([header frame]); | |
| 1070 [header setFrameOrigin:controlOrigin]; | |
| 1071 } | |
| 1072 controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing; | |
| 1073 | 1116 |
| 1074 for (const auto& permission : permissionInfoList) { | 1117 for (const auto& permission : permissionInfoList) { |
| 1075 controlOrigin.y += kPermissionsTabSpacing; | 1118 controlOrigin.y += kPermissionsVerticalSpacing; |
| 1076 NSPoint rowBottomRight = [self addPermission:permission | 1119 NSPoint rowBottomRight = [self addPermission:permission |
| 1077 toView:permissionsView_ | 1120 toView:permissionsView_ |
| 1078 atPoint:controlOrigin]; | 1121 atPoint:controlOrigin]; |
| 1079 controlOrigin.y = rowBottomRight.y; | 1122 controlOrigin.y = rowBottomRight.y; |
| 1080 } | 1123 } |
| 1081 | 1124 |
| 1082 for (auto object : chosenObjectInfoList) { | 1125 for (auto object : chosenObjectInfoList) { |
| 1083 controlOrigin.y += kPermissionsTabSpacing; | 1126 controlOrigin.y += kPermissionsVerticalSpacing; |
| 1084 NSPoint rowBottomRight = [self addChosenObject:base::WrapUnique(object) | 1127 NSPoint rowBottomRight = [self addChosenObject:base::WrapUnique(object) |
| 1085 toView:permissionsView_ | 1128 toView:permissionsView_ |
| 1086 atPoint:controlOrigin]; | 1129 atPoint:controlOrigin]; |
| 1087 controlOrigin.y = rowBottomRight.y; | 1130 controlOrigin.y = rowBottomRight.y; |
| 1088 } | 1131 } |
| 1089 | 1132 |
| 1090 controlOrigin.y += kFramePadding; | 1133 controlOrigin.y += kSectionHorizontalPadding; |
| 1091 } | 1134 } |
| 1092 | 1135 |
| 1093 [permissionsView_ setFrameSize: | 1136 [permissionsView_ setFrameSize: |
| 1094 NSMakeSize(NSWidth([permissionsView_ frame]), controlOrigin.y)]; | 1137 NSMakeSize(NSWidth([permissionsView_ frame]), controlOrigin.y)]; |
| 1095 [self performLayout]; | 1138 [self performLayout]; |
| 1096 } | 1139 } |
| 1097 | 1140 |
| 1098 @end | 1141 @end |
| 1099 | 1142 |
| 1100 WebsiteSettingsUIBridge::WebsiteSettingsUIBridge( | 1143 WebsiteSettingsUIBridge::WebsiteSettingsUIBridge( |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1190 void WebsiteSettingsUIBridge::SetPermissionInfo( | 1233 void WebsiteSettingsUIBridge::SetPermissionInfo( |
| 1191 const PermissionInfoList& permission_info_list, | 1234 const PermissionInfoList& permission_info_list, |
| 1192 const ChosenObjectInfoList& chosen_object_info_list) { | 1235 const ChosenObjectInfoList& chosen_object_info_list) { |
| 1193 [bubble_controller_ setPermissionInfo:permission_info_list | 1236 [bubble_controller_ setPermissionInfo:permission_info_list |
| 1194 andChosenObjects:chosen_object_info_list]; | 1237 andChosenObjects:chosen_object_info_list]; |
| 1195 } | 1238 } |
| 1196 | 1239 |
| 1197 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { | 1240 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { |
| 1198 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) | 1241 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) |
| 1199 } | 1242 } |
| OLD | NEW |