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

Unified Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 7522025: Turn on session restore by default for mac on Lion (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: JS nits and comment correction Created 9 years, 5 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/ui/webui/options/browser_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index 9a541ee5fb2fb5abcbb3a7ce0668933f8f3aab89..0143ef6e8f75fb8c9494baf284ef9cc2e848dc38 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -103,6 +103,9 @@ void BrowserOptionsHandler::RegisterMessages() {
"setDefaultSearchEngine",
NewCallback(this, &BrowserOptionsHandler::SetDefaultSearchEngine));
web_ui_->RegisterMessageCallback(
+ "setRestoreOnStartup",
+ NewCallback(this, &BrowserOptionsHandler::SetRestoreOnStartup));
+ web_ui_->RegisterMessageCallback(
"removeStartupPages",
NewCallback(this, &BrowserOptionsHandler::RemoveStartupPages));
web_ui_->RegisterMessageCallback(
@@ -148,6 +151,7 @@ void BrowserOptionsHandler::Initialize() {
this);
UpdateDefaultBrowserState();
+ UpdateRestoreOnStartup();
startup_custom_pages_table_model_.reset(
new CustomHomePagesTableModel(profile));
startup_custom_pages_table_model_->SetObserver(this);
@@ -321,6 +325,15 @@ void BrowserOptionsHandler::UpdateSearchEngines() {
}
}
+void BrowserOptionsHandler::UpdateRestoreOnStartup() {
+ Profile* profile = web_ui_->GetProfile();
+ const SessionStartupPref startup_pref =
+ SessionStartupPref::GetStartupPref(profile->GetPrefs());
+ FundamentalValue restore_on_startup(startup_pref.type);
+ web_ui_->CallJavascriptFunction("BrowserOptions.updateRestoreOnStartup",
+ restore_on_startup);
+}
+
void BrowserOptionsHandler::UpdateStartupPages() {
Profile* profile = web_ui_->GetProfile();
const SessionStartupPref startup_pref =
@@ -365,6 +378,8 @@ void BrowserOptionsHandler::Observe(int type,
std::string* pref = Details<std::string>(details).ptr();
if (*pref == prefs::kDefaultBrowserSettingEnabled) {
UpdateDefaultBrowserState();
+ } else if (*pref == prefs::kRestoreOnStartup) {
+ UpdateRestoreOnStartup();
} else if (*pref == prefs::kURLsToRestoreOnStartup) {
UpdateStartupPages();
} else {
@@ -381,6 +396,28 @@ void BrowserOptionsHandler::SetStartupPagesToCurrentPages(
SaveStartupPagesPref();
}
+void BrowserOptionsHandler::SetRestoreOnStartup(const ListValue* args) {
+ std::string pref_string;
+ CHECK_EQ(args->GetSize(), 1UL);
+ CHECK(args->GetString(0, &pref_string));
+
+ PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
+
+ SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs);
+ if (pref_string == "0") {
+ pref.type = SessionStartupPref::DEFAULT;
+ } else if (pref_string == "1") {
+ pref.type = SessionStartupPref::LAST;
+ } else if (pref_string == "2") {
+ pref.type = SessionStartupPref::URLS;
+ } else {
+ NOTREACHED();
+ return;
+ }
+
+ SessionStartupPref::SetStartupPref(prefs, pref);
+}
+
void BrowserOptionsHandler::RemoveStartupPages(const ListValue* args) {
for (int i = args->GetSize() - 1; i >= 0; --i) {
std::string string_value;

Powered by Google App Engine
This is Rietveld 408576698