Skip to content

Commit

Permalink
Save/restore position for the preferences window based on prefs,
Browse files Browse the repository at this point in the history
BUG=34644
TEST=Try moving the preferences window and confirm it works.

Patch from Mingmin Xie <melvinxie@gmail.com>

Review URL: http://codereview.chromium.org/2592001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48834 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tfarina@chromium.org committed Jun 3, 2010
1 parent 9848c7e commit 74ed092
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -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>
1 change: 1 addition & 0 deletions chrome/browser/browser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions chrome/browser/cocoa/preferences_window_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,6 +42,7 @@ class ProfileSyncService;
ProfileSyncService* syncService_;
scoped_ptr<PreferencesWindowControllerInternal::PrefObserverBridge>
observer_; // Watches for pref changes.
scoped_nsobject<WindowSizeAutosaver> sizeSaver_;

IBOutlet NSToolbar* toolbar_;

Expand Down
12 changes: 9 additions & 3 deletions chrome/browser/cocoa/preferences_window_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -651,9 +652,14 @@ - (void)awakeFromNib {

[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 {
Expand Down
4 changes: 4 additions & 0 deletions chrome/common/pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions chrome/common/pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down

0 comments on commit 74ed092

Please sign in to comment.