| 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/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 340 } |
| 341 | 341 |
| 342 // Since the bubble shares first responder with its parent window, set event | 342 // Since the bubble shares first responder with its parent window, set event |
| 343 // handlers to dismiss the bubble when it would normally lose key state. | 343 // handlers to dismiss the bubble when it would normally lose key state. |
| 344 // Events on sheets are ignored: this assumes the sheet belongs to the bubble | 344 // Events on sheets are ignored: this assumes the sheet belongs to the bubble |
| 345 // since, to affect a sheet on a different window, the bubble would also lose | 345 // since, to affect a sheet on a different window, the bubble would also lose |
| 346 // key status in -[NSWindowDelegate windowDidResignKey:]. This keeps the logic | 346 // key status in -[NSWindowDelegate windowDidResignKey:]. This keeps the logic |
| 347 // simple, since -[NSWindow attachedSheet] returns nil while the sheet is still | 347 // simple, since -[NSWindow attachedSheet] returns nil while the sheet is still |
| 348 // closing. | 348 // closing. |
| 349 - (void)registerKeyStateEventTap { | 349 - (void)registerKeyStateEventTap { |
| 350 // Parent key state sharing is only avaiable on 10.7+. | |
| 351 if (!base::mac::IsOSLionOrLater()) | |
| 352 return; | |
| 353 | |
| 354 NSWindow* window = self.window; | 350 NSWindow* window = self.window; |
| 355 NSNotification* note = | 351 NSNotification* note = |
| 356 [NSNotification notificationWithName:NSWindowDidResignKeyNotification | 352 [NSNotification notificationWithName:NSWindowDidResignKeyNotification |
| 357 object:window]; | 353 object:window]; |
| 358 | 354 |
| 359 // The eventTap_ catches clicks within the application that are outside the | 355 // The eventTap_ catches clicks within the application that are outside the |
| 360 // window. | 356 // window. |
| 361 eventTap_ = [NSEvent | 357 eventTap_ = [NSEvent |
| 362 addLocalMonitorForEventsMatchingMask:NSLeftMouseDownMask | | 358 addLocalMonitorForEventsMatchingMask:NSLeftMouseDownMask | |
| 363 NSRightMouseDownMask | 359 NSRightMouseDownMask |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 444 |
| 449 - (void)activateTabWithContents:(content::WebContents*)newContents | 445 - (void)activateTabWithContents:(content::WebContents*)newContents |
| 450 previousContents:(content::WebContents*)oldContents | 446 previousContents:(content::WebContents*)oldContents |
| 451 atIndex:(NSInteger)index | 447 atIndex:(NSInteger)index |
| 452 reason:(int)reason { | 448 reason:(int)reason { |
| 453 // The user switched tabs; close. | 449 // The user switched tabs; close. |
| 454 [self closeBubble]; | 450 [self closeBubble]; |
| 455 } | 451 } |
| 456 | 452 |
| 457 @end // BaseBubbleController | 453 @end // BaseBubbleController |
| OLD | NEW |