| OLD | NEW |
| 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" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 selected_index >= startup_custom_pages_table_model_->RowCount()) { | 144 selected_index >= startup_custom_pages_table_model_->RowCount()) { |
| 145 NOTREACHED(); | 145 NOTREACHED(); |
| 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 ListValue* args) { | 152 void StartupPagesHandler::AddStartupPage(const ListValue* args) { |
| 153 std::string url_string; | 153 std::string url_string; |
| 154 CHECK_EQ(args->GetSize(), 1U); | |
| 155 CHECK(args->GetString(0, &url_string)); | 154 CHECK(args->GetString(0, &url_string)); |
| 156 | 155 |
| 157 GURL url = URLFixerUpper::FixupURL(url_string, std::string()); | 156 GURL url = URLFixerUpper::FixupURL(url_string, std::string()); |
| 158 if (!url.is_valid()) | 157 if (!url.is_valid()) |
| 159 return; | 158 return; |
| 160 int index = startup_custom_pages_table_model_->RowCount(); | 159 |
| 160 int row_count = startup_custom_pages_table_model_->RowCount(); |
| 161 int index; |
| 162 if (!args->GetInteger(1, &index) || index > row_count) |
| 163 index = row_count; |
| 164 |
| 161 startup_custom_pages_table_model_->Add(index, url); | 165 startup_custom_pages_table_model_->Add(index, url); |
| 162 } | 166 } |
| 163 | 167 |
| 164 void StartupPagesHandler::EditStartupPage(const ListValue* args) { | 168 void StartupPagesHandler::EditStartupPage(const ListValue* args) { |
| 165 std::string url_string; | 169 std::string url_string; |
| 166 int index; | 170 int index; |
| 167 CHECK_EQ(args->GetSize(), 2U); | 171 CHECK_EQ(args->GetSize(), 2U); |
| 168 CHECK(args->GetInteger(0, &index)); | 172 CHECK(args->GetInteger(0, &index)); |
| 169 CHECK(args->GetString(1, &url_string)); | 173 CHECK(args->GetString(1, &url_string)); |
| 170 | 174 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 236 |
| 233 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { | 237 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { |
| 234 const AutocompleteResult& result = autocomplete_controller_->result(); | 238 const AutocompleteResult& result = autocomplete_controller_->result(); |
| 235 ListValue suggestions; | 239 ListValue suggestions; |
| 236 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); | 240 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); |
| 237 web_ui()->CallJavascriptFunction( | 241 web_ui()->CallJavascriptFunction( |
| 238 "StartupOverlay.updateAutocompleteSuggestions", suggestions); | 242 "StartupOverlay.updateAutocompleteSuggestions", suggestions); |
| 239 } | 243 } |
| 240 | 244 |
| 241 } // namespace options | 245 } // namespace options |
| OLD | NEW |