- add sources.
[platform/framework/web/crosswalk.git] / src / ui / base / cocoa / focus_tracker.h
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
3 // found in the LICENSE file.
4
5 #import <Cocoa/Cocoa.h>
6
7 #include "base/mac/scoped_nsobject.h"
8 #include "ui/base/ui_export.h"
9
10 // A class that handles saving and restoring focus.  An instance of
11 // this class snapshots the currently focused view when it is
12 // constructed, and callers can use restoreFocus to return focus to
13 // that view.  FocusTracker will not restore focus to views that are
14 // no longer in the view hierarchy or are not in the correct window.
15 UI_EXPORT
16 @interface FocusTracker : NSObject {
17  @private
18   base::scoped_nsobject<NSView> focusedView_;
19 }
20
21 // |window| is the window that we are saving focus for.  This
22 // method snapshots the currently focused view.
23 - (id)initWithWindow:(NSWindow*)window;
24
25 // Attempts to restore focus to the snapshotted view.  Returns YES if
26 // focus was restored.  Will not restore focus if the view is no
27 // longer in the view hierarchy under |window|.
28 - (BOOL)restoreFocusInWindow:(NSWindow*)window;
29 @end