Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(836)

Side by Side Diff: chrome/browser/ui/cocoa/base_bubble_controller.mm

Issue 300113009: Fix BaseBubbleController close issue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit_test Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 until
Robert Sesek 2014/06/05 14:22:50 nit: exec -> execute/run. We don't abbreviate in c
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];
252 } 253 }
254 }
Robert Sesek 2014/06/05 14:22:50 nit: indent 1 more space
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698