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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_WINDOW_SIZE_AUTOSAVER_H_
6 #define CHROME_BROWSER_UI_COCOA_WINDOW_SIZE_AUTOSAVER_H_
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.
13 // To use this, add a |base::scoped_nsobject<WindowSizeAutosaver>| to your
15 // controller and initialize it in the window controller's init method, passing
16 // a window and an autosave name. The autosaver will register for "window moved"
17 // and "window resized" notifications and write the current window state to the
18 // prefs service every time they fire. The window's size is automatically
19 // restored when the autosaver's |initWithWindow:...| method is called.
21 // Note: Your xib file should have "Visible at launch" UNCHECKED, so that the
22 // initial repositioning is not visible.
23 @interface WindowSizeAutosaver
: NSObject
{
24 NSWindow
* window_
; // weak
25 PrefService
* prefService_
; // weak
29 - (id
)initWithWindow
:(NSWindow
*)window
30 prefService
:(PrefService
*)prefs
31 path
:(const char*)path
;
34 #endif // CHROME_BROWSER_UI_COCOA_WINDOW_SIZE_AUTOSAVER_H_