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/permission_bubble_controller.h
" | 5 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h
" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/mac/bind_objc_block.h" | 9 #include "base/mac/bind_objc_block.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 } | 333 } |
334 maxPermissionLineWidth = std::max( | 334 maxPermissionLineWidth = std::max( |
335 maxPermissionLineWidth, NSMaxX([permissionView frame])); | 335 maxPermissionLineWidth, NSMaxX([permissionView frame])); |
336 yOffset += NSHeight([permissionView frame]); | 336 yOffset += NSHeight([permissionView frame]); |
337 | 337 |
338 // Add extra padding for all but first permission. | 338 // Add extra padding for all but first permission. |
339 verticalPadding = kVerticalPermissionPadding; | 339 verticalPadding = kVerticalPermissionPadding; |
340 } | 340 } |
341 | 341 |
342 base::scoped_nsobject<NSView> titleView( | 342 base::scoped_nsobject<NSView> titleView( |
343 [[self titleWithHostname:requests[0]->GetRequestingHostname().host()] | 343 [[self titleWithHostname:requests[0]->GetOrigin().host()] retain]); |
344 retain]); | |
345 [contentView addSubview:titleView]; | 344 [contentView addSubview:titleView]; |
346 [titleView setFrameOrigin:NSMakePoint(kHorizontalPadding, | 345 [titleView setFrameOrigin:NSMakePoint(kHorizontalPadding, |
347 kVerticalPadding + yOffset)]; | 346 kVerticalPadding + yOffset)]; |
348 | 347 |
349 // 'x' button in the upper-right-hand corner. | 348 // 'x' button in the upper-right-hand corner. |
350 base::scoped_nsobject<NSView> closeButton([[self closeButton] retain]); | 349 base::scoped_nsobject<NSView> closeButton([[self closeButton] retain]); |
351 | 350 |
352 // Determine the dimensions of the bubble. | 351 // Determine the dimensions of the bubble. |
353 // Once the height and width are set, the buttons and permission menus can | 352 // Once the height and width are set, the buttons and permission menus can |
354 // be laid out correctly. | 353 // be laid out correctly. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 NSHeight(titleFrame))]; | 533 NSHeight(titleFrame))]; |
535 return titleView.autorelease(); | 534 return titleView.autorelease(); |
536 } | 535 } |
537 | 536 |
538 - (NSView*)menuForRequest:(PermissionBubbleRequest*)request | 537 - (NSView*)menuForRequest:(PermissionBubbleRequest*)request |
539 atIndex:(int)index | 538 atIndex:(int)index |
540 allow:(BOOL)allow { | 539 allow:(BOOL)allow { |
541 DCHECK(request); | 540 DCHECK(request); |
542 DCHECK(delegate_); | 541 DCHECK(delegate_); |
543 base::scoped_nsobject<AllowBlockMenuButton> button( | 542 base::scoped_nsobject<AllowBlockMenuButton> button( |
544 [[AllowBlockMenuButton alloc] initForURL:request->GetRequestingHostname() | 543 [[AllowBlockMenuButton alloc] initForURL:request->GetOrigin() |
545 allowed:allow | 544 allowed:allow |
546 index:index | 545 index:index |
547 delegate:delegate_]); | 546 delegate:delegate_]); |
548 return button.autorelease(); | 547 return button.autorelease(); |
549 } | 548 } |
550 | 549 |
551 - (NSView*)buttonWithTitle:(NSString*)title | 550 - (NSView*)buttonWithTitle:(NSString*)title |
552 action:(SEL)action { | 551 action:(SEL)action { |
553 base::scoped_nsobject<NSButton> button( | 552 base::scoped_nsobject<NSButton> button( |
554 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); | 553 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 614 |
616 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { | 615 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { |
617 NSRect frameA = [viewA frame]; | 616 NSRect frameA = [viewA frame]; |
618 NSRect frameB = [viewB frame]; | 617 NSRect frameB = [viewB frame]; |
619 frameA.origin.y = | 618 frameA.origin.y = |
620 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); | 619 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); |
621 [viewA setFrameOrigin:frameA.origin]; | 620 [viewA setFrameOrigin:frameA.origin]; |
622 } | 621 } |
623 | 622 |
624 @end // implementation PermissionBubbleController | 623 @end // implementation PermissionBubbleController |
OLD | NEW |