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

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

Issue 320253004: Componentize URLFixerUpper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win64 fix Created 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/options/core_options_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
11 #include "chrome/browser/autocomplete/autocomplete_controller.h" 11 #include "chrome/browser/autocomplete/autocomplete_controller.h"
12 #include "chrome/browser/autocomplete/autocomplete_input.h" 12 #include "chrome/browser/autocomplete/autocomplete_input.h"
13 #include "chrome/browser/autocomplete/autocomplete_result.h" 13 #include "chrome/browser/autocomplete/autocomplete_result.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/custom_home_pages_table_model.h" 15 #include "chrome/browser/custom_home_pages_table_model.h"
16 #include "chrome/browser/prefs/session_startup_pref.h" 16 #include "chrome/browser/prefs/session_startup_pref.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/net/url_fixer_upper.h"
19 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "components/url_fixer/url_fixer.h"
20 #include "content/public/browser/notification_details.h" 20 #include "content/public/browser/notification_details.h"
21 #include "content/public/browser/web_ui.h" 21 #include "content/public/browser/web_ui.h"
22 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
23 23
24 namespace options { 24 namespace options {
25 25
26 StartupPagesHandler::StartupPagesHandler() { 26 StartupPagesHandler::StartupPagesHandler() {
27 } 27 }
28 28
29 StartupPagesHandler::~StartupPagesHandler() { 29 StartupPagesHandler::~StartupPagesHandler() {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return; 146 return;
147 } 147 }
148 startup_custom_pages_table_model_->Remove(selected_index); 148 startup_custom_pages_table_model_->Remove(selected_index);
149 } 149 }
150 } 150 }
151 151
152 void StartupPagesHandler::AddStartupPage(const base::ListValue* args) { 152 void StartupPagesHandler::AddStartupPage(const base::ListValue* args) {
153 std::string url_string; 153 std::string url_string;
154 CHECK(args->GetString(0, &url_string)); 154 CHECK(args->GetString(0, &url_string));
155 155
156 GURL url = URLFixerUpper::FixupURL(url_string, std::string()); 156 GURL url = url_fixer::FixupURL(url_string, std::string());
157 if (!url.is_valid()) 157 if (!url.is_valid())
158 return; 158 return;
159 159
160 int row_count = startup_custom_pages_table_model_->RowCount(); 160 int row_count = startup_custom_pages_table_model_->RowCount();
161 int index; 161 int index;
162 if (!args->GetInteger(1, &index) || index > row_count) 162 if (!args->GetInteger(1, &index) || index > row_count)
163 index = row_count; 163 index = row_count;
164 164
165 startup_custom_pages_table_model_->Add(index, url); 165 startup_custom_pages_table_model_->Add(index, url);
166 } 166 }
167 167
168 void StartupPagesHandler::EditStartupPage(const base::ListValue* args) { 168 void StartupPagesHandler::EditStartupPage(const base::ListValue* args) {
169 std::string url_string; 169 std::string url_string;
170 GURL fixed_url; 170 GURL fixed_url;
171 int index; 171 int index;
172 CHECK_EQ(args->GetSize(), 2U); 172 CHECK_EQ(args->GetSize(), 2U);
173 CHECK(args->GetInteger(0, &index)); 173 CHECK(args->GetInteger(0, &index));
174 CHECK(args->GetString(1, &url_string)); 174 CHECK(args->GetString(1, &url_string));
175 175
176 if (index < 0 || index > startup_custom_pages_table_model_->RowCount()) { 176 if (index < 0 || index > startup_custom_pages_table_model_->RowCount()) {
177 NOTREACHED(); 177 NOTREACHED();
178 return; 178 return;
179 } 179 }
180 180
181 fixed_url = URLFixerUpper::FixupURL(url_string, std::string()); 181 fixed_url = url_fixer::FixupURL(url_string, std::string());
182 if (!fixed_url.is_empty()) { 182 if (!fixed_url.is_empty()) {
183 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); 183 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs();
184 urls[index] = fixed_url; 184 urls[index] = fixed_url;
185 startup_custom_pages_table_model_->SetURLs(urls); 185 startup_custom_pages_table_model_->SetURLs(urls);
186 } else { 186 } else {
187 startup_custom_pages_table_model_->Remove(index); 187 startup_custom_pages_table_model_->Remove(index);
188 } 188 }
189 } 189 }
190 190
191 void StartupPagesHandler::DragDropStartupPage(const base::ListValue* args) { 191 void StartupPagesHandler::DragDropStartupPage(const base::ListValue* args) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { 242 void StartupPagesHandler::OnResultChanged(bool default_match_changed) {
243 const AutocompleteResult& result = autocomplete_controller_->result(); 243 const AutocompleteResult& result = autocomplete_controller_->result();
244 base::ListValue suggestions; 244 base::ListValue suggestions;
245 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); 245 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions);
246 web_ui()->CallJavascriptFunction( 246 web_ui()->CallJavascriptFunction(
247 "StartupOverlay.updateAutocompleteSuggestions", suggestions); 247 "StartupOverlay.updateAutocompleteSuggestions", suggestions);
248 } 248 }
249 249
250 } // namespace options 250 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/core_options_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698