OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_UI_COCOA_WINDOW_SIZE_AUTOSAVER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_WINDOW_SIZE_AUTOSAVER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_WINDOW_SIZE_AUTOSAVER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_WINDOW_SIZE_AUTOSAVER_H_ |
7 | 7 |
8 class PrefService; | 8 class PrefService; |
9 @class NSWindow; | 9 @class NSWindow; |
10 | 10 |
11 // WindowSizeAutosaver is a helper class that makes it easy to let windows | 11 // WindowSizeAutosaver is a helper class that makes it easy to let windows |
12 // autoremember their position or position and size in a PrefService object. | 12 // autoremember their position or position and size in a PrefService object. |
13 // To use this, add a |scoped_nsobject<WindowSizeAutosaver>| to your window | 13 // To use this, add a |base::scoped_nsobject<WindowSizeAutosaver>| to your |
| 14 // window |
14 // controller and initialize it in the window controller's init method, passing | 15 // controller and initialize it in the window controller's init method, passing |
15 // a window and an autosave name. The autosaver will register for "window moved" | 16 // a window and an autosave name. The autosaver will register for "window moved" |
16 // and "window resized" notifications and write the current window state to the | 17 // and "window resized" notifications and write the current window state to the |
17 // prefs service every time they fire. The window's size is automatically | 18 // prefs service every time they fire. The window's size is automatically |
18 // restored when the autosaver's |initWithWindow:...| method is called. | 19 // restored when the autosaver's |initWithWindow:...| method is called. |
19 // | 20 // |
20 // Note: Your xib file should have "Visible at launch" UNCHECKED, so that the | 21 // Note: Your xib file should have "Visible at launch" UNCHECKED, so that the |
21 // initial repositioning is not visible. | 22 // initial repositioning is not visible. |
22 @interface WindowSizeAutosaver : NSObject { | 23 @interface WindowSizeAutosaver : NSObject { |
23 NSWindow* window_; // weak | 24 NSWindow* window_; // weak |
24 PrefService* prefService_; // weak | 25 PrefService* prefService_; // weak |
25 const char* path_; | 26 const char* path_; |
26 } | 27 } |
27 | 28 |
28 - (id)initWithWindow:(NSWindow*)window | 29 - (id)initWithWindow:(NSWindow*)window |
29 prefService:(PrefService*)prefs | 30 prefService:(PrefService*)prefs |
30 path:(const char*)path; | 31 path:(const char*)path; |
31 @end | 32 @end |
32 | 33 |
33 #endif // CHROME_BROWSER_UI_COCOA_WINDOW_SIZE_AUTOSAVER_H_ | 34 #endif // CHROME_BROWSER_UI_COCOA_WINDOW_SIZE_AUTOSAVER_H_ |
34 | 35 |
OLD | NEW |