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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 bridge:(PermissionBubbleCocoa*)bridge { | 229 bridge:(PermissionBubbleCocoa*)bridge { |
230 DCHECK(parentWindow); | 230 DCHECK(parentWindow); |
231 DCHECK(bridge); | 231 DCHECK(bridge); |
232 base::scoped_nsobject<PermissionBubbleWindow> window( | 232 base::scoped_nsobject<PermissionBubbleWindow> window( |
233 [[PermissionBubbleWindow alloc] | 233 [[PermissionBubbleWindow alloc] |
234 initWithContentRect:ui::kWindowSizeDeterminedLater | 234 initWithContentRect:ui::kWindowSizeDeterminedLater |
235 styleMask:NSBorderlessWindowMask | 235 styleMask:NSBorderlessWindowMask |
236 backing:NSBackingStoreBuffered | 236 backing:NSBackingStoreBuffered |
237 defer:NO]); | 237 defer:NO]); |
238 [window setAllowedAnimations:info_bubble::kAnimateNone]; | 238 [window setAllowedAnimations:info_bubble::kAnimateNone]; |
| 239 [window setReleasedWhenClosed:NO]; |
239 if ((self = [super initWithWindow:window | 240 if ((self = [super initWithWindow:window |
240 parentWindow:parentWindow | 241 parentWindow:parentWindow |
241 anchoredAt:NSZeroPoint])) { | 242 anchoredAt:NSZeroPoint])) { |
242 [self setShouldCloseOnResignKey:NO]; | 243 [self setShouldCloseOnResignKey:NO]; |
243 [self setShouldOpenAsKeyWindow:NO]; | 244 [self setShouldOpenAsKeyWindow:NO]; |
244 [[self bubble] setArrowLocation:info_bubble::kTopLeft]; | 245 [[self bubble] setArrowLocation:info_bubble::kTopLeft]; |
245 bridge_ = bridge; | 246 bridge_ = bridge; |
246 } | 247 } |
247 return self; | 248 return self; |
248 } | 249 } |
249 | 250 |
250 - (void)windowWillClose:(NSNotification*)notification { | 251 - (void)windowWillClose:(NSNotification*)notification { |
251 bridge_->OnBubbleClosing(); | 252 bridge_->OnBubbleClosing(); |
252 [super windowWillClose:notification]; | 253 [super windowWillClose:notification]; |
253 } | 254 } |
254 | 255 |
| 256 - (void)parentWindowWillBecomeFullScreen:(NSNotification*)notification { |
| 257 // Override the base class implementation, which would have closed the bubble. |
| 258 } |
| 259 |
| 260 - (void)parentWindowDidResize:(NSNotification*)notification { |
| 261 DCHECK(bridge_); |
| 262 [self setAnchorPoint:bridge_->GetAnchorPoint()]; |
| 263 } |
| 264 |
255 - (void)showAtAnchor:(NSPoint)anchorPoint | 265 - (void)showAtAnchor:(NSPoint)anchorPoint |
256 withDelegate:(PermissionBubbleView::Delegate*)delegate | 266 withDelegate:(PermissionBubbleView::Delegate*)delegate |
257 forRequests:(const std::vector<PermissionBubbleRequest*>&)requests | 267 forRequests:(const std::vector<PermissionBubbleRequest*>&)requests |
258 acceptStates:(const std::vector<bool>&)acceptStates | 268 acceptStates:(const std::vector<bool>&)acceptStates |
259 customizationMode:(BOOL)customizationMode { | 269 customizationMode:(BOOL)customizationMode { |
260 DCHECK(!requests.empty()); | 270 DCHECK(!requests.empty()); |
261 DCHECK(delegate); | 271 DCHECK(delegate); |
262 DCHECK(!customizationMode || (requests.size() == acceptStates.size())); | 272 DCHECK(!customizationMode || (requests.size() == acceptStates.size())); |
263 delegate_ = delegate; | 273 delegate_ = delegate; |
264 | 274 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 586 |
577 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { | 587 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { |
578 NSRect frameA = [viewA frame]; | 588 NSRect frameA = [viewA frame]; |
579 NSRect frameB = [viewB frame]; | 589 NSRect frameB = [viewB frame]; |
580 frameA.origin.y = | 590 frameA.origin.y = |
581 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); | 591 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); |
582 [viewA setFrameOrigin:frameA.origin]; | 592 [viewA setFrameOrigin:frameA.origin]; |
583 } | 593 } |
584 | 594 |
585 @end // implementation PermissionBubbleController | 595 @end // implementation PermissionBubbleController |
OLD | NEW |