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

Unified Diff: chrome/browser/ui/cocoa/info_bubble_view.mm

Issue 1580943006: Ignore key commands in closed windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/info_bubble_view.mm
diff --git a/chrome/browser/ui/cocoa/info_bubble_view.mm b/chrome/browser/ui/cocoa/info_bubble_view.mm
index 90f89e971ac5ea75588909aed0593de66075bba1..81eade77d4e0d81c36eafcffdbca58452dc398a5 100644
--- a/chrome/browser/ui/cocoa/info_bubble_view.mm
+++ b/chrome/browser/ui/cocoa/info_bubble_view.mm
@@ -5,6 +5,8 @@
#import "chrome/browser/ui/cocoa/info_bubble_view.h"
#include "base/logging.h"
+#include "base/mac/foundation_util.h"
+#import "chrome/browser/ui/cocoa/info_bubble_window.h"
#import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect.h"
@implementation InfoBubbleView
@@ -23,6 +25,24 @@
return self;
}
+- (BOOL)performKeyEquivalent:(NSEvent *)event {
+ InfoBubbleWindow* info_bubble_window =
+ base::mac::ObjCCast<InfoBubbleWindow>([self window]);
+ if (info_bubble_window && [info_bubble_window isClosing]) {
+ // When a keyboard shortcut is pressed, the method that handles it is
+ // -[NSApplication _handleKeyEquivalent:], which calls the
+ // -performKeyEquivalent methods on all windows in the window list, whether
Robert Sesek 2016/01/13 21:39:50 If this is sent to all windows, why not no-op this
Avi (use Gerrit) 2016/01/13 21:53:20 Because -[NSView performKeyEquivalent] is official
+ // they are open or closed, shown or hidden, active or dying. If a bubble
+ // window is closed but lingers in an autorelease pool, it might receive
+ // unexpected requests for key commands; see <http://crbug.com/574798> for
+ // an example. In such a case, make sure the key equivalent search stops
+ // here rather than proceeding down the view hierarchy and tickling stale
+ // pointers.
+ return NO;
+ }
+ return [super performKeyEquivalent:event];
+}
+
- (void)drawRect:(NSRect)rect {
// Make room for the border to be seen.
NSRect bounds = [self bounds];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698