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

Unified Diff: chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc

Issue 1877633002: MD Settings: Adding C++ support for editing startup URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@on_startup_urls
Patch Set: Add missing call to save prefs. Created 4 years, 8 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
« no previous file with comments | « chrome/browser/ui/webui/settings/settings_startup_pages_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc
diff --git a/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc b/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc
index 17342b6645927c8ab392abe015bd099380acb116..6f919d5048b1bfe4731d98f891fdcc5c2d1fd225 100644
--- a/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc
@@ -30,6 +30,9 @@ void StartupPagesHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("addStartupPage",
base::Bind(&StartupPagesHandler::HandleAddStartupPage,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback("editStartupPage",
+ base::Bind(&StartupPagesHandler::HandleEditStartupPage,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback("onStartupPrefsPageLoad",
base::Bind(&StartupPagesHandler::HandleOnStartupPrefsPageLoad,
base::Unretained(this)));
@@ -105,6 +108,34 @@ void StartupPagesHandler::HandleAddStartupPage(const base::ListValue* args) {
ResolveJavascriptCallback(*callback_id, base::FundamentalValue(true));
}
+void StartupPagesHandler::HandleEditStartupPage(const base::ListValue* args) {
+ CHECK_EQ(args->GetSize(), 3U);
+ const base::Value* callback_id;
+ CHECK(args->Get(0, &callback_id));
+ int index;
+ CHECK(args->GetInteger(1, &index));
+
+ if (index < 0 || index > startup_custom_pages_table_model_.RowCount()) {
+ RejectJavascriptCallback(*callback_id, *base::Value::CreateNullValue());
+ NOTREACHED();
+ return;
+ }
+
+ std::string url_string;
+ CHECK(args->GetString(2, &url_string));
+
+ GURL fixed_url;
+ if (settings_utils::FixupAndValidateStartupPage(url_string, &fixed_url)) {
+ std::vector<GURL> urls = startup_custom_pages_table_model_.GetURLs();
+ urls[index] = fixed_url;
+ startup_custom_pages_table_model_.SetURLs(urls);
+ SaveStartupPagesPref();
+ ResolveJavascriptCallback(*callback_id, base::FundamentalValue(true));
+ } else {
+ ResolveJavascriptCallback(*callback_id, base::FundamentalValue(false));
+ }
+}
+
void StartupPagesHandler::HandleOnStartupPrefsPageLoad(
const base::ListValue* args) {
startup_custom_pages_table_model_.SetObserver(this);
« no previous file with comments | « chrome/browser/ui/webui/settings/settings_startup_pages_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698