| 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/search_engine_manager_handler.h" | 5 #include "chrome/browser/ui/webui/options/search_engine_manager_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 // Build the extension keywords list. | 145 // Build the extension keywords list. |
| 146 base::ListValue keyword_list; | 146 base::ListValue keyword_list; |
| 147 if (last_other_engine_index < 0) | 147 if (last_other_engine_index < 0) |
| 148 last_other_engine_index = 0; | 148 last_other_engine_index = 0; |
| 149 int engine_count = list_controller_->table_model()->RowCount(); | 149 int engine_count = list_controller_->table_model()->RowCount(); |
| 150 for (int i = last_other_engine_index; i < engine_count; ++i) { | 150 for (int i = last_other_engine_index; i < engine_count; ++i) { |
| 151 keyword_list.Append(CreateDictionaryForEngine(i, i == default_index)); | 151 keyword_list.Append(CreateDictionaryForEngine(i, i == default_index)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 web_ui()->CallJavascriptFunction("SearchEngineManager.updateSearchEngineList", | 154 web_ui()->CallJavascriptFunctionUnsafe( |
| 155 defaults_list, others_list, keyword_list); | 155 "SearchEngineManager.updateSearchEngineList", defaults_list, others_list, |
| 156 keyword_list); |
| 156 } | 157 } |
| 157 | 158 |
| 158 void SearchEngineManagerHandler::OnItemsChanged(int start, int length) { | 159 void SearchEngineManagerHandler::OnItemsChanged(int start, int length) { |
| 159 OnModelChanged(); | 160 OnModelChanged(); |
| 160 } | 161 } |
| 161 | 162 |
| 162 void SearchEngineManagerHandler::OnItemsAdded(int start, int length) { | 163 void SearchEngineManagerHandler::OnItemsAdded(int start, int length) { |
| 163 OnModelChanged(); | 164 OnModelChanged(); |
| 164 } | 165 } |
| 165 | 166 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 !args->GetString(3, &modelIndex)) { | 290 !args->GetString(3, &modelIndex)) { |
| 290 NOTREACHED(); | 291 NOTREACHED(); |
| 291 return; | 292 return; |
| 292 } | 293 } |
| 293 | 294 |
| 294 base::DictionaryValue validity; | 295 base::DictionaryValue validity; |
| 295 validity.SetBoolean("name", edit_controller_->IsTitleValid(name)); | 296 validity.SetBoolean("name", edit_controller_->IsTitleValid(name)); |
| 296 validity.SetBoolean("keyword", edit_controller_->IsKeywordValid(keyword)); | 297 validity.SetBoolean("keyword", edit_controller_->IsKeywordValid(keyword)); |
| 297 validity.SetBoolean("url", edit_controller_->IsURLValid(url)); | 298 validity.SetBoolean("url", edit_controller_->IsURLValid(url)); |
| 298 base::StringValue indexValue(modelIndex); | 299 base::StringValue indexValue(modelIndex); |
| 299 web_ui()->CallJavascriptFunction("SearchEngineManager.validityCheckCallback", | 300 web_ui()->CallJavascriptFunctionUnsafe( |
| 300 validity, indexValue); | 301 "SearchEngineManager.validityCheckCallback", validity, indexValue); |
| 301 } | 302 } |
| 302 | 303 |
| 303 void SearchEngineManagerHandler::EditCancelled(const base::ListValue* args) { | 304 void SearchEngineManagerHandler::EditCancelled(const base::ListValue* args) { |
| 304 if (!edit_controller_.get()) | 305 if (!edit_controller_.get()) |
| 305 return; | 306 return; |
| 306 edit_controller_->CleanUpCancelledAdd(); | 307 edit_controller_->CleanUpCancelledAdd(); |
| 307 edit_controller_.reset(); | 308 edit_controller_.reset(); |
| 308 } | 309 } |
| 309 | 310 |
| 310 void SearchEngineManagerHandler::EditCompleted(const base::ListValue* args) { | 311 void SearchEngineManagerHandler::EditCompleted(const base::ListValue* args) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 322 | 323 |
| 323 // Recheck validity. It's possible to get here with invalid input if e.g. the | 324 // Recheck validity. It's possible to get here with invalid input if e.g. the |
| 324 // user calls the right JS functions directly from the web inspector. | 325 // user calls the right JS functions directly from the web inspector. |
| 325 if (edit_controller_->IsTitleValid(name) && | 326 if (edit_controller_->IsTitleValid(name) && |
| 326 edit_controller_->IsKeywordValid(keyword) && | 327 edit_controller_->IsKeywordValid(keyword) && |
| 327 edit_controller_->IsURLValid(url)) | 328 edit_controller_->IsURLValid(url)) |
| 328 edit_controller_->AcceptAddOrEdit(name, keyword, url); | 329 edit_controller_->AcceptAddOrEdit(name, keyword, url); |
| 329 } | 330 } |
| 330 | 331 |
| 331 } // namespace options | 332 } // namespace options |
| OLD | NEW |