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

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

Issue 352003: [mac] Remember last used prefs tab. (Closed)
Patch Set: rebase tot Created 11 years, 1 month 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
« no previous file with comments | « chrome/browser/cocoa/preferences_window_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/preferences_window_controller.mm
diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm
index 48f4b9bc9a62c49b7d0d5ecef17a968c4de614c9..e3243f475e715a9e116042218e59cacb43791441 100644
--- a/chrome/browser/cocoa/preferences_window_controller.mm
+++ b/chrome/browser/cocoa/preferences_window_controller.mm
@@ -21,6 +21,7 @@
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/net/dns_global.h"
#include "chrome/browser/net/url_fixer_upper.h"
+#include "chrome/browser/options_window.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/session_startup_pref.h"
@@ -207,11 +208,15 @@ class PrefObserverBridge : public NotificationObserver {
CenterViewForWidth(personalStuffView_, widest);
CenterViewForWidth(underTheHoodView_, widest);
- // Ensure the "basics" is selected.
- // TODO: change this to remember what's selected in a preference and restore
- // it.
+ // Get the last visited page from local state.
+ OptionsPage page = static_cast<OptionsPage>(lastSelectedPage_.GetValue());
+ if (page == OPTIONS_PAGE_DEFAULT)
+ page = OPTIONS_PAGE_GENERAL;
- NSToolbarItem* firstItem = [[toolbar_ items] objectAtIndex:0];
+ NSUInteger pageIndex = (NSUInteger)page;
+ if (pageIndex >= [[toolbar_ items] count])
+ pageIndex = 0;
+ NSToolbarItem* firstItem = [[toolbar_ items] objectAtIndex:pageIndex];
[self displayPreferenceViewForToolbarItem:firstItem animate:NO];
[toolbar_ setSelectedItemIdentifier:[firstItem itemIdentifier]];
@@ -275,6 +280,9 @@ class PrefObserverBridge : public NotificationObserver {
defaultDownloadLocation_.Init(prefs::kDownloadDefaultDirectory, prefs_,
observer_.get());
askForSaveLocation_.Init(prefs::kPromptForDownload, prefs_, observer_.get());
+
+ // We don't need to observe changes in this value.
+ lastSelectedPage_.Init(prefs::kOptionsWindowLastTabIndex, local, NULL);
}
// Clean up what was registered in -registerPrefObservers. We only have to
@@ -851,16 +859,20 @@ const int kDisabledIndex = 1;
- (void)displayPreferenceViewForToolbarItem:(NSToolbarItem*)toolbarItem
animate:(BOOL)animate {
NSView* prefsView = NULL;
+ OptionsPage page = OPTIONS_PAGE_DEFAULT;
// Tags are set in the nib file.
switch ([toolbarItem tag]) {
case 0: // Basics
prefsView = basicsView_;
+ page = OPTIONS_PAGE_GENERAL;
break;
case 1: // Personal Stuff
prefsView = personalStuffView_;
+ page = OPTIONS_PAGE_CONTENT;
break;
case 2: // Under the Hood
prefsView = underTheHoodView_;
+ page = OPTIONS_PAGE_ADVANCED;
break;
default:
NOTIMPLEMENTED();
@@ -883,6 +895,10 @@ const int kDisabledIndex = 1;
return;
}
+ // Remember new options page as current page.
+ if (page != OPTIONS_PAGE_DEFAULT)
+ lastSelectedPage_.SetValue(page);
+
// Stop any running animation, and remove any past views that were on the way
// out.
[animation_ stopAnimation];
« no previous file with comments | « chrome/browser/cocoa/preferences_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698