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

Side by Side Diff: chrome/browser/ui/webui/options/startup_pages_handler.cc

Issue 1849543006: MD Settings: validate startup URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@startup-browser-proxy
Patch Set: compile fix 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/options/startup_pages_handler.h" 5 #include "chrome/browser/ui/webui/options/startup_pages_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/logging.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" 13 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
13 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" 14 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
14 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/custom_home_pages_table_model.h" 16 #include "chrome/browser/custom_home_pages_table_model.h"
16 #include "chrome/browser/prefs/session_startup_pref.h" 17 #include "chrome/browser/prefs/session_startup_pref.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/search_engines/template_url_service_factory.h" 19 #include "chrome/browser/search_engines/template_url_service_factory.h"
19 #include "chrome/browser/ui/webui/settings_utils.h" 20 #include "chrome/browser/ui/webui/settings_utils.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 162 }
162 startup_custom_pages_table_model_->Remove(selected_index); 163 startup_custom_pages_table_model_->Remove(selected_index);
163 } 164 }
164 } 165 }
165 166
166 void StartupPagesHandler::AddStartupPage(const base::ListValue* args) { 167 void StartupPagesHandler::AddStartupPage(const base::ListValue* args) {
167 std::string url_string; 168 std::string url_string;
168 CHECK(args->GetString(0, &url_string)); 169 CHECK(args->GetString(0, &url_string));
169 170
170 GURL fixed_url; 171 GURL fixed_url;
171 if (!settings_utils::FixupAndValidateStartupPage(url_string, &fixed_url)) 172 if (!settings_utils::FixupAndValidateStartupPage(url_string, &fixed_url)) {
173 NOTREACHED();
172 return; 174 return;
175 }
173 176
174 int row_count = startup_custom_pages_table_model_->RowCount(); 177 int row_count = startup_custom_pages_table_model_->RowCount();
175 int index; 178 int index;
176 if (!args->GetInteger(1, &index) || index > row_count) 179 if (!args->GetInteger(1, &index) || index > row_count)
177 index = row_count; 180 index = row_count;
178 181
179 startup_custom_pages_table_model_->Add(index, fixed_url); 182 startup_custom_pages_table_model_->Add(index, fixed_url);
180 } 183 }
181 184
182 void StartupPagesHandler::EditStartupPage(const base::ListValue* args) { 185 void StartupPagesHandler::EditStartupPage(const base::ListValue* args) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 259
257 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { 260 void StartupPagesHandler::OnResultChanged(bool default_match_changed) {
258 const AutocompleteResult& result = autocomplete_controller_->result(); 261 const AutocompleteResult& result = autocomplete_controller_->result();
259 base::ListValue suggestions; 262 base::ListValue suggestions;
260 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); 263 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions);
261 web_ui()->CallJavascriptFunction( 264 web_ui()->CallJavascriptFunction(
262 "StartupOverlay.updateAutocompleteSuggestions", suggestions); 265 "StartupOverlay.updateAutocompleteSuggestions", suggestions);
263 } 266 }
264 267
265 } // namespace options 268 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698