OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 return; | 234 return; |
235 | 235 |
236 NSWindow* window = self.window; | 236 NSWindow* window = self.window; |
237 NSNotification* note = | 237 NSNotification* note = |
238 [NSNotification notificationWithName:NSWindowDidResignKeyNotification | 238 [NSNotification notificationWithName:NSWindowDidResignKeyNotification |
239 object:window]; | 239 object:window]; |
240 | 240 |
241 // The eventTap_ catches clicks within the application that are outside the | 241 // The eventTap_ catches clicks within the application that are outside the |
242 // window. | 242 // window. |
243 eventTap_ = [NSEvent | 243 eventTap_ = [NSEvent |
244 addLocalMonitorForEventsMatchingMask:NSLeftMouseDownMask | 244 addLocalMonitorForEventsMatchingMask:NSLeftMouseDownMask | |
245 NSRightMouseDownMask | |
245 handler:^NSEvent* (NSEvent* event) { | 246 handler:^NSEvent* (NSEvent* event) { |
246 if (event.window != window) { | 247 if (event.window != window) { |
247 // Call via the runloop because this block is called in the | 248 // Do it right now, because if this event is right mouse event, |
248 // middle of event dispatch. | 249 // it may pop up a menu. windowDidResignKey will not exec untill |
Nico
2014/05/28 08:50:15
typo "until"
Robert Sesek
2014/05/28 19:47:03
nit: add a : after windowDidResignKey (it's part o
| |
249 [self performSelector:@selector(windowDidResignKey:) | 250 // the menu is closed. |
250 withObject:note | 251 if ([self respondsToSelector:@selector(windowDidResignKey:)]) { |
251 afterDelay:0]; | 252 [self windowDidResignKey:note]; |
Nico
2014/05/28 08:50:15
nit: this should be indented only 2 relative to th
| |
252 } | 253 } |
254 } | |
253 return event; | 255 return event; |
254 }]; | 256 }]; |
255 | 257 |
256 // The resignationObserver_ watches for when a window resigns key state, | 258 // The resignationObserver_ watches for when a window resigns key state, |
257 // meaning the key window has changed and the bubble should be dismissed. | 259 // meaning the key window has changed and the bubble should be dismissed. |
258 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 260 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
259 resignationObserver_ = | 261 resignationObserver_ = |
260 [center addObserverForName:NSWindowDidResignKeyNotification | 262 [center addObserverForName:NSWindowDidResignKeyNotification |
261 object:nil | 263 object:nil |
262 queue:[NSOperationQueue mainQueue] | 264 queue:[NSOperationQueue mainQueue] |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 | 329 |
328 - (void)activateTabWithContents:(content::WebContents*)newContents | 330 - (void)activateTabWithContents:(content::WebContents*)newContents |
329 previousContents:(content::WebContents*)oldContents | 331 previousContents:(content::WebContents*)oldContents |
330 atIndex:(NSInteger)index | 332 atIndex:(NSInteger)index |
331 reason:(int)reason { | 333 reason:(int)reason { |
332 // The user switched tabs; close. | 334 // The user switched tabs; close. |
333 [self close]; | 335 [self close]; |
334 } | 336 } |
335 | 337 |
336 @end // BaseBubbleController | 338 @end // BaseBubbleController |
OLD | NEW |