Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4859)

Unified Diff: chrome/browser/cocoa/page_info_window_controller.mm

Issue 207027: [Mac] Polish the search engine manager (Closed)
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/page_info_window_controller.mm
diff --git a/chrome/browser/cocoa/page_info_window_controller.mm b/chrome/browser/cocoa/page_info_window_controller.mm
index 9f3b813327472f3704a479d52b7950d15b57ee65..d8eb7c7bbbbb881236b9949f6edd4837c67323da 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

Powered by Google App Engine
This is Rietveld 408576698