| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 bridge_->OnBubbleClosing(); | 256 bridge_->OnBubbleClosing(); |
| 257 [super windowWillClose:notification]; | 257 [super windowWillClose:notification]; |
| 258 } | 258 } |
| 259 | 259 |
| 260 - (void)parentWindowWillToggleFullScreen:(NSNotification*)notification { | 260 - (void)parentWindowWillToggleFullScreen:(NSNotification*)notification { |
| 261 // Override the base class implementation, which would have closed the bubble. | 261 // Override the base class implementation, which would have closed the bubble. |
| 262 } | 262 } |
| 263 | 263 |
| 264 - (void)parentWindowDidResize:(NSNotification*)notification { | 264 - (void)parentWindowDidResize:(NSNotification*)notification { |
| 265 DCHECK(bridge_); | 265 DCHECK(bridge_); |
| 266 [self setAnchorPoint:[self getExpectedAnchorPoint]]; | 266 [self updateAnchorPosition]; |
| 267 } | 267 } |
| 268 | 268 |
| 269 - (void)parentWindowDidMove:(NSNotification*)notification { | 269 - (void)parentWindowDidMove:(NSNotification*)notification { |
| 270 DCHECK(bridge_); | 270 DCHECK(bridge_); |
| 271 [self setAnchorPoint:[self getExpectedAnchorPoint]]; | 271 [self setAnchorPoint:[self getExpectedAnchorPoint]]; |
| 272 } | 272 } |
| 273 | 273 |
| 274 - (void)showWithDelegate:(PermissionBubbleView::Delegate*)delegate | 274 - (void)showWithDelegate:(PermissionBubbleView::Delegate*)delegate |
| 275 forRequests:(const std::vector<PermissionBubbleRequest*>&)requests | 275 forRequests:(const std::vector<PermissionBubbleRequest*>&)requests |
| 276 acceptStates:(const std::vector<bool>&)acceptStates { | 276 acceptStates:(const std::vector<bool>&)acceptStates { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 [self setAnchorPoint:[self getExpectedAnchorPoint]]; | 426 [self setAnchorPoint:[self getExpectedAnchorPoint]]; |
| 427 [self showWindow:nil]; | 427 [self showWindow:nil]; |
| 428 [[self window] makeFirstResponder:nil]; | 428 [[self window] makeFirstResponder:nil]; |
| 429 [[self window] setInitialFirstResponder:allowOrOkButton.get()]; | 429 [[self window] setInitialFirstResponder:allowOrOkButton.get()]; |
| 430 } | 430 } |
| 431 } | 431 } |
| 432 | 432 |
| 433 - (void)updateAnchorPosition { | 433 - (void)updateAnchorPosition { |
| 434 [self setParentWindow:[self getExpectedParentWindow]]; | 434 [self setParentWindow:[self getExpectedParentWindow]]; |
| 435 [self setAnchorPoint:[self getExpectedAnchorPoint]]; | 435 [self setAnchorPoint:[self getExpectedAnchorPoint]]; |
| 436 [[self bubble] setArrowLocation:[self getExpectedArrowLocation]]; |
| 436 } | 437 } |
| 437 | 438 |
| 438 - (NSPoint)getExpectedAnchorPoint { | 439 - (NSPoint)getExpectedAnchorPoint { |
| 439 NSPoint anchor; | 440 NSPoint anchor; |
| 440 if ([self hasVisibleLocationBar]) { | 441 if ([self hasVisibleLocationBar]) { |
| 441 LocationBarViewMac* location_bar = | 442 LocationBarViewMac* location_bar = |
| 442 [[[self getExpectedParentWindow] windowController] locationBarBridge]; | 443 [[[self getExpectedParentWindow] windowController] locationBarBridge]; |
| 443 anchor = location_bar->GetPageInfoBubblePoint(); | 444 anchor = location_bar->GetPageInfoBubblePoint(); |
| 444 } else { | 445 } else { |
| 445 // Center the bubble if there's no location bar. | 446 // Center the bubble if there's no location bar. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 630 |
| 630 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { | 631 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { |
| 631 NSRect frameA = [viewA frame]; | 632 NSRect frameA = [viewA frame]; |
| 632 NSRect frameB = [viewB frame]; | 633 NSRect frameB = [viewB frame]; |
| 633 frameA.origin.y = | 634 frameA.origin.y = |
| 634 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); | 635 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); |
| 635 [viewA setFrameOrigin:frameA.origin]; | 636 [viewA setFrameOrigin:frameA.origin]; |
| 636 } | 637 } |
| 637 | 638 |
| 638 @end // implementation PermissionBubbleController | 639 @end // implementation PermissionBubbleController |
| OLD | NEW |