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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/info_bubble_view.h" 5 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h"
9 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
8 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect .h" 10 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect .h"
9 11
10 @implementation InfoBubbleView 12 @implementation InfoBubbleView
11 13
12 @synthesize arrowLocation = arrowLocation_; 14 @synthesize arrowLocation = arrowLocation_;
13 @synthesize alignment = alignment_; 15 @synthesize alignment = alignment_;
14 @synthesize cornerFlags = cornerFlags_; 16 @synthesize cornerFlags = cornerFlags_;
15 17
16 - (id)initWithFrame:(NSRect)frameRect { 18 - (id)initWithFrame:(NSRect)frameRect {
17 if ((self = [super initWithFrame:frameRect])) { 19 if ((self = [super initWithFrame:frameRect])) {
18 arrowLocation_ = info_bubble::kTopLeft; 20 arrowLocation_ = info_bubble::kTopLeft;
19 alignment_ = info_bubble::kAlignArrowToAnchor; 21 alignment_ = info_bubble::kAlignArrowToAnchor;
20 cornerFlags_ = info_bubble::kRoundedAllCorners; 22 cornerFlags_ = info_bubble::kRoundedAllCorners;
21 backgroundColor_.reset([[NSColor whiteColor] retain]); 23 backgroundColor_.reset([[NSColor whiteColor] retain]);
22 } 24 }
23 return self; 25 return self;
24 } 26 }
25 27
28 - (BOOL)performKeyEquivalent:(NSEvent *)event {
29 InfoBubbleWindow* info_bubble_window =
30 base::mac::ObjCCast<InfoBubbleWindow>([self window]);
31 if (info_bubble_window && [info_bubble_window isClosing]) {
32 // When a keyboard shortcut is pressed, the method that handles it is
33 // -[NSApplication _handleKeyEquivalent:], which calls the
34 // -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
35 // they are open or closed, shown or hidden, active or dying. If a bubble
36 // window is closed but lingers in an autorelease pool, it might receive
37 // unexpected requests for key commands; see <http://crbug.com/574798> for
38 // an example. In such a case, make sure the key equivalent search stops
39 // here rather than proceeding down the view hierarchy and tickling stale
40 // pointers.
41 return NO;
42 }
43 return [super performKeyEquivalent:event];
44 }
45
26 - (void)drawRect:(NSRect)rect { 46 - (void)drawRect:(NSRect)rect {
27 // Make room for the border to be seen. 47 // Make room for the border to be seen.
28 NSRect bounds = [self bounds]; 48 NSRect bounds = [self bounds];
29 if (arrowLocation_ != info_bubble::kNoArrow) { 49 if (arrowLocation_ != info_bubble::kNoArrow) {
30 bounds.size.height -= info_bubble::kBubbleArrowHeight; 50 bounds.size.height -= info_bubble::kBubbleArrowHeight;
31 } 51 }
32 rect.size.height -= info_bubble::kBubbleArrowHeight; 52 rect.size.height -= info_bubble::kBubbleArrowHeight;
33 53
34 float topRadius = cornerFlags_ & info_bubble::kRoundedTopCorners ? 54 float topRadius = cornerFlags_ & info_bubble::kRoundedTopCorners ?
35 info_bubble::kBubbleCornerRadius : 0; 55 info_bubble::kBubbleCornerRadius : 0;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 123
104 - (NSColor*)backgroundColor { 124 - (NSColor*)backgroundColor {
105 return backgroundColor_; 125 return backgroundColor_;
106 } 126 }
107 127
108 - (void)setBackgroundColor:(NSColor*)backgroundColor { 128 - (void)setBackgroundColor:(NSColor*)backgroundColor {
109 backgroundColor_.reset([backgroundColor retain]); 129 backgroundColor_.reset([backgroundColor retain]);
110 } 130 }
111 131
112 @end 132 @end
OLDNEW
« 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