| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/memory/scoped_nsobject.h" | 9 #include "base/memory/scoped_nsobject.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // position). We cannot have an addChildWindow: and a subsequent | 150 // position). We cannot have an addChildWindow: and a subsequent |
| 151 // showWindow:. Thus, we have our own version. | 151 // showWindow:. Thus, we have our own version. |
| 152 - (void)showWindow:(id)sender { | 152 - (void)showWindow:(id)sender { |
| 153 NSWindow* window = [self window]; // completes nib load | 153 NSWindow* window = [self window]; // completes nib load |
| 154 [self updateOriginFromAnchor]; | 154 [self updateOriginFromAnchor]; |
| 155 [parentWindow_ addChildWindow:window ordered:NSWindowAbove]; | 155 [parentWindow_ addChildWindow:window ordered:NSWindowAbove]; |
| 156 [window makeKeyAndOrderFront:self]; | 156 [window makeKeyAndOrderFront:self]; |
| 157 } | 157 } |
| 158 | 158 |
| 159 - (void)close { | 159 - (void)close { |
| 160 [parentWindow_ removeChildWindow:[self window]]; | 160 [[[self window] parentWindow] removeChildWindow:[self window]]; |
| 161 [super close]; | 161 [super close]; |
| 162 } | 162 } |
| 163 | 163 |
| 164 // The controller is the delegate of the window so it receives did resign key | 164 // The controller is the delegate of the window so it receives did resign key |
| 165 // notifications. When key is resigned mirror Windows behavior and close the | 165 // notifications. When key is resigned mirror Windows behavior and close the |
| 166 // window. | 166 // window. |
| 167 - (void)windowDidResignKey:(NSNotification*)notification { | 167 - (void)windowDidResignKey:(NSNotification*)notification { |
| 168 NSWindow* window = [self window]; | 168 NSWindow* window = [self window]; |
| 169 DCHECK_EQ([notification object], window); | 169 DCHECK_EQ([notification object], window); |
| 170 if ([window isVisible]) { | 170 if ([window isVisible]) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 191 if ([bubble_ arrowLocation] == info_bubble::kTopRight) { | 191 if ([bubble_ arrowLocation] == info_bubble::kTopRight) { |
| 192 origin.x -= NSWidth([window frame]) - offsets.width; | 192 origin.x -= NSWidth([window frame]) - offsets.width; |
| 193 } else { | 193 } else { |
| 194 origin.x -= offsets.width; | 194 origin.x -= offsets.width; |
| 195 } | 195 } |
| 196 origin.y -= NSHeight([window frame]); | 196 origin.y -= NSHeight([window frame]); |
| 197 [window setFrameOrigin:origin]; | 197 [window setFrameOrigin:origin]; |
| 198 } | 198 } |
| 199 | 199 |
| 200 @end // BaseBubbleController | 200 @end // BaseBubbleController |
| OLD | NEW |