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

Unified Diff: chrome/browser/cocoa/find_bar_cocoa_controller.mm

Issue 205010: Reverting 26219. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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/cocoa/find_bar_cocoa_controller.h ('k') | chrome/browser/cocoa/focus_tracker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/find_bar_cocoa_controller.mm
===================================================================
--- chrome/browser/cocoa/find_bar_cocoa_controller.mm (revision 26230)
+++ chrome/browser/cocoa/find_bar_cocoa_controller.mm (working copy)
@@ -12,6 +12,7 @@
#include "chrome/browser/cocoa/browser_window_cocoa.h"
#import "chrome/browser/cocoa/find_bar_cocoa_controller.h"
#import "chrome/browser/cocoa/find_bar_bridge.h"
+#import "chrome/browser/cocoa/focus_tracker.h"
#import "chrome/browser/cocoa/tab_strip_controller.h"
#include "chrome/browser/tab_contents/tab_contents.h"
@@ -120,6 +121,14 @@
// Methods from FindBar
- (void)showFindBar {
[[self view] setHidden:NO];
+
+ // Save the currently-focused view. |[self view]| is in the view
+ // hierarchy by now. showFindBar can be called even when the
+ // findbar is already open, so do not overwrite an already saved
+ // view.
+ if (!focusTracker_.get())
+ focusTracker_.reset(
+ [[FocusTracker alloc] initWithWindow:[[self view] window]]);
}
- (void)hideFindBar {
@@ -136,6 +145,15 @@
}
+- (void)restoreSavedFocus {
+ if (!(focusTracker_.get() &&
+ [focusTracker_ restoreFocusInWindow:[[self view] window]])) {
+ // Fall back to giving focus to the tab contents.
+ findBarBridge_->GetFindBarController()->tab_contents()->Focus();
+ }
+ focusTracker_.reset(nil);
+}
+
- (void)setFindText:(const string16&)findText {
[findText_ setStringValue:base::SysUTF16ToNSString(findText)];
}
@@ -177,6 +195,11 @@
[resultsLabel_ setStringValue:@""];
}
+ // If we found any results, reset the focus tracker, so we always
+ // restore focus to the tab contents.
+ if (result.number_of_matches() > 0)
+ focusTracker_.reset(nil);
+
// Resize |resultsLabel_| to completely contain its string and right-justify
// it within |findText_|. sizeToFit may shrink the frame vertically, which we
// don't want, so we save the original vertical positioning.
« no previous file with comments | « chrome/browser/cocoa/find_bar_cocoa_controller.h ('k') | chrome/browser/cocoa/focus_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698