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/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 defer:NO]); | 237 defer:NO]); |
238 [window setAllowedAnimations:info_bubble::kAnimateNone]; | 238 [window setAllowedAnimations:info_bubble::kAnimateNone]; |
239 [window setReleasedWhenClosed:NO]; | 239 [window setReleasedWhenClosed:NO]; |
240 if ((self = [super initWithWindow:window | 240 if ((self = [super initWithWindow:window |
241 parentWindow:parentWindow | 241 parentWindow:parentWindow |
242 anchoredAt:NSZeroPoint])) { | 242 anchoredAt:NSZeroPoint])) { |
243 [self setShouldCloseOnResignKey:NO]; | 243 [self setShouldCloseOnResignKey:NO]; |
244 [self setShouldOpenAsKeyWindow:NO]; | 244 [self setShouldOpenAsKeyWindow:NO]; |
245 [[self bubble] setArrowLocation:info_bubble::kTopLeft]; | 245 [[self bubble] setArrowLocation:info_bubble::kTopLeft]; |
246 bridge_ = bridge; | 246 bridge_ = bridge; |
| 247 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 248 [center addObserver:self |
| 249 selector:@selector(parentWindowDidMove:) |
| 250 name:NSWindowDidMoveNotification |
| 251 object:parentWindow]; |
247 } | 252 } |
248 return self; | 253 return self; |
249 } | 254 } |
250 | 255 |
251 - (void)windowWillClose:(NSNotification*)notification { | 256 - (void)windowWillClose:(NSNotification*)notification { |
252 bridge_->OnBubbleClosing(); | 257 bridge_->OnBubbleClosing(); |
253 [super windowWillClose:notification]; | 258 [super windowWillClose:notification]; |
254 } | 259 } |
255 | 260 |
256 - (void)parentWindowWillBecomeFullScreen:(NSNotification*)notification { | 261 - (void)parentWindowWillBecomeFullScreen:(NSNotification*)notification { |
257 // Override the base class implementation, which would have closed the bubble. | 262 // Override the base class implementation, which would have closed the bubble. |
258 } | 263 } |
259 | 264 |
260 - (void)parentWindowDidResize:(NSNotification*)notification { | 265 - (void)parentWindowDidResize:(NSNotification*)notification { |
261 DCHECK(bridge_); | 266 DCHECK(bridge_); |
262 [self setAnchorPoint:bridge_->GetAnchorPoint()]; | 267 [self setAnchorPoint:bridge_->GetAnchorPoint()]; |
263 } | 268 } |
264 | 269 |
| 270 - (void)parentWindowDidMove:(NSNotification*)notification { |
| 271 DCHECK(bridge_); |
| 272 [self setAnchorPoint:bridge_->GetAnchorPoint()]; |
| 273 } |
| 274 |
265 - (void)showAtAnchor:(NSPoint)anchorPoint | 275 - (void)showAtAnchor:(NSPoint)anchorPoint |
266 withDelegate:(PermissionBubbleView::Delegate*)delegate | 276 withDelegate:(PermissionBubbleView::Delegate*)delegate |
267 forRequests:(const std::vector<PermissionBubbleRequest*>&)requests | 277 forRequests:(const std::vector<PermissionBubbleRequest*>&)requests |
268 acceptStates:(const std::vector<bool>&)acceptStates | 278 acceptStates:(const std::vector<bool>&)acceptStates |
269 customizationMode:(BOOL)customizationMode { | 279 customizationMode:(BOOL)customizationMode { |
270 DCHECK(!requests.empty()); | 280 DCHECK(!requests.empty()); |
271 DCHECK(delegate); | 281 DCHECK(delegate); |
272 DCHECK(!customizationMode || (requests.size() == acceptStates.size())); | 282 DCHECK(!customizationMode || (requests.size() == acceptStates.size())); |
273 delegate_ = delegate; | 283 delegate_ = delegate; |
274 | 284 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 | 596 |
587 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { | 597 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { |
588 NSRect frameA = [viewA frame]; | 598 NSRect frameA = [viewA frame]; |
589 NSRect frameB = [viewB frame]; | 599 NSRect frameB = [viewB frame]; |
590 frameA.origin.y = | 600 frameA.origin.y = |
591 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); | 601 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); |
592 [viewA setFrameOrigin:frameA.origin]; | 602 [viewA setFrameOrigin:frameA.origin]; |
593 } | 603 } |
594 | 604 |
595 @end // implementation PermissionBubbleController | 605 @end // implementation PermissionBubbleController |
OLD | NEW |