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

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

Issue 2951013002: [Mac] Dismiss the first run bubble when the user starts typing. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/first_run_bubble_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/first_run_bubble_controller.mm
diff --git a/chrome/browser/ui/cocoa/first_run_bubble_controller.mm b/chrome/browser/ui/cocoa/first_run_bubble_controller.mm
index 85915c4d614a41bf80fa24854ec075cd33cc6c7c..d7d0d5df147bb9d0807c5781af2f41fae71417b1 100644
--- a/chrome/browser/ui/cocoa/first_run_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/first_run_bubble_controller.mm
@@ -14,6 +14,24 @@
#include "components/search_engines/util.h"
#include "ui/base/l10n/l10n_util.h"
+@interface FirstRunKeyResponder : NSResponder
+@end
+
+@implementation FirstRunKeyResponder
+
+- (void)keyDown:(NSEvent*)event {
+ // Pass the key event along to the browser window's first responder (which is
+ // the omnibox).
+ NSWindow* firstRunBubbleWindow = [event window];
+ [[[firstRunBubbleWindow parentWindow] firstResponder] keyDown:event];
+
+ // Remove the first run bubble from the screen and clean up.
+ [firstRunBubbleWindow orderOut:nil];
+ [[firstRunBubbleWindow windowController] close];
+}
+
+@end
+
@interface FirstRunBubbleController(Private)
- (id)initRelativeToView:(NSView*)view
offset:(NSPoint)offset
@@ -44,6 +62,12 @@
offset:offset])) {
browser_ = browser;
profile_ = profile;
+
+ // Add a responder object to catch any key events that are not consumed
+ // by controls in the bubble, so that user typing dismisses the bubble.
+ keyResponder_.reset([[FirstRunKeyResponder alloc] init]);
+ [[self window] setNextResponder:keyResponder_];
+
[self showWindow:nil];
// On 10.5, the first run bubble sometimes does not disappear when clicking
« no previous file with comments | « chrome/browser/ui/cocoa/first_run_bubble_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698