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

Side by Side Diff: chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc

Issue 2924943002: MD Settings/On Startup: ignore current tab when using current pages (Closed)
Patch Set: ignore_contents Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/startup_pages_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h" 5 #include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 NOTREACHED(); 167 NOTREACHED();
168 return; 168 return;
169 } 169 }
170 170
171 startup_custom_pages_table_model_.Remove(selected_index); 171 startup_custom_pages_table_model_.Remove(selected_index);
172 SaveStartupPagesPref(); 172 SaveStartupPagesPref();
173 } 173 }
174 174
175 void StartupPagesHandler::HandleSetStartupPagesToCurrentPages( 175 void StartupPagesHandler::HandleSetStartupPagesToCurrentPages(
176 const base::ListValue* args) { 176 const base::ListValue* args) {
177 startup_custom_pages_table_model_.SetToCurrentlyOpenPages(); 177 startup_custom_pages_table_model_.SetToCurrentlyOpenPages(
178 web_ui()->GetWebContents());
178 SaveStartupPagesPref(); 179 SaveStartupPagesPref();
179 } 180 }
180 181
181 void StartupPagesHandler::SaveStartupPagesPref() { 182 void StartupPagesHandler::SaveStartupPagesPref() {
182 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 183 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
183 184
184 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); 185 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs);
185 pref.urls = startup_custom_pages_table_model_.GetURLs(); 186 pref.urls = startup_custom_pages_table_model_.GetURLs();
186 187
187 if (pref.urls.empty()) 188 if (pref.urls.empty())
188 pref.type = SessionStartupPref::DEFAULT; 189 pref.type = SessionStartupPref::DEFAULT;
189 190
190 SessionStartupPref::SetStartupPref(prefs, pref); 191 SessionStartupPref::SetStartupPref(prefs, pref);
191 } 192 }
192 193
193 void StartupPagesHandler::UpdateStartupPages() { 194 void StartupPagesHandler::UpdateStartupPages() {
194 const SessionStartupPref startup_pref = SessionStartupPref::GetStartupPref( 195 const SessionStartupPref startup_pref = SessionStartupPref::GetStartupPref(
195 Profile::FromWebUI(web_ui())->GetPrefs()); 196 Profile::FromWebUI(web_ui())->GetPrefs());
196 startup_custom_pages_table_model_.SetURLs(startup_pref.urls); 197 startup_custom_pages_table_model_.SetURLs(startup_pref.urls);
197 // The change will go to the JS code in the 198 // The change will go to the JS code in the
198 // StartupPagesHandler::OnModelChanged() method. 199 // StartupPagesHandler::OnModelChanged() method.
199 } 200 }
200 201
201 } // namespace settings 202 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/startup_pages_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698