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