diff options
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.mm | 12 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 4 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
6 files changed, 18 insertions, 3 deletions
@@ -77,3 +77,4 @@ Satoshi Matsuzaki <satoshi.matsuzaki@gmail.com> Benjamin Jemlich <pcgod99@gmail.com> Ningxin Hu <ningxin.hu@intel.com> Jared Wein <weinjared@gmail.com> +Mingmin Xie <melvinxie@gmail.com> diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 2cca704..67daf12 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1829,6 +1829,7 @@ void Browser::RegisterPrefs(PrefService* prefs) { prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); prefs->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0); prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1); + prefs->RegisterDictionaryPref(prefs::kPreferencesWindowPlacement); } // static diff --git a/chrome/browser/cocoa/preferences_window_controller.h b/chrome/browser/cocoa/preferences_window_controller.h index 43c8a93..46ac043 100644 --- a/chrome/browser/cocoa/preferences_window_controller.h +++ b/chrome/browser/cocoa/preferences_window_controller.h @@ -19,6 +19,7 @@ class PrefService; class Profile; class ProfileSyncService; @class SearchEngineListModel; +@class WindowSizeAutosaver; // A window controller that handles the preferences window. The bulk of the // work is handled via Cocoa Bindings and getter/setter methods that wrap @@ -41,6 +42,7 @@ class ProfileSyncService; ProfileSyncService* syncService_; scoped_ptr<PreferencesWindowControllerInternal::PrefObserverBridge> observer_; // Watches for pref changes. + scoped_nsobject<WindowSizeAutosaver> sizeSaver_; IBOutlet NSToolbar* toolbar_; diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index 74e9c21..251abd5 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -28,6 +28,7 @@ #import "chrome/browser/cocoa/l10n_util.h" #import "chrome/browser/cocoa/search_engine_list_model.h" #import "chrome/browser/cocoa/sync_customize_controller_cppsafe.h" +#import "chrome/browser/cocoa/window_size_autosaver.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/metrics/metrics_service.h" @@ -651,9 +652,14 @@ class PrefObserverBridge : public NotificationObserver, [self switchToPage:initialPage_ animate:NO]; - // TODO(pinkerton): save/restore position based on prefs. - // http://crbug.com/34644 - [[self window] center]; + // Save/restore position based on prefs. + if (g_browser_process && g_browser_process->local_state()) { + sizeSaver_.reset([[WindowSizeAutosaver alloc] + initWithWindow:[self window] + prefService:g_browser_process->local_state() + path:prefs::kPreferencesWindowPlacement + state:kSaveWindowRect]); + } } - (void)dealloc { diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index aa47bc49..5500fa6 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -644,6 +644,10 @@ const wchar_t kPageInfoWindowPlacement[] = L"page_info.window_placement"; const wchar_t kKeywordEditorWindowPlacement[] = L"keyword_editor.window_placement"; +// A collection of position, size, and other data relating to the preferences +// window to restore on startup. +const wchar_t kPreferencesWindowPlacement[] = L"preferences.window_placement"; + // An integer specifying the total number of bytes to be used by the // renderer's in-memory cache of objects. const wchar_t kMemoryCacheSize[] = L"renderer.memory_cache.size"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index ec33553..fad9b53 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -229,6 +229,7 @@ extern const wchar_t kBrowserWindowPlacement[]; extern const wchar_t kTaskManagerWindowPlacement[]; extern const wchar_t kPageInfoWindowPlacement[]; extern const wchar_t kKeywordEditorWindowPlacement[]; +extern const wchar_t kPreferencesWindowPlacement[]; extern const wchar_t kMemoryCacheSize[]; extern const wchar_t kDownloadDefaultDirectory[]; |