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 22 matching lines...) Expand all Loading... | |
| 33 #include "components/prefs/pref_service.h" | 33 #include "components/prefs/pref_service.h" |
| 34 #include "content/public/browser/cert_store.h" | 34 #include "content/public/browser/cert_store.h" |
| 35 #include "content/public/browser/page_navigator.h" | 35 #include "content/public/browser/page_navigator.h" |
| 36 #include "content/public/browser/ssl_host_state_delegate.h" | 36 #include "content/public/browser/ssl_host_state_delegate.h" |
| 37 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
| 38 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
| 39 #include "content/public/common/url_constants.h" | 39 #include "content/public/common/url_constants.h" |
| 40 #include "extensions/common/constants.h" | 40 #include "extensions/common/constants.h" |
| 41 #include "grit/components_chromium_strings.h" | 41 #include "grit/components_chromium_strings.h" |
| 42 #include "grit/components_strings.h" | 42 #include "grit/components_strings.h" |
| 43 #include "skia/ext/skia_utils_mac.h" | |
| 43 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" | 44 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" |
| 44 #include "ui/base/cocoa/cocoa_base_utils.h" | 45 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 45 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" | 46 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" |
| 46 #import "ui/base/cocoa/flipped_view.h" | 47 #import "ui/base/cocoa/flipped_view.h" |
| 47 #import "ui/base/cocoa/hover_image_button.h" | 48 #import "ui/base/cocoa/hover_image_button.h" |
| 48 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
| 49 #include "ui/base/resource/resource_bundle.h" | 50 #include "ui/base/resource/resource_bundle.h" |
| 50 #import "ui/gfx/mac/coordinate_conversion.h" | 51 #import "ui/gfx/mac/coordinate_conversion.h" |
| 51 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 52 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 52 #include "ui/resources/grit/ui_resources.h" | 53 #include "ui/resources/grit/ui_resources.h" |
| 53 | 54 |
| 54 using ChosenObjectInfoPtr = | 55 using ChosenObjectInfoPtr = |
| 55 std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo>; | 56 std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo>; |
| 56 using ChosenObjectDeleteCallback = | 57 using ChosenObjectDeleteCallback = |
| 57 base::Callback<void(const WebsiteSettingsUI::ChosenObjectInfo&)>; | 58 base::Callback<void(const WebsiteSettingsUI::ChosenObjectInfo&)>; |
| 58 | 59 |
| 59 namespace { | 60 namespace { |
| 60 | 61 |
| 61 // The default width of the window, in view coordinates. It may be larger to | |
| 62 // fit the content. | |
| 63 const CGFloat kDefaultWindowWidth = 310; | |
| 64 | |
| 65 // Padding between the window frame and content. | |
| 66 const CGFloat kFramePadding = 20; | |
| 67 | |
| 68 // Padding between the window frame and content. | |
| 69 const CGFloat kVerticalSectionMargin = 16; | |
| 70 | |
| 71 // Padding between the window frame and content for the internal page bubble. | |
| 72 const CGFloat kInternalPageFramePadding = 10; | |
| 73 | |
| 74 // Spacing between the identity field and the security summary. | |
| 75 const CGFloat kSpacingBeforeSecuritySummary = 2; | |
| 76 | |
| 77 // Spacing between the security summary and the reset decisions button. | |
| 78 const CGFloat kSpacingBeforeResetDecisionsButton = 8; | |
| 79 | |
| 80 // Spacing between parts of the site settings section. | |
| 81 const CGFloat kSiteSettingsSectionSpacing = 2; | |
| 82 | |
| 83 // Spacing between the image and text for internal pages. | |
| 84 const CGFloat kInternalPageImageSpacing = 10; | |
| 85 | |
| 86 // Square size of the permission images. | |
| 87 const CGFloat kPermissionImageSize = 19; | |
| 88 | |
| 89 // Square size of the permission delete button image. | |
| 90 const CGFloat kPermissionDeleteImageSize = 16; | |
| 91 | |
| 92 // Vertical adjustment for the permission images. They have an extra pixel of | |
| 93 // padding on the bottom edge. | |
| 94 const CGFloat kPermissionImageYAdjust = 1; | |
| 95 | |
| 96 // Spacing between a permission image and the text. | |
| 97 const CGFloat kPermissionImageSpacing = 3; | |
| 98 | |
| 99 // The spacing between individual items in the Permissions tab. | |
| 100 const CGFloat kPermissionsTabSpacing = 12; | |
| 101 | |
| 102 // Extra spacing after a headline on the Permissions tab. | |
| 103 const CGFloat kPermissionsHeadlineSpacing = 2; | |
| 104 | |
| 105 // The amount of horizontal space between a permission label and the popup. | |
| 106 const CGFloat kPermissionPopUpXSpacing = 3; | |
| 107 | |
| 108 // The amount of padding to *remove* when placing | |
| 109 // |IDS_WEBSITE_SETTINGS_{FIRST,THIRD}_PARTY_SITE_DATA| next to each other. | |
| 110 const CGFloat kTextLabelXPadding = 5; | |
| 111 | |
| 112 // 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 |
| 113 // 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 |
| 114 // window. This matches the behaviour in views: see WebsiteSettingsPopupView. | 64 // window. This matches the behaviour in views: see WebsiteSettingsPopupView. |
| 115 bool g_is_popup_showing = false; | 65 bool g_is_popup_showing = false; |
| 116 | 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 // Links are buttons with invisible padding, so we need to move them back to | |
| 78 // align with other text. | |
| 79 const CGFloat kLinkButtonXAdjustment = 1; | |
| 80 | |
| 81 /**************** Security Section ****************/ | |
| 82 | |
| 83 // Tweak to move the security summary up. | |
| 84 const CGFloat kSecuritySummaryYAdjustment = -6; | |
| 85 | |
| 86 // Spacing between security summary, security details, and cert decisions text. | |
| 87 const CGFloat kSecurityParagraphSpacing = 12; | |
| 88 | |
| 89 /**************** Site Settings Section ****************/ | |
| 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 icon to align the icon baseline with the | |
| 104 // label text. | |
| 105 const CGFloat kPermissionIconYAdjustment = 1; | |
| 106 | |
| 107 // Amount to lower each permission popup button to make its text align with the | |
| 108 // permission label. | |
| 109 const CGFloat kPermissionPopupButtonYAdjustment = 3; | |
| 110 | |
| 111 /**************** Internal Page Bubble ****************/ | |
| 112 | |
| 113 // Padding between the window frame and content for the internal page bubble. | |
| 114 const CGFloat kInternalPageFramePadding = 10; | |
| 115 | |
| 116 // Spacing between the image and text for internal pages. | |
| 117 const CGFloat kInternalPageImageSpacing = 10; | |
| 118 | |
| 117 // Takes in the parent window, which should be a BrowserWindow, and gets the | 119 // Takes in the parent window, which should be a BrowserWindow, and gets the |
| 118 // proper anchor point for the bubble. The returned point is in screen | 120 // proper anchor point for the bubble. The returned point is in screen |
| 119 // coordinates. | 121 // coordinates. |
| 120 NSPoint AnchorPointForWindow(NSWindow* parent) { | 122 NSPoint AnchorPointForWindow(NSWindow* parent) { |
| 121 BrowserWindowController* controller = [parent windowController]; | 123 BrowserWindowController* controller = [parent windowController]; |
| 122 NSPoint origin = NSZeroPoint; | 124 NSPoint origin = NSZeroPoint; |
| 123 if ([controller isKindOfClass:[BrowserWindowController class]]) { | 125 if ([controller isKindOfClass:[BrowserWindowController class]]) { |
| 124 LocationBarViewMac* location_bar = [controller locationBarBridge]; | 126 LocationBarViewMac* location_bar = [controller locationBarBridge]; |
| 125 if (location_bar) { | 127 if (location_bar) { |
| 126 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint(); | 128 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 // results when the image, at 26x26, was taller than (or just slightly | 287 // results when the image, at 26x26, was taller than (or just slightly |
| 286 // shorter) than the text, but produced incorrect results once the icon | 288 // shorter) than the text, but produced incorrect results once the icon |
| 287 // shrank to 16x16. The icon should now always be shorter than the text. | 289 // shrank to 16x16. The icon should now always be shorter than the text. |
| 288 // See crbug.com/572044 . | 290 // See crbug.com/572044 . |
| 289 NSRect textFrame = [textField frame]; | 291 NSRect textFrame = [textField frame]; |
| 290 imageFrame.origin.y += (NSHeight(textFrame) - NSHeight(imageFrame)) / 2; | 292 imageFrame.origin.y += (NSHeight(textFrame) - NSHeight(imageFrame)) / 2; |
| 291 [imageView setFrame:imageFrame]; | 293 [imageView setFrame:imageFrame]; |
| 292 | 294 |
| 293 // Adjust the contentView to fit everything. | 295 // Adjust the contentView to fit everything. |
| 294 CGFloat maxY = std::max(NSMaxY(imageFrame), NSMaxY(textFrame)); | 296 CGFloat maxY = std::max(NSMaxY(imageFrame), NSMaxY(textFrame)); |
| 295 [contentView_ setFrame:NSMakeRect( | 297 [contentView_ setFrame:NSMakeRect(0, 0, [self defaultWindowWidth], |
| 296 0, 0, [self defaultWindowWidth], maxY + kInternalPageFramePadding)]; | 298 maxY + kInternalPageFramePadding)]; |
| 297 | 299 |
| 298 [self sizeAndPositionWindow]; | 300 [self sizeAndPositionWindow]; |
| 299 } | 301 } |
| 300 | 302 |
| 301 // Create the subviews for the website settings bubble. | 303 // Create the subviews for the website settings bubble. |
| 302 - (void)initializeContents { | 304 - (void)initializeContents { |
| 303 securitySectionView_ = [self addSecuritySectionToView:contentView_]; | 305 securitySectionView_ = [self addSecuritySectionToView:contentView_]; |
| 304 separatorAfterSecuritySection_ = [self addSeparatorToView:contentView_]; | 306 separatorAfterSecuritySection_ = [self addSeparatorToView:contentView_]; |
| 305 siteSettingsSectionView_ = [self addSiteSettingsSectionToView:contentView_]; | 307 siteSettingsSectionView_ = [self addSiteSettingsSectionToView:contentView_]; |
| 306 | 308 |
| 307 [self performLayout]; | 309 [self performLayout]; |
| 308 } | 310 } |
| 309 | 311 |
| 310 // Create and return a subview for the security section and add it to the given | 312 // Create and return a subview for the security section and add it to the given |
| 311 // |superview|. |superview| retains the new view. | 313 // |superview|. |superview| retains the new view. |
| 312 - (NSView*)addSecuritySectionToView:(NSView*)superview { | 314 - (NSView*)addSecuritySectionToView:(NSView*)superview { |
| 313 base::scoped_nsobject<NSView> securitySectionView( | 315 base::scoped_nsobject<NSView> securitySectionView( |
| 314 [[FlippedView alloc] initWithFrame:[superview frame]]); | 316 [[FlippedView alloc] initWithFrame:[superview frame]]); |
| 315 [superview addSubview:securitySectionView]; | 317 [superview addSubview:securitySectionView]; |
| 316 | 318 |
| 317 // Create a controlOrigin to place the text fields. The y value doesn't | 319 // Create a controlOrigin to place the text fields. The y value doesn't |
| 318 // matter, because the correct value is calculated in -performLayout. | 320 // matter, because the correct value is calculated in -performLayout. |
| 319 NSPoint controlOrigin = NSMakePoint(kFramePadding, 0); | 321 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); |
| 320 | |
| 321 // Create a text field (empty for now) to show the site identity. | |
| 322 identityField_ = [self addText:base::string16() | |
| 323 withSize:[NSFont systemFontSize] | |
| 324 bold:YES | |
| 325 toView:securitySectionView | |
| 326 atPoint:controlOrigin]; | |
| 327 | 322 |
| 328 // Create a text field for the security summary (private/not private/etc.). | 323 // Create a text field for the security summary (private/not private/etc.). |
| 329 securitySummaryField_ = [self addText:base::string16() | 324 securitySummaryField_ = [self addText:base::string16() |
| 325 withSize:[NSFont systemFontSize] | |
| 326 bold:NO | |
| 327 toView:securitySectionView | |
| 328 atPoint:controlOrigin]; | |
| 329 | |
| 330 securityDetailsField_ = [self addText:base::string16() | |
| 330 withSize:[NSFont smallSystemFontSize] | 331 withSize:[NSFont smallSystemFontSize] |
| 331 bold:NO | 332 bold:NO |
| 332 toView:securitySectionView | 333 toView:securitySectionView |
| 333 atPoint:controlOrigin]; | 334 atPoint:controlOrigin]; |
| 334 | 335 |
| 335 resetDecisionsButton_ = nil; // This will be created only if necessary. | 336 // These will be created only if necessary. |
| 337 resetDecisionsField_ = nil; | |
| 338 resetDecisionsButton_ = nil; | |
| 336 | 339 |
| 337 NSString* securityDetailsButtonText = | 340 NSString* securityDetailsButtonText = |
| 338 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_DETAILS_LINK); | 341 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_DETAILS_LINK); |
| 339 // Note: The security details button may be removed from the superview in | 342 // Note: The security details button may be removed from the superview in |
| 340 // -performLayout in order to hide it (depending on the connection). | 343 // -performLayout in order to hide it (depending on the connection). |
| 341 securityDetailsButton_ = [self addLinkButtonWithText:securityDetailsButtonText | 344 securityDetailsButton_ = [self addLinkButtonWithText:securityDetailsButtonText |
| 342 toView:securitySectionView]; | 345 toView:securitySectionView]; |
| 343 [securityDetailsButton_ setTarget:self]; | 346 [securityDetailsButton_ setTarget:self]; |
| 344 [securityDetailsButton_ setAction:@selector(showSecurityDetails:)]; | 347 [securityDetailsButton_ setAction:@selector(showSecurityDetails:)]; |
| 345 | 348 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 361 [siteSettingsSectionView addSubview:cookiesView_]; | 364 [siteSettingsSectionView addSubview:cookiesView_]; |
| 362 | 365 |
| 363 permissionsView_ = | 366 permissionsView_ = |
| 364 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; | 367 [[[FlippedView alloc] initWithFrame:[superview frame]] autorelease]; |
| 365 [siteSettingsSectionView addSubview:permissionsView_]; | 368 [siteSettingsSectionView addSubview:permissionsView_]; |
| 366 | 369 |
| 367 // Create the link button to view site settings. Its position will be set in | 370 // Create the link button to view site settings. Its position will be set in |
| 368 // performLayout. | 371 // performLayout. |
| 369 NSString* siteSettingsButtonText = | 372 NSString* siteSettingsButtonText = |
| 370 l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK); | 373 l10n_util::GetNSString(IDS_PAGE_INFO_SITE_SETTINGS_LINK); |
| 371 siteSettingsButton_ = [self addLinkButtonWithText:siteSettingsButtonText | 374 siteSettingsButton_ = [self addButtonWithText:siteSettingsButtonText |
| 372 toView:siteSettingsSectionView]; | 375 toView:siteSettingsSectionView]; |
| 376 [GTMUILocalizerAndLayoutTweaker sizeToFitView:siteSettingsButton_]; | |
| 377 | |
| 373 [siteSettingsButton_ setTarget:self]; | 378 [siteSettingsButton_ setTarget:self]; |
| 374 [siteSettingsButton_ setAction:@selector(showSiteSettingsData:)]; | 379 [siteSettingsButton_ setAction:@selector(showSiteSettingsData:)]; |
| 375 | 380 |
| 376 return siteSettingsSectionView.get(); | 381 return siteSettingsSectionView.get(); |
| 377 } | 382 } |
| 378 | 383 |
| 379 // Handler for the link button below the list of cookies. | 384 // Handler for the link button below the list of cookies. |
| 380 - (void)showCookiesAndSiteData:(id)sender { | 385 - (void)showCookiesAndSiteData:(id)sender { |
| 381 DCHECK(webContents_); | 386 DCHECK(webContents_); |
| 382 DCHECK(presenter_); | 387 DCHECK(presenter_); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 ShowCertificateViewerByID(webContents_, [self parentWindow], certificateId_); | 427 ShowCertificateViewerByID(webContents_, [self parentWindow], certificateId_); |
| 423 } | 428 } |
| 424 | 429 |
| 425 // Handler for the link button to revoke user certificate decisions. | 430 // Handler for the link button to revoke user certificate decisions. |
| 426 - (void)resetCertificateDecisions:(id)sender { | 431 - (void)resetCertificateDecisions:(id)sender { |
| 427 DCHECK(resetDecisionsButton_); | 432 DCHECK(resetDecisionsButton_); |
| 428 presenter_->OnRevokeSSLErrorBypassButtonPressed(); | 433 presenter_->OnRevokeSSLErrorBypassButtonPressed(); |
| 429 [self close]; | 434 [self close]; |
| 430 } | 435 } |
| 431 | 436 |
| 437 - (CGFloat)layoutViewAtRTLStart:(NSView*)view withYPosition:(CGFloat)yPos { | |
| 438 CGFloat xPos; | |
| 439 if (base::i18n::IsRTL()) { | |
| 440 xPos = | |
| 441 kDefaultWindowWidth - kSectionHorizontalPadding - NSWidth([view frame]); | |
| 442 } else { | |
| 443 xPos = kSectionHorizontalPadding; | |
| 444 } | |
| 445 [view setFrameOrigin:NSMakePoint(xPos, yPos)]; | |
| 446 return yPos + NSHeight([view frame]); | |
| 447 } | |
| 448 | |
| 432 // Set the Y position of |view| to the given position, and return the position | 449 // Set the Y position of |view| to the given position, and return the position |
| 433 // of its bottom edge. | 450 // of its bottom edge. |
| 434 - (CGFloat)setYPositionOfView:(NSView*)view to:(CGFloat)position { | 451 - (CGFloat)setYPositionOfView:(NSView*)view to:(CGFloat)position { |
| 435 NSRect frame = [view frame]; | 452 NSRect frame = [view frame]; |
| 436 frame.origin.y = position; | 453 frame.origin.y = position; |
| 437 [view setFrame:frame]; | 454 [view setFrame:frame]; |
| 438 return position + NSHeight(frame); | 455 return position + NSHeight(frame); |
| 439 } | 456 } |
| 440 | 457 |
| 441 - (void)setWidthOfView:(NSView*)view to:(CGFloat)width { | 458 - (void)setWidthOfView:(NSView*)view to:(CGFloat)width { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 455 | 472 |
| 456 // Set the width of the content view now, so that all the text fields will | 473 // Set the width of the content view now, so that all the text fields will |
| 457 // be sized to fit before their heights and vertical positions are adjusted. | 474 // be sized to fit before their heights and vertical positions are adjusted. |
| 458 [self setWidthOfView:contentView_ to:contentWidth]; | 475 [self setWidthOfView:contentView_ to:contentWidth]; |
| 459 [self setWidthOfView:securitySectionView_ to:contentWidth]; | 476 [self setWidthOfView:securitySectionView_ to:contentWidth]; |
| 460 [self setWidthOfView:siteSettingsSectionView_ to:contentWidth]; | 477 [self setWidthOfView:siteSettingsSectionView_ to:contentWidth]; |
| 461 | 478 |
| 462 CGFloat yPos = info_bubble::kBubbleArrowHeight; | 479 CGFloat yPos = info_bubble::kBubbleArrowHeight; |
| 463 | 480 |
| 464 [self layoutSecuritySection]; | 481 [self layoutSecuritySection]; |
| 465 yPos = [self setYPositionOfView:securitySectionView_ to:yPos + kFramePadding]; | 482 yPos = [self setYPositionOfView:securitySectionView_ to:yPos]; |
| 466 | 483 |
| 467 yPos = [self setYPositionOfView:separatorAfterSecuritySection_ | 484 yPos = [self setYPositionOfView:separatorAfterSecuritySection_ |
| 468 to:yPos + kVerticalSectionMargin]; | 485 to:yPos + kSectionHorizontalPadding]; |
| 469 | 486 |
| 470 [self layoutSiteSettingsSection]; | 487 [self layoutSiteSettingsSection]; |
| 471 yPos = [self setYPositionOfView:siteSettingsSectionView_ | 488 yPos = [self setYPositionOfView:siteSettingsSectionView_ |
| 472 to:yPos + kVerticalSectionMargin]; | 489 to:yPos + kSectionHorizontalPadding]; |
| 473 | 490 |
| 474 [contentView_ setFrame:NSMakeRect(0, 0, NSWidth([contentView_ frame]), | 491 [contentView_ setFrame:NSMakeRect(0, 0, NSWidth([contentView_ frame]), |
| 475 yPos + kFramePadding)]; | 492 yPos + kSectionVerticalPadding)]; |
| 476 | 493 |
| 477 [self sizeAndPositionWindow]; | 494 [self sizeAndPositionWindow]; |
| 478 } | 495 } |
| 479 | 496 |
| 480 - (void)layoutSecuritySection { | 497 - (void)layoutSecuritySection { |
| 481 // Start the layout with the first element. Margins are handled by the caller. | 498 // Start the layout with the first element. Margins are handled by the caller. |
| 482 CGFloat yPos = 0; | 499 CGFloat yPos = 0; |
| 483 | 500 |
| 484 [self sizeTextFieldHeightToFit:identityField_]; | |
| 485 yPos = [self setYPositionOfView:identityField_ to:yPos]; | |
| 486 | |
| 487 [self sizeTextFieldHeightToFit:securitySummaryField_]; | 501 [self sizeTextFieldHeightToFit:securitySummaryField_]; |
| 488 yPos = [self setYPositionOfView:securitySummaryField_ | 502 yPos = [self setYPositionOfView:securitySummaryField_ |
| 489 to:yPos + kSpacingBeforeSecuritySummary]; | 503 to:yPos + kSectionVerticalPadding + |
| 504 kSecuritySummaryYAdjustment]; | |
| 505 | |
| 506 [self sizeTextFieldHeightToFit:securityDetailsField_]; | |
| 507 yPos = [self setYPositionOfView:securityDetailsField_ | |
| 508 to:yPos + kSecurityParagraphSpacing]; | |
| 490 | 509 |
| 491 if (isDevToolsDisabled_ && certificateId_ == 0) { | 510 if (isDevToolsDisabled_ && certificateId_ == 0) { |
| 492 // -removeFromSuperview is idempotent. | 511 // -removeFromSuperview is idempotent. |
| 493 [securityDetailsButton_ removeFromSuperview]; | 512 [securityDetailsButton_ removeFromSuperview]; |
| 494 } else { | 513 } else { |
| 495 // -addSubview is idempotent. | 514 // -addSubview is idempotent. |
| 496 [securitySectionView_ addSubview:securityDetailsButton_]; | 515 [securitySectionView_ addSubview:securityDetailsButton_]; |
| 497 yPos = [self setYPositionOfView:securityDetailsButton_ to:yPos]; | 516 [securityDetailsButton_ |
| 517 setFrameOrigin:NSMakePoint( | |
| 518 kSectionHorizontalPadding - kLinkButtonXAdjustment, | |
| 519 yPos)]; | |
| 520 yPos = NSMaxY([securityDetailsButton_ frame]); | |
| 498 } | 521 } |
| 499 | 522 |
| 500 if (resetDecisionsButton_) { | 523 if (resetDecisionsButton_) { |
| 501 yPos = [self setYPositionOfView:resetDecisionsButton_ | 524 DCHECK(resetDecisionsField_); |
| 502 to:yPos + kSpacingBeforeResetDecisionsButton]; | 525 yPos = [self setYPositionOfView:resetDecisionsField_ |
| 526 to:yPos + kSecurityParagraphSpacing]; | |
| 527 [resetDecisionsButton_ | |
| 528 setFrameOrigin:NSMakePoint(NSMinX([resetDecisionsButton_ frame]) - | |
| 529 kLinkButtonXAdjustment, | |
| 530 yPos)]; | |
| 531 yPos = NSMaxY([resetDecisionsButton_ frame]); | |
| 503 } | 532 } |
| 504 | 533 |
| 505 // Resize the height based on contents. | 534 // Resize the height based on contents. |
| 506 [self setHeightOfView:securitySectionView_ to:yPos]; | 535 [self setHeightOfView:securitySectionView_ to:yPos]; |
| 507 } | 536 } |
| 508 | 537 |
| 509 - (void)layoutSiteSettingsSection { | 538 - (void)layoutSiteSettingsSection { |
| 510 // Start the layout with the first element. Margins are handled by the caller. | 539 // Start the layout with the first element. Margins are handled by the caller. |
| 511 CGFloat yPos = 0; | 540 CGFloat yPos = 0; |
| 512 | 541 |
| 513 yPos = [self setYPositionOfView:cookiesView_ to:yPos]; | 542 yPos = [self setYPositionOfView:cookiesView_ to:yPos]; |
| 514 | 543 |
| 515 if (permissionsPresent_) { | 544 if (permissionsPresent_) { |
| 516 // Put the permission info just below the link button. | 545 // Put the permission info just below the link button. |
| 517 yPos = [self setYPositionOfView:permissionsView_ | 546 yPos = [self setYPositionOfView:permissionsView_ to:yPos]; |
| 518 to:yPos + kSiteSettingsSectionSpacing]; | |
| 519 } | 547 } |
| 520 | 548 |
| 521 // Put the link button for site settings just below the permissions. | 549 yPos = [self layoutViewAtRTLStart:siteSettingsButton_ withYPosition:yPos]; |
| 522 // TODO(lgarron): set the position of this based on RTL/LTR. | |
| 523 // http://code.google.com/p/chromium/issues/detail?id=525304 | |
| 524 yPos += kSiteSettingsSectionSpacing; | |
| 525 [siteSettingsButton_ setFrameOrigin:NSMakePoint(kFramePadding, yPos)]; | |
| 526 yPos = NSMaxY([siteSettingsButton_ frame]); | |
| 527 | 550 |
| 528 // Resize the height based on contents. | 551 // Resize the height based on contents. |
| 529 [self setHeightOfView:siteSettingsSectionView_ to:yPos]; | 552 [self setHeightOfView:siteSettingsSectionView_ to:yPos]; |
| 530 } | 553 } |
| 531 | 554 |
| 532 // Adjust the size of the window to match the size of the content, and position | 555 // Adjust the size of the window to match the size of the content, and position |
| 533 // the bubble anchor appropriately. | 556 // the bubble anchor appropriately. |
| 534 - (void)sizeAndPositionWindow { | 557 - (void)sizeAndPositionWindow { |
| 535 NSRect windowFrame = [contentView_ frame]; | 558 NSRect windowFrame = [contentView_ frame]; |
| 536 windowFrame.size = [[[self window] contentView] convertSize:windowFrame.size | 559 windowFrame.size = [[[self window] contentView] convertSize:windowFrame.size |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 | 593 |
| 571 // Create a new text field and add it to the given array of subviews. | 594 // Create a new text field and add it to the given array of subviews. |
| 572 // The array will retain a reference to the object. | 595 // The array will retain a reference to the object. |
| 573 - (NSTextField*)addText:(const base::string16&)text | 596 - (NSTextField*)addText:(const base::string16&)text |
| 574 withSize:(CGFloat)fontSize | 597 withSize:(CGFloat)fontSize |
| 575 bold:(BOOL)bold | 598 bold:(BOOL)bold |
| 576 toView:(NSView*)view | 599 toView:(NSView*)view |
| 577 atPoint:(NSPoint)point { | 600 atPoint:(NSPoint)point { |
| 578 // Size the text to take up the full available width, with some padding. | 601 // Size the text to take up the full available width, with some padding. |
| 579 // The height is arbitrary as it will be adjusted later. | 602 // The height is arbitrary as it will be adjusted later. |
| 580 CGFloat width = NSWidth([view frame]) - point.x - kFramePadding; | 603 CGFloat width = NSWidth([view frame]) - point.x - kSectionHorizontalPadding; |
| 581 NSRect frame = NSMakeRect(point.x, point.y, width, 100); | 604 NSRect frame = NSMakeRect(point.x, point.y, width, 100); |
| 582 base::scoped_nsobject<NSTextField> textField( | 605 base::scoped_nsobject<NSTextField> textField( |
| 583 [[NSTextField alloc] initWithFrame:frame]); | 606 [[NSTextField alloc] initWithFrame:frame]); |
| 584 [self configureTextFieldAsLabel:textField.get()]; | 607 [self configureTextFieldAsLabel:textField.get()]; |
| 585 [textField setStringValue:base::SysUTF16ToNSString(text)]; | 608 [textField setStringValue:base::SysUTF16ToNSString(text)]; |
| 586 NSFont* font = bold ? [NSFont boldSystemFontOfSize:fontSize] | 609 NSFont* font = bold ? [NSFont boldSystemFontOfSize:fontSize] |
| 587 : [NSFont systemFontOfSize:fontSize]; | 610 : [NSFont systemFontOfSize:fontSize]; |
| 588 [textField setFont:font]; | 611 [textField setFont:font]; |
| 589 [self sizeTextFieldHeightToFit:textField]; | 612 [self sizeTextFieldHeightToFit:textField]; |
| 590 [textField setAutoresizingMask:NSViewWidthSizable]; | 613 [textField setAutoresizingMask:NSViewWidthSizable]; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 610 // Use an arbitrary position; it will be adjusted in performLayout. | 633 // Use an arbitrary position; it will be adjusted in performLayout. |
| 611 NSBox* spacer = [self | 634 NSBox* spacer = [self |
| 612 horizontalSeparatorWithFrame:NSMakeRect(0, 0, NSWidth([view frame]), 0)]; | 635 horizontalSeparatorWithFrame:NSMakeRect(0, 0, NSWidth([view frame]), 0)]; |
| 613 [view addSubview:spacer]; | 636 [view addSubview:spacer]; |
| 614 return spacer; | 637 return spacer; |
| 615 } | 638 } |
| 616 | 639 |
| 617 // Add a link button with the given text to |view|. | 640 // Add a link button with the given text to |view|. |
| 618 - (NSButton*)addLinkButtonWithText:(NSString*)text toView:(NSView*)view { | 641 - (NSButton*)addLinkButtonWithText:(NSString*)text toView:(NSView*)view { |
| 619 // Frame size is arbitrary; it will be adjusted by the layout tweaker. | 642 // Frame size is arbitrary; it will be adjusted by the layout tweaker. |
| 620 NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10); | 643 NSRect frame = NSMakeRect(kSectionHorizontalPadding, 0, 100, 10); |
| 621 base::scoped_nsobject<NSButton> button( | 644 base::scoped_nsobject<NSButton> button( |
| 622 [[NSButton alloc] initWithFrame:frame]); | 645 [[NSButton alloc] initWithFrame:frame]); |
| 623 base::scoped_nsobject<HyperlinkButtonCell> cell( | 646 base::scoped_nsobject<HyperlinkButtonCell> cell( |
| 624 [[HyperlinkButtonCell alloc] initTextCell:text]); | 647 [[HyperlinkButtonCell alloc] initTextCell:text]); |
| 625 [cell setControlSize:NSSmallControlSize]; | 648 [cell setControlSize:NSSmallControlSize]; |
| 626 [button setCell:cell.get()]; | 649 [button setCell:cell.get()]; |
| 627 [button setButtonType:NSMomentaryPushInButton]; | 650 [button setButtonType:NSMomentaryPushInButton]; |
| 628 [button setBezelStyle:NSRegularSquareBezelStyle]; | 651 [button setBezelStyle:NSRegularSquareBezelStyle]; |
| 629 [view addSubview:button.get()]; | 652 [view addSubview:button.get()]; |
| 630 | 653 |
| 631 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; | 654 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; |
| 632 return button.get(); | 655 return button.get(); |
| 633 } | 656 } |
| 634 | 657 |
| 635 // Create and return a button with the specified text and add it to the given | 658 // Create and return a button with the specified text and add it to the given |
| 636 // |view|. |view| retains the new button. | 659 // |view|. |view| retains the new button. |
| 637 - (NSButton*)addButtonWithText:(NSString*)text toView:(NSView*)view { | 660 - (NSButton*)addButtonWithText:(NSString*)text toView:(NSView*)view { |
| 638 NSRect containerFrame = [view frame]; | 661 NSRect containerFrame = [view frame]; |
| 639 // Frame size is arbitrary; it will be adjusted by the layout tweaker. | 662 // Frame size is arbitrary; it will be adjusted by the layout tweaker. |
| 640 NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10); | 663 NSRect frame = NSMakeRect(kSectionHorizontalPadding, 0, 100, 10); |
| 641 base::scoped_nsobject<NSButton> button( | 664 base::scoped_nsobject<NSButton> button( |
| 642 [[NSButton alloc] initWithFrame:frame]); | 665 [[NSButton alloc] initWithFrame:frame]); |
| 643 | 666 |
| 644 // Determine the largest possible size for this button. The size is the width | 667 // Determine the largest possible size for this button. The size is the width |
| 645 // of the connection section minus the padding on both sides minus the | 668 // of the connection section minus the padding on both sides minus the |
| 646 // connection image size and spacing. | 669 // connection image size and spacing. |
| 647 // TODO(lgarron): handle this sizing in -performLayout. | 670 // TODO(lgarron): handle this sizing in -performLayout. |
| 648 CGFloat maxTitleWidth = containerFrame.size.width - kFramePadding * 2; | 671 CGFloat maxTitleWidth = |
| 672 containerFrame.size.width - kSectionHorizontalPadding * 2; | |
| 649 | 673 |
| 650 base::scoped_nsobject<NSButtonCell> cell( | 674 base::scoped_nsobject<NSButtonCell> cell( |
| 651 [[NSButtonCell alloc] initTextCell:text]); | 675 [[NSButtonCell alloc] initTextCell:text]); |
| 652 [button setCell:cell.get()]; | 676 [button setCell:cell.get()]; |
| 653 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; | 677 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; |
| 654 | 678 |
| 655 // Ensure the containing view is large enough to contain the button with its | 679 // Ensure the containing view is large enough to contain the button with its |
| 656 // widest possible title. | 680 // widest possible title. |
| 657 NSRect buttonFrame = [button frame]; | 681 NSRect buttonFrame = [button frame]; |
| 658 buttonFrame.size.width = maxTitleWidth; | 682 buttonFrame.size.width = maxTitleWidth; |
| 659 | 683 |
| 660 [button setFrame:buttonFrame]; | 684 [button setFrame:buttonFrame]; |
| 661 [button setButtonType:NSMomentaryPushInButton]; | 685 [button setButtonType:NSMomentaryPushInButton]; |
| 662 [button setBezelStyle:NSRegularSquareBezelStyle]; | 686 [button setBezelStyle:NSRegularSquareBezelStyle]; |
| 663 [view addSubview:button.get()]; | 687 [view addSubview:button.get()]; |
| 664 | 688 |
| 665 return button.get(); | 689 return button.get(); |
| 666 } | 690 } |
| 667 | 691 |
| 668 // Set the content of the identity and identity status fields. | 692 // Set the content of the identity and identity status fields. |
| 669 - (void)setIdentityInfo:(const WebsiteSettingsUI::IdentityInfo&)identityInfo { | 693 - (void)setIdentityInfo:(const WebsiteSettingsUI::IdentityInfo&)identityInfo { |
| 670 [identityField_ | 694 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = |
| 671 setStringValue:base::SysUTF8ToNSString(identityInfo.site_identity)]; | 695 identityInfo.GetSecurityDescription(); |
| 672 [securitySummaryField_ setStringValue:base::SysUTF16ToNSString( | 696 [securitySummaryField_ |
| 673 identityInfo.GetSecuritySummary())]; | 697 setStringValue:base::SysUTF16ToNSString(security_description->summary)]; |
| 698 | |
| 699 if (security_description->summary_style & WebsiteSettingsUI::STYLE_COLOR) { | |
| 700 NSColor* color = | |
| 701 skia::SkColorToSRGBNSColor(security_description->summary_color); | |
| 702 [securitySummaryField_ setTextColor:color]; | |
| 703 } | |
| 704 | |
| 705 [securityDetailsField_ | |
| 706 setStringValue:SysUTF16ToNSString(security_description->details)]; | |
| 674 | 707 |
| 675 certificateId_ = identityInfo.cert_id; | 708 certificateId_ = identityInfo.cert_id; |
| 676 | 709 |
| 677 if (certificateId_ && identityInfo.show_ssl_decision_revoke_button) { | 710 if (certificateId_ && identityInfo.show_ssl_decision_revoke_button) { |
| 678 NSString* text = l10n_util::GetNSString( | 711 resetDecisionsField_ = |
| 679 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON); | 712 [self addText:base::string16() |
| 713 withSize:[NSFont smallSystemFontSize] | |
| 714 bold:NO | |
| 715 toView:securitySectionView_ | |
| 716 atPoint:NSMakePoint(kSectionHorizontalPadding, 0)]; | |
| 717 [resetDecisionsField_ | |
| 718 setStringValue:l10n_util::GetNSString( | |
| 719 IDS_PAGEINFO_INVALID_CERTIFICATE_DESCRIPTION)]; | |
| 720 [self sizeTextFieldHeightToFit:resetDecisionsField_]; | |
| 721 | |
| 680 resetDecisionsButton_ = | 722 resetDecisionsButton_ = |
| 681 [self addButtonWithText:text toView:securitySectionView_]; | 723 [self addLinkButtonWithText: |
| 724 l10n_util::GetNSString( | |
| 725 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON) | |
| 726 toView:securitySectionView_]; | |
| 682 [resetDecisionsButton_ setTarget:self]; | 727 [resetDecisionsButton_ setTarget:self]; |
| 683 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)]; | 728 [resetDecisionsButton_ setAction:@selector(resetCertificateDecisions:)]; |
| 684 } | 729 } |
| 685 | 730 |
| 686 [self performLayout]; | 731 [self performLayout]; |
| 687 } | 732 } |
| 688 | 733 |
| 689 // Add a pop-up button for |permissionInfo| to the given view. | 734 // Add a pop-up button for |permissionInfo| to the given view. |
| 690 - (NSPopUpButton*)addPopUpButtonForPermission: | 735 - (NSPopUpButton*)addPopUpButtonForPermission: |
| 691 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo | 736 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo |
| 692 toView:(NSView*)view | 737 toView:(NSView*)view |
| 693 atPoint:(NSPoint)point { | 738 atPoint:(NSPoint)point { |
| 694 | 739 |
| 695 GURL url = webContents_ ? webContents_->GetURL() : GURL(); | 740 GURL url = webContents_ ? webContents_->GetURL() : GURL(); |
| 696 __block WebsiteSettingsBubbleController* weakSelf = self; | 741 __block WebsiteSettingsBubbleController* weakSelf = self; |
| 697 PermissionMenuModel::ChangeCallback callback = | 742 PermissionMenuModel::ChangeCallback callback = |
| 698 base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) { | 743 base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) { |
| 699 [weakSelf onPermissionChanged:permission.type to:permission.setting]; | 744 [weakSelf onPermissionChanged:permission.type to:permission.setting]; |
| 700 }); | 745 }); |
| 701 base::scoped_nsobject<PermissionSelectorButton> button( | 746 base::scoped_nsobject<PermissionSelectorButton> button( |
| 702 [[PermissionSelectorButton alloc] initWithPermissionInfo:permissionInfo | 747 [[PermissionSelectorButton alloc] initWithPermissionInfo:permissionInfo |
| 703 forURL:url | 748 forURL:url |
| 704 withCallback:callback]); | 749 withCallback:callback]); |
| 750 | |
| 705 // Determine the largest possible size for this button. | 751 // Determine the largest possible size for this button. |
| 706 CGFloat maxTitleWidth = [button | 752 CGFloat maxTitleWidth = [button |
| 707 maxTitleWidthForContentSettingsType:permissionInfo.type | 753 maxTitleWidthForContentSettingsType:permissionInfo.type |
| 708 withDefaultSetting:permissionInfo.default_setting]; | 754 withDefaultSetting:permissionInfo.default_setting]; |
| 709 | 755 |
| 710 // Ensure the containing view is large enough to contain the button with its | 756 // Ensure the containing view is large enough to contain the button with its |
| 711 // widest possible title. | 757 // widest possible title. |
| 712 NSRect containerFrame = [view frame]; | 758 NSRect containerFrame = [view frame]; |
| 713 containerFrame.size.width = std::max( | 759 containerFrame.size.width = |
| 714 NSWidth(containerFrame), point.x + maxTitleWidth + kFramePadding); | 760 std::max(NSWidth(containerFrame), |
| 761 point.x + maxTitleWidth + kSectionHorizontalPadding); | |
| 715 [view setFrame:containerFrame]; | 762 [view setFrame:containerFrame]; |
| 716 [view addSubview:button.get()]; | 763 [view addSubview:button.get()]; |
| 717 return button.get(); | 764 return button.get(); |
| 718 } | 765 } |
| 719 | 766 |
| 720 // Add a delete button for |objectInfo| to the given view. | 767 // Add a delete button for |objectInfo| to the given view. |
| 721 - (NSButton*)addDeleteButtonForChosenObject:(ChosenObjectInfoPtr)objectInfo | 768 - (NSButton*)addDeleteButtonForChosenObject:(ChosenObjectInfoPtr)objectInfo |
| 722 toView:(NSView*)view | 769 toView:(NSView*)view |
| 723 atPoint:(NSPoint)point { | 770 atPoint:(NSPoint)point { |
| 724 __block WebsiteSettingsBubbleController* weakSelf = self; | 771 __block WebsiteSettingsBubbleController* weakSelf = self; |
| 725 auto callback = | 772 auto callback = |
| 726 base::BindBlock(^(const WebsiteSettingsUI::ChosenObjectInfo& objectInfo) { | 773 base::BindBlock(^(const WebsiteSettingsUI::ChosenObjectInfo& objectInfo) { |
| 727 [weakSelf onChosenObjectDeleted:objectInfo]; | 774 [weakSelf onChosenObjectDeleted:objectInfo]; |
| 728 }); | 775 }); |
| 729 base::scoped_nsobject<ChosenObjectDeleteButton> button( | 776 base::scoped_nsobject<ChosenObjectDeleteButton> button( |
| 730 [[ChosenObjectDeleteButton alloc] | 777 [[ChosenObjectDeleteButton alloc] |
| 731 initWithChosenObject:std::move(objectInfo) | 778 initWithChosenObject:std::move(objectInfo) |
| 732 atPoint:point | 779 atPoint:point |
| 733 withCallback:callback]); | 780 withCallback:callback]); |
| 734 | 781 |
| 735 // Ensure the containing view is large enough to contain the button. | 782 // Ensure the containing view is large enough to contain the button. |
| 736 NSRect containerFrame = [view frame]; | 783 NSRect containerFrame = [view frame]; |
| 737 containerFrame.size.width = | 784 containerFrame.size.width = |
| 738 std::max(NSWidth(containerFrame), | 785 std::max(NSWidth(containerFrame), point.x + kPermissionDeleteImageSize + |
| 739 point.x + kPermissionDeleteImageSize + kFramePadding); | 786 kSectionHorizontalPadding); |
| 740 [view setFrame:containerFrame]; | 787 [view setFrame:containerFrame]; |
| 741 [view addSubview:button.get()]; | 788 [view addSubview:button.get()]; |
| 742 return button.get(); | 789 return button.get(); |
| 743 } | 790 } |
| 744 | 791 |
| 745 // Called when the user changes the setting of a permission. | 792 // Called when the user changes the setting of a permission. |
| 746 - (void)onPermissionChanged:(ContentSettingsType)permissionType | 793 - (void)onPermissionChanged:(ContentSettingsType)permissionType |
| 747 to:(ContentSetting)newSetting { | 794 to:(ContentSetting)newSetting { |
| 748 if (presenter_) | 795 if (presenter_) |
| 749 presenter_->OnSitePermissionChanged(permissionType, newSetting); | 796 presenter_->OnSitePermissionChanged(permissionType, newSetting); |
| 750 } | 797 } |
| 751 | 798 |
| 752 // Called when the user revokes permission for a previously chosen object. | 799 // Called when the user revokes permission for a previously chosen object. |
| 753 - (void)onChosenObjectDeleted:(const WebsiteSettingsUI::ChosenObjectInfo&)info { | 800 - (void)onChosenObjectDeleted:(const WebsiteSettingsUI::ChosenObjectInfo&)info { |
| 754 if (presenter_) | 801 if (presenter_) |
| 755 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); | 802 presenter_->OnSiteChosenObjectDeleted(info.ui_info, *info.object); |
| 756 } | 803 } |
| 757 | 804 |
| 758 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the | 805 // Adds a new row to the UI listing the permissions. Returns the NSPoint of the |
| 759 // last UI element added (either the permission button, in LTR, or the text | 806 // last UI element added (either the permission button, in LTR, or the text |
| 760 // label, in RTL). | 807 // label, in RTL). |
| 761 - (NSPoint)addPermission: | 808 - (NSPoint)addPermission: |
| 762 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo | 809 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo |
| 763 toView:(NSView*)view | 810 toView:(NSView*)view |
| 764 atPoint:(NSPoint)point { | 811 atPoint:(NSPoint)point { |
| 765 base::string16 labelText = | 812 base::string16 labelText = |
| 766 WebsiteSettingsUI::PermissionTypeToUIString(permissionInfo.type) + | 813 WebsiteSettingsUI::PermissionTypeToUIString(permissionInfo.type); |
| 767 base::ASCIIToUTF16(":"); | 814 bool isRTL = base::i18n::IsRTL(); |
| 768 bool isRTL = | |
| 769 base::i18n::RIGHT_TO_LEFT == base::i18n::GetStringDirection(labelText); | |
| 770 base::scoped_nsobject<NSImage> image( | 815 base::scoped_nsobject<NSImage> image( |
| 771 [WebsiteSettingsUI::GetPermissionIcon(permissionInfo).ToNSImage() | 816 [WebsiteSettingsUI::GetPermissionIcon(permissionInfo).ToNSImage() |
| 772 retain]); | 817 retain]); |
| 773 | 818 |
| 774 NSPoint position; | 819 NSPoint position; |
| 775 NSImageView* imageView; | 820 NSImageView* imageView; |
| 776 NSPopUpButton* button; | 821 NSPopUpButton* button; |
| 777 NSTextField* label; | 822 NSTextField* label; |
| 778 | 823 |
| 779 CGFloat viewWidth = NSWidth([view frame]); | 824 CGFloat viewWidth = NSWidth([view frame]); |
| 780 | 825 |
| 781 if (isRTL) { | 826 if (isRTL) { |
| 782 point.x = NSWidth([view frame]) - kPermissionImageSize - | 827 point.x = NSWidth([view frame]) - kPermissionImageSize - |
| 783 kPermissionImageSpacing - kFramePadding; | 828 kPermissionImageSpacing - kSectionHorizontalPadding; |
| 784 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; | 829 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; |
| 785 [imageView setImage:image]; | 830 [imageView setImage:image]; |
| 786 point.x -= kPermissionImageSpacing; | 831 point.x -= kPermissionImageSpacing; |
| 787 | 832 |
| 788 label = [self addText:labelText | 833 label = [self addText:labelText |
| 789 withSize:[NSFont smallSystemFontSize] | 834 withSize:[NSFont systemFontSize] |
| 790 bold:NO | 835 bold:NO |
| 791 toView:view | 836 toView:view |
| 792 atPoint:point]; | 837 atPoint:point]; |
| 793 [label sizeToFit]; | 838 [label sizeToFit]; |
| 794 point.x -= NSWidth([label frame]); | 839 point.x -= NSWidth([label frame]); |
| 795 [label setFrameOrigin:point]; | 840 [label setFrameOrigin:point]; |
| 796 | 841 |
| 797 position = NSMakePoint(point.x, point.y); | 842 position = |
| 843 NSMakePoint(point.x, point.y + kPermissionPopupButtonYAdjustment); | |
| 798 button = [self addPopUpButtonForPermission:permissionInfo | 844 button = [self addPopUpButtonForPermission:permissionInfo |
| 799 toView:view | 845 toView:view |
| 800 atPoint:position]; | 846 atPoint:position]; |
| 801 position.x -= NSWidth([button frame]); | 847 position.x -= NSWidth([button frame]); |
| 802 [button setFrameOrigin:position]; | 848 [button setFrameOrigin:position]; |
| 803 } else { | 849 } else { |
| 804 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; | 850 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; |
| 805 [imageView setImage:image]; | 851 [imageView setImage:image]; |
| 806 point.x += kPermissionImageSize + kPermissionImageSpacing; | 852 point.x += kPermissionImageSize + kPermissionImageSpacing; |
| 807 | 853 |
| 808 label = [self addText:labelText | 854 label = [self addText:labelText |
| 809 withSize:[NSFont smallSystemFontSize] | 855 withSize:[NSFont systemFontSize] |
| 810 bold:NO | 856 bold:NO |
| 811 toView:view | 857 toView:view |
| 812 atPoint:point]; | 858 atPoint:point]; |
| 813 [label sizeToFit]; | 859 [label sizeToFit]; |
| 814 | 860 |
| 815 position = NSMakePoint(NSMaxX([label frame]), point.y); | 861 position = NSMakePoint(NSMaxX([label frame]), |
| 862 point.y + kPermissionPopupButtonYAdjustment); | |
| 863 | |
| 816 button = [self addPopUpButtonForPermission:permissionInfo | 864 button = [self addPopUpButtonForPermission:permissionInfo |
| 817 toView:view | 865 toView:view |
| 818 atPoint:position]; | 866 atPoint:position]; |
| 819 } | 867 } |
| 820 | 868 |
| 821 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; | 869 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; |
| 822 | 870 |
| 823 // Adjust the vertical position of the button so that its title text is | 871 // Adjust the vertical position of the button so that its title text is |
| 824 // aligned with the label. Assumes that the text is the same size in both. | 872 // aligned with the label. Assumes that the text is the same size in both. |
| 825 // Also adjust the horizontal position to remove excess space due to the | 873 // Also adjust the horizontal position to remove excess space due to the |
| 826 // invisible bezel. | 874 // invisible bezel. |
| 827 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; | 875 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; |
| 828 if (isRTL) { | 876 if (isRTL) { |
| 829 position.x += kPermissionPopUpXSpacing; | 877 position.x = kSectionHorizontalPadding; |
| 830 } else { | 878 } else { |
| 831 position.x -= titleRect.origin.x - kPermissionPopUpXSpacing; | 879 position.x = kDefaultWindowWidth - kSectionHorizontalPadding - |
| 880 [button frame].size.width; | |
| 832 } | 881 } |
| 833 position.y -= titleRect.origin.y; | 882 position.y -= titleRect.origin.y; |
| 834 [button setFrameOrigin:position]; | 883 [button setFrameOrigin:position]; |
| 835 | 884 |
| 836 // Align the icon with the text. | 885 // Align the icon with the text. |
| 837 [self alignPermissionIcon:imageView withTextField:label]; | 886 [self alignPermissionIcon:imageView withTextField:label]; |
| 838 | 887 |
| 839 // Permissions specified by policy or an extension cannot be changed. | 888 // Permissions specified by policy or an extension cannot be changed. |
| 840 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || | 889 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || |
| 841 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { | 890 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 863 | 912 |
| 864 NSPoint position; | 913 NSPoint position; |
| 865 NSImageView* imageView; | 914 NSImageView* imageView; |
| 866 NSButton* button; | 915 NSButton* button; |
| 867 NSTextField* label; | 916 NSTextField* label; |
| 868 | 917 |
| 869 CGFloat viewWidth = NSWidth([view frame]); | 918 CGFloat viewWidth = NSWidth([view frame]); |
| 870 | 919 |
| 871 if (isRTL) { | 920 if (isRTL) { |
| 872 point.x = NSWidth([view frame]) - kPermissionImageSize - | 921 point.x = NSWidth([view frame]) - kPermissionImageSize - |
| 873 kPermissionImageSpacing - kFramePadding; | 922 kPermissionImageSpacing - kSectionHorizontalPadding; |
| 874 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; | 923 imageView = [self addImageWithSize:[image size] toView:view atPoint:point]; |
| 875 [imageView setImage:image]; | 924 [imageView setImage:image]; |
| 876 point.x -= kPermissionImageSpacing; | 925 point.x -= kPermissionImageSpacing; |
| 877 | 926 |
| 878 label = [self addText:labelText | 927 label = [self addText:labelText |
| 879 withSize:[NSFont smallSystemFontSize] | 928 withSize:[NSFont smallSystemFontSize] |
| 880 bold:NO | 929 bold:NO |
| 881 toView:view | 930 toView:view |
| 882 atPoint:point]; | 931 atPoint:point]; |
| 883 [label sizeToFit]; | 932 [label sizeToFit]; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 909 } | 958 } |
| 910 | 959 |
| 911 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; | 960 [view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))]; |
| 912 | 961 |
| 913 // Adjust the vertical position of the button so that its title text is | 962 // Adjust the vertical position of the button so that its title text is |
| 914 // aligned with the label. Assumes that the text is the same size in both. | 963 // aligned with the label. Assumes that the text is the same size in both. |
| 915 // Also adjust the horizontal position to remove excess space due to the | 964 // Also adjust the horizontal position to remove excess space due to the |
| 916 // invisible bezel. | 965 // invisible bezel. |
| 917 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; | 966 NSRect titleRect = [[button cell] titleRectForBounds:[button bounds]]; |
| 918 if (isRTL) { | 967 if (isRTL) { |
| 919 position.x += kPermissionPopUpXSpacing; | 968 // position.x += BYEkPermissionPopUpXSpacing; // TODO |
|
Avi (use Gerrit)
2016/08/24 04:02:41
:( Can you not commit commented-out code?
lgarron
2016/08/26 23:27:04
I most certainly can! I mean, uh, can not. Am able
| |
| 920 } else { | |
| 921 position.x -= titleRect.origin.x - kPermissionPopUpXSpacing; | |
| 922 } | 969 } |
| 923 position.y -= titleRect.origin.y; | 970 position.y -= titleRect.origin.y; |
| 924 [button setFrameOrigin:position]; | 971 [button setFrameOrigin:position]; |
| 925 | 972 |
| 926 // Align the icon with the text. | 973 // Align the icon with the text. |
| 927 [self alignPermissionIcon:imageView withTextField:label]; | 974 [self alignPermissionIcon:imageView withTextField:label]; |
| 928 | 975 |
| 929 NSRect buttonFrame = [button frame]; | 976 NSRect buttonFrame = [button frame]; |
| 930 return NSMakePoint(NSMaxX(buttonFrame), NSMaxY(buttonFrame)); | 977 return NSMakePoint(NSMaxX(buttonFrame), NSMaxY(buttonFrame)); |
| 931 } | 978 } |
| 932 | 979 |
| 933 // Align an image with a text field by vertically centering the image on | 980 // Align an image with a text field by vertically centering the image on |
| 934 // the cap height of the first line of text. | 981 // the cap height of the first line of text. |
| 935 - (void)alignPermissionIcon:(NSImageView*)imageView | 982 - (void)alignPermissionIcon:(NSImageView*)imageView |
| 936 withTextField:(NSTextField*)textField { | 983 withTextField:(NSTextField*)textField { |
| 937 NSFont* font = [textField font]; | |
| 938 | |
| 939 // Calculate the offset from the top of the text field. | |
| 940 CGFloat capHeight = [font capHeight]; | |
| 941 CGFloat offset = (kPermissionImageSize - capHeight) / 2 - | |
| 942 ([font ascender] - capHeight) - kPermissionImageYAdjust; | |
| 943 | 984 |
| 944 NSRect frame = [imageView frame]; | 985 NSRect frame = [imageView frame]; |
| 945 frame.origin.y -= offset; | 986 frame.origin.y += kPermissionIconYAdjustment; |
| 946 [imageView setFrame:frame]; | 987 [imageView setFrame:frame]; |
| 947 } | 988 } |
| 948 | 989 |
| 949 - (void)setCookieInfo:(const CookieInfoList&)cookieInfoList { | 990 - (void)setCookieInfo:(const CookieInfoList&)cookieInfoList { |
| 950 // A result of re-ordering of the permissions (crbug.com/444244) is | 991 // A result of re-ordering of the permissions (crbug.com/444244) is |
| 951 // that sometimes permissions may not be displayed at all, so it's | 992 // that sometimes permissions may not be displayed at all, so it's |
| 952 // incorrect to check they are set before the cookie info. | 993 // incorrect to check they are set before the cookie info. |
| 953 | 994 |
| 954 // |cookieInfoList| should only ever have 2 items: first- and third-party | 995 // |cookieInfoList| should only ever have 2 items: first- and third-party |
| 955 // cookies. | 996 // cookies. |
| 956 DCHECK_EQ(cookieInfoList.size(), 2u); | 997 DCHECK_EQ(cookieInfoList.size(), 2u); |
| 957 base::string16 firstPartyLabelText; | 998 |
| 958 base::string16 thirdPartyLabelText; | 999 int totalAllowed = 0; |
| 959 for (const auto& i : cookieInfoList) { | 1000 for (const auto& i : cookieInfoList) { |
| 960 if (i.is_first_party) { | 1001 totalAllowed += i.allowed; |
| 961 firstPartyLabelText = l10n_util::GetPluralStringFUTF16( | |
| 962 IDS_WEBSITE_SETTINGS_FIRST_PARTY_SITE_DATA, i.allowed); | |
| 963 } else { | |
| 964 thirdPartyLabelText = l10n_util::GetPluralStringFUTF16( | |
| 965 IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA, i.allowed); | |
| 966 } | |
| 967 } | 1002 } |
| 1003 base::string16 label_text = l10n_util::GetPluralStringFUTF16( | |
| 1004 IDS_WEBSITE_SETTINGS_NUM_COOKIES, totalAllowed); | |
| 968 | 1005 |
| 969 base::string16 sectionTitle = | 1006 base::string16 sectionTitle = |
| 970 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA); | 1007 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA); |
| 971 bool isRTL = base::i18n::RIGHT_TO_LEFT == | 1008 bool isRTL = base::i18n::IsRTL(); |
| 972 base::i18n::GetStringDirection(firstPartyLabelText); | |
| 973 | 1009 |
| 974 [cookiesView_ setSubviews:[NSArray array]]; | 1010 [cookiesView_ setSubviews:[NSArray array]]; |
| 975 NSPoint controlOrigin = NSMakePoint(kFramePadding, 0); | 1011 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); |
| 976 | |
| 977 NSTextField* label; | |
| 978 | 1012 |
| 979 CGFloat viewWidth = NSWidth([cookiesView_ frame]); | 1013 CGFloat viewWidth = NSWidth([cookiesView_ frame]); |
| 980 | 1014 |
| 981 NSTextField* header = [self addText:sectionTitle | |
| 982 withSize:[NSFont smallSystemFontSize] | |
| 983 bold:YES | |
| 984 toView:cookiesView_ | |
| 985 atPoint:controlOrigin]; | |
| 986 [header sizeToFit]; | |
| 987 | |
| 988 if (isRTL) { | |
| 989 controlOrigin.x = viewWidth - kFramePadding - NSWidth([header frame]); | |
| 990 [header setFrameOrigin:controlOrigin]; | |
| 991 } | |
| 992 controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing; | |
| 993 controlOrigin.y += kPermissionsTabSpacing; | |
| 994 | |
| 995 // Reset X for the cookie image. | 1015 // Reset X for the cookie image. |
| 996 if (isRTL) { | 1016 if (isRTL) { |
| 997 controlOrigin.x = viewWidth - kPermissionImageSize - | 1017 controlOrigin.x = viewWidth - kPermissionImageSize - |
| 998 kPermissionImageSpacing - kFramePadding; | 1018 kPermissionImageSpacing - kSectionHorizontalPadding; |
| 999 } | 1019 } |
| 1000 | 1020 |
| 1001 WebsiteSettingsUI::PermissionInfo info; | 1021 WebsiteSettingsUI::PermissionInfo info; |
| 1002 info.type = CONTENT_SETTINGS_TYPE_COOKIES; | 1022 info.type = CONTENT_SETTINGS_TYPE_COOKIES; |
| 1003 info.setting = CONTENT_SETTING_ALLOW; | 1023 info.setting = CONTENT_SETTING_ALLOW; |
| 1004 // info.default_setting, info.source, and info.is_incognito have not been set, | 1024 // info.default_setting, info.source, and info.is_incognito have not been set, |
| 1005 // but GetPermissionIcon doesn't use any of those. | 1025 // but GetPermissionIcon doesn't use any of those. |
| 1006 NSImage* image = WebsiteSettingsUI::GetPermissionIcon(info).ToNSImage(); | 1026 NSImage* image = WebsiteSettingsUI::GetPermissionIcon(info).ToNSImage(); |
| 1007 NSImageView* imageView = [self addImageWithSize:[image size] | 1027 NSImageView* imageView = [self addImageWithSize:[image size] |
| 1008 toView:cookiesView_ | 1028 toView:cookiesView_ |
| 1009 atPoint:controlOrigin]; | 1029 atPoint:controlOrigin]; |
| 1010 [imageView setImage:image]; | 1030 [imageView setImage:image]; |
| 1011 | 1031 |
| 1012 base::string16 comma = base::ASCIIToUTF16(", "); | 1032 NSButton* cookiesButton = |
| 1013 NSString* cookieButtonText = base::SysUTF16ToNSString(firstPartyLabelText); | 1033 [self addLinkButtonWithText:base::SysUTF16ToNSString(label_text) |
| 1034 toView:cookiesView_]; | |
| 1035 [cookiesButton setTarget:self]; | |
| 1036 [cookiesButton setAction:@selector(showCookiesAndSiteData:)]; | |
| 1014 | 1037 |
| 1015 if (isRTL) { | 1038 if (isRTL) { |
| 1016 NSButton* cookiesButton = | 1039 controlOrigin.x -= kPermissionImageSpacing; |
| 1017 [self addLinkButtonWithText:cookieButtonText toView:cookiesView_]; | 1040 NSTextField* cookiesLabel = |
| 1018 [cookiesButton setTarget:self]; | 1041 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES) |
| 1019 [cookiesButton setAction:@selector(showCookiesAndSiteData:)]; | 1042 withSize:[NSFont systemFontSize] |
| 1020 controlOrigin.x -= NSWidth([cookiesButton frame]); | 1043 bold:NO |
| 1044 toView:cookiesView_ | |
| 1045 atPoint:controlOrigin]; | |
| 1046 [cookiesLabel sizeToFit]; | |
| 1047 | |
| 1048 NSPoint cookiesLabelOrigin = [cookiesLabel frame].origin; | |
| 1049 cookiesLabelOrigin.x -= NSWidth([cookiesLabel frame]); | |
| 1050 [cookiesLabel setFrameOrigin:cookiesLabelOrigin]; | |
| 1051 | |
| 1052 // Align the icon with the text. | |
| 1053 [self alignPermissionIcon:imageView withTextField:cookiesLabel]; | |
| 1054 | |
| 1055 controlOrigin.y += NSHeight([cookiesLabel frame]); | |
| 1056 controlOrigin.x -= NSWidth([cookiesButton frame]) - kLinkButtonXAdjustment; | |
| 1057 [cookiesButton setFrameOrigin:controlOrigin]; | |
| 1058 } else { | |
| 1059 controlOrigin.x += kPermissionImageSize + kPermissionImageSpacing; | |
| 1060 NSTextField* cookiesLabel = | |
| 1061 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_COOKIES) | |
| 1062 withSize:[NSFont systemFontSize] | |
| 1063 bold:NO | |
| 1064 toView:cookiesView_ | |
| 1065 atPoint:controlOrigin]; | |
| 1066 [cookiesLabel sizeToFit]; | |
| 1067 | |
| 1068 controlOrigin.y += NSHeight([cookiesLabel frame]); | |
| 1069 controlOrigin.x -= kLinkButtonXAdjustment; | |
| 1021 [cookiesButton setFrameOrigin:controlOrigin]; | 1070 [cookiesButton setFrameOrigin:controlOrigin]; |
| 1022 | 1071 |
| 1023 label = [self addText:comma + thirdPartyLabelText | 1072 // Align the icon with the text. |
| 1024 withSize:[NSFont smallSystemFontSize] | 1073 [self alignPermissionIcon:imageView withTextField:cookiesLabel]; |
| 1025 bold:NO | |
| 1026 toView:cookiesView_ | |
| 1027 atPoint:controlOrigin]; | |
| 1028 [label sizeToFit]; | |
| 1029 controlOrigin.x -= NSWidth([label frame]) - kTextLabelXPadding; | |
| 1030 [label setFrameOrigin:controlOrigin]; | |
| 1031 } else { | |
| 1032 controlOrigin.x += kPermissionImageSize + kPermissionImageSpacing; | |
| 1033 | |
| 1034 NSButton* cookiesButton = | |
| 1035 [self addLinkButtonWithText:cookieButtonText toView:cookiesView_]; | |
| 1036 [cookiesButton setTarget:self]; | |
| 1037 [cookiesButton setAction:@selector(showCookiesAndSiteData:)]; | |
| 1038 [cookiesButton setFrameOrigin:controlOrigin]; | |
| 1039 | |
| 1040 controlOrigin.x += NSWidth([cookiesButton frame]) - kTextLabelXPadding; | |
| 1041 | |
| 1042 label = [self addText:comma + thirdPartyLabelText | |
| 1043 withSize:[NSFont smallSystemFontSize] | |
| 1044 bold:NO | |
| 1045 toView:cookiesView_ | |
| 1046 atPoint:controlOrigin]; | |
| 1047 [label sizeToFit]; | |
| 1048 } | 1074 } |
| 1049 | 1075 |
| 1050 // Align the icon with the text. | 1076 controlOrigin.y += NSHeight([cookiesButton frame]); |
| 1051 [self alignPermissionIcon:imageView withTextField:label]; | 1077 [cookiesView_ |
| 1052 | 1078 setFrameSize:NSMakeSize(NSWidth([cookiesView_ frame]), controlOrigin.y)]; |
| 1053 controlOrigin.y += NSHeight([label frame]) + kPermissionsTabSpacing; | |
| 1054 | |
| 1055 [cookiesView_ setFrameSize: | |
| 1056 NSMakeSize(NSWidth([cookiesView_ frame]), controlOrigin.y)]; | |
| 1057 | 1079 |
| 1058 [self performLayout]; | 1080 [self performLayout]; |
| 1059 } | 1081 } |
| 1060 | 1082 |
| 1061 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList | 1083 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList |
| 1062 andChosenObjects:(const ChosenObjectInfoList&)chosenObjectInfoList { | 1084 andChosenObjects:(const ChosenObjectInfoList&)chosenObjectInfoList { |
| 1063 [permissionsView_ setSubviews:[NSArray array]]; | 1085 [permissionsView_ setSubviews:[NSArray array]]; |
| 1064 NSPoint controlOrigin = NSMakePoint(kFramePadding, 0); | 1086 NSPoint controlOrigin = NSMakePoint(kSectionHorizontalPadding, 0); |
| 1065 | 1087 |
| 1066 permissionsPresent_ = YES; | 1088 permissionsPresent_ = YES; |
| 1067 | 1089 |
| 1068 if (permissionInfoList.size() > 0 || chosenObjectInfoList.size() > 0) { | 1090 if (permissionInfoList.size() > 0 || chosenObjectInfoList.size() > 0) { |
| 1069 base::string16 sectionTitle = l10n_util::GetStringUTF16( | 1091 base::string16 sectionTitle = l10n_util::GetStringUTF16( |
| 1070 IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); | 1092 IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); |
| 1071 bool isRTL = base::i18n::RIGHT_TO_LEFT == | |
| 1072 base::i18n::GetStringDirection(sectionTitle); | |
| 1073 NSTextField* header = [self addText:sectionTitle | |
| 1074 withSize:[NSFont smallSystemFontSize] | |
| 1075 bold:YES | |
| 1076 toView:permissionsView_ | |
| 1077 atPoint:controlOrigin]; | |
| 1078 [header sizeToFit]; | |
| 1079 if (isRTL) { | |
| 1080 controlOrigin.x = NSWidth([permissionsView_ frame]) - kFramePadding - | |
| 1081 NSWidth([header frame]); | |
| 1082 [header setFrameOrigin:controlOrigin]; | |
| 1083 } | |
| 1084 controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing; | |
| 1085 | 1093 |
| 1086 for (const auto& permission : permissionInfoList) { | 1094 for (const auto& permission : permissionInfoList) { |
| 1087 controlOrigin.y += kPermissionsTabSpacing; | 1095 controlOrigin.y += kPermissionsVerticalSpacing; |
| 1088 NSPoint rowBottomRight = [self addPermission:permission | 1096 NSPoint rowBottomRight = [self addPermission:permission |
| 1089 toView:permissionsView_ | 1097 toView:permissionsView_ |
| 1090 atPoint:controlOrigin]; | 1098 atPoint:controlOrigin]; |
| 1091 controlOrigin.y = rowBottomRight.y; | 1099 controlOrigin.y = rowBottomRight.y; |
| 1092 } | 1100 } |
| 1093 | 1101 |
| 1094 for (auto* object : chosenObjectInfoList) { | 1102 for (auto* object : chosenObjectInfoList) { |
| 1095 controlOrigin.y += kPermissionsTabSpacing; | 1103 controlOrigin.y += kPermissionsVerticalSpacing; |
| 1096 NSPoint rowBottomRight = [self addChosenObject:base::WrapUnique(object) | 1104 NSPoint rowBottomRight = [self addChosenObject:base::WrapUnique(object) |
| 1097 toView:permissionsView_ | 1105 toView:permissionsView_ |
| 1098 atPoint:controlOrigin]; | 1106 atPoint:controlOrigin]; |
| 1099 controlOrigin.y = rowBottomRight.y; | 1107 controlOrigin.y = rowBottomRight.y; |
| 1100 } | 1108 } |
| 1101 | 1109 |
| 1102 controlOrigin.y += kFramePadding; | 1110 controlOrigin.y += kSectionHorizontalPadding; |
| 1103 } | 1111 } |
| 1104 | 1112 |
| 1105 [permissionsView_ setFrameSize: | 1113 [permissionsView_ setFrameSize: |
| 1106 NSMakeSize(NSWidth([permissionsView_ frame]), controlOrigin.y)]; | 1114 NSMakeSize(NSWidth([permissionsView_ frame]), controlOrigin.y)]; |
| 1107 [self performLayout]; | 1115 [self performLayout]; |
| 1108 } | 1116 } |
| 1109 | 1117 |
| 1110 @end | 1118 @end |
| 1111 | 1119 |
| 1112 WebsiteSettingsUIBridge::WebsiteSettingsUIBridge( | 1120 WebsiteSettingsUIBridge::WebsiteSettingsUIBridge( |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1196 void WebsiteSettingsUIBridge::SetPermissionInfo( | 1204 void WebsiteSettingsUIBridge::SetPermissionInfo( |
| 1197 const PermissionInfoList& permission_info_list, | 1205 const PermissionInfoList& permission_info_list, |
| 1198 const ChosenObjectInfoList& chosen_object_info_list) { | 1206 const ChosenObjectInfoList& chosen_object_info_list) { |
| 1199 [bubble_controller_ setPermissionInfo:permission_info_list | 1207 [bubble_controller_ setPermissionInfo:permission_info_list |
| 1200 andChosenObjects:chosen_object_info_list]; | 1208 andChosenObjects:chosen_object_info_list]; |
| 1201 } | 1209 } |
| 1202 | 1210 |
| 1203 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { | 1211 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { |
| 1204 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) | 1212 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) |
| 1205 } | 1213 } |
| OLD | NEW |