diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-19 01:54:23 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-19 01:54:23 +0000 |
commit | c2788ecbcd5c443fb129f63b7b86f83e944b4950 (patch) | |
tree | 5bf36eb1814dbafe12604c05c19b703897a2c74b /chrome/browser/cocoa/page_info_window_controller.mm | |
parent | d4208dd1717889212bc7749168d1a7b8dea44ebe (diff) | |
download | chromium_src-c2788ecbcd5c443fb129f63b7b86f83e944b4950.zip chromium_src-c2788ecbcd5c443fb129f63b7b86f83e944b4950.tar.gz chromium_src-c2788ecbcd5c443fb129f63b7b86f83e944b4950.tar.bz2 |
[Mac] Polish the search engine manager
* Make the edit search engine window a sheet.
* Only allow one instance of the search engine manager to be opened at once.
* The search engine manager now remembers its position.
* Create NSWindow(LocalStateAdditions) category to assist with storing window
position in Chromium's local state.
BUG=21761,21762,21883,21996
TEST=Editing/adding a search engine happens in a sheet. Press [Manage] multiple times and only 1 window should open. Press [Manage] and the window should be at its last position.
Review URL: http://codereview.chromium.org/207027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26646 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/page_info_window_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/page_info_window_controller.mm | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/chrome/browser/cocoa/page_info_window_controller.mm b/chrome/browser/cocoa/page_info_window_controller.mm index 9f3b813..d8eb7c7 100644 --- a/chrome/browser/cocoa/page_info_window_controller.mm +++ b/chrome/browser/cocoa/page_info_window_controller.mm @@ -7,6 +7,7 @@ #include "base/mac_util.h" #include "base/values.h" #include "chrome/browser/browser_process.h" +#import "chrome/browser/cocoa/nswindow_local_state.h" #include "chrome/browser/cocoa/page_info_window_mac.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" @@ -45,17 +46,8 @@ if (g_browser_process && g_browser_process->local_state()) { // Get the positioning information. PrefService* prefs = g_browser_process->local_state(); - DictionaryValue* windowPrefs = - prefs->GetMutableDictionary(prefs::kPageInfoWindowPlacement); - int x = 0, y = 0; - windowPrefs->GetInteger(L"x", &x); - windowPrefs->GetInteger(L"y", &y); - // Turn the origin (lower-left) into an upper-left window point. - NSPoint upperLeft = NSMakePoint(x, y + [[self window] frame].size.height); - NSPoint cascadePoint = [[self window] cascadeTopLeftFromPoint:upperLeft]; - // Cascade again to get the offset when opening new windows. - [[self window] cascadeTopLeftFromPoint:cascadePoint]; - [self saveWindowPositionToLocalState]; // Force a save of the pref. + [[self window] restoreWindowPositionFromPrefs:prefs + withPath:prefs::kPageInfoWindowPlacement]; } // By default, assume we have no history information. @@ -116,25 +108,9 @@ // The last page info window that was moved will determine the location of the // next new one. - (void)windowDidMove:(NSNotification*)notif { - [self saveWindowPositionToLocalState]; -} - -// Saves the window preference to the local state. -- (void)saveWindowPositionToLocalState { - if (!g_browser_process || !g_browser_process->local_state()) - return; - [self saveWindowPositionToPrefs:g_browser_process->local_state()]; -} - -// Saves the window's origin into the given PrefService. Caller is responsible -// for making sure |prefs| is not NULL. -- (void)saveWindowPositionToPrefs:(PrefService*)prefs { - // Save the origin of the window. - DictionaryValue* windowPrefs = prefs->GetMutableDictionary( - prefs::kPageInfoWindowPlacement); - NSRect frame = [[self window] frame]; - windowPrefs->SetInteger(L"x", frame.origin.x); - windowPrefs->SetInteger(L"y", frame.origin.y); + if (g_browser_process && g_browser_process->local_state()) + [[self window] saveWindowPositionToPrefs:g_browser_process->local_state() + withPath:prefs::kPageInfoWindowPlacement]; } @end |