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

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: Undo move for now. 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..53632f817b7fbc0930f4bc7b5b89a452cf25b84a 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,33 @@ 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;
Dan Beam 2016/04/12 04:37:47 all numbers in javascript are doubles i honestly
dpapad 2016/04/12 17:52:54 This logic is mostly copied from the equivalent co
Dan Beam 2016/04/12 18:08:53 Acknowledged.
+ 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);
+ ResolveJavascriptCallback(*callback_id, base::FundamentalValue(true));
+ } else {
+ ResolveJavascriptCallback(*callback_id, base::FundamentalValue(false));
+ }
+}
Dan Beam 2016/04/12 04:39:13 it might be worthwhile to test any of these callba
dpapad 2016/04/12 17:52:54 Agreed. C++ test coverage would be nice for this (
Dan Beam 2016/04/12 18:08:53 Acknowledged.
+
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