summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/focus_tracker.h
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 18:01:58 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 18:01:58 +0000
commit59f3e6d0f59a671ed2f50d14abbec2708cb709b1 (patch)
tree36b3687d077ef4d5c0e9657c6520175550fadd00 /chrome/browser/cocoa/focus_tracker.h
parentd88453afb9292607a16321e23785e5ee2417f776 (diff)
downloadchromium_src-59f3e6d0f59a671ed2f50d14abbec2708cb709b1.zip
chromium_src-59f3e6d0f59a671ed2f50d14abbec2708cb709b1.tar.gz
chromium_src-59f3e6d0f59a671ed2f50d14abbec2708cb709b1.tar.bz2
[Mac] Restore focus to the previously focused view when dismissing the find bar.
If a result was found, restore focus to the tab contents. This allows for keyboard navigation using the find bar. Now with fix for valgrind failure. This CL reverts 26219, which in turn reverted 26214. BUG=http://crbug.com/12657 BUG=http://crbug.com/21374 TEST=See test case in bug 21374 Review URL: http://codereview.chromium.org/205010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26231 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/focus_tracker.h')
-rw-r--r--chrome/browser/cocoa/focus_tracker.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/focus_tracker.h b/chrome/browser/cocoa/focus_tracker.h
new file mode 100644
index 0000000..f828979
--- /dev/null
+++ b/chrome/browser/cocoa/focus_tracker.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/scoped_nsobject.h"
+
+// A class that handles saving and restoring focus. An instance of
+// this class snapshots the currently focused view when it is
+// constructed, and callers can use restoreFocus to return focus to
+// that view. FocusTracker will not restore focus to views that are
+// no longer in the view hierarchy or are not in the correct window.
+
+@interface FocusTracker : NSObject {
+ @private
+ scoped_nsobject<NSView> focusedView_;
+}
+
+// |window| is the window that we are saving focus for. This
+// method snapshots the currently focused view.
+- (id)initWithWindow:(NSWindow*)window;
+
+// Attempts to restore focus to the snapshotted view. Returns YES if
+// focus was restored. Will not restore focus if the view is no
+// longer in the view hierarchy under |window|.
+- (BOOL)restoreFocusInWindow:(NSWindow*)window;
+@end