| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/settings/search_engines_handler.h" | 5 #include "chrome/browser/ui/webui/settings/search_engines_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 CHECK_EQ(3U, args->GetSize()); | 274 CHECK_EQ(3U, args->GetSize()); |
| 275 | 275 |
| 276 const base::Value* callback_id; | 276 const base::Value* callback_id; |
| 277 std::string field_name; | 277 std::string field_name; |
| 278 std::string field_value; | 278 std::string field_value; |
| 279 CHECK(args->Get(0, &callback_id)); | 279 CHECK(args->Get(0, &callback_id)); |
| 280 CHECK(args->GetString(1, &field_name)); | 280 CHECK(args->GetString(1, &field_name)); |
| 281 CHECK(args->GetString(2, &field_value)); | 281 CHECK(args->GetString(2, &field_value)); |
| 282 ResolveJavascriptCallback( | 282 ResolveJavascriptCallback( |
| 283 *callback_id, | 283 *callback_id, |
| 284 base::FundamentalValue(CheckFieldValidity(field_name, field_value))); | 284 base::Value(CheckFieldValidity(field_name, field_value))); |
| 285 } | 285 } |
| 286 | 286 |
| 287 bool SearchEnginesHandler::CheckFieldValidity(const std::string& field_name, | 287 bool SearchEnginesHandler::CheckFieldValidity(const std::string& field_name, |
| 288 const std::string& field_value) { | 288 const std::string& field_value) { |
| 289 if (!edit_controller_.get()) | 289 if (!edit_controller_.get()) |
| 290 return false; | 290 return false; |
| 291 | 291 |
| 292 bool is_valid = false; | 292 bool is_valid = false; |
| 293 if (field_name.compare(kSearchEngineField) == 0) | 293 if (field_name.compare(kSearchEngineField) == 0) |
| 294 is_valid = edit_controller_->IsTitleValid(base::UTF8ToUTF16(field_value)); | 294 is_valid = edit_controller_->IsTitleValid(base::UTF8ToUTF16(field_value)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 325 // user calls the right JS functions directly from the web inspector. | 325 // user calls the right JS functions directly from the web inspector. |
| 326 if (CheckFieldValidity(kSearchEngineField, search_engine) && | 326 if (CheckFieldValidity(kSearchEngineField, search_engine) && |
| 327 CheckFieldValidity(kKeywordField, keyword) && | 327 CheckFieldValidity(kKeywordField, keyword) && |
| 328 CheckFieldValidity(kQueryUrlField, query_url)) { | 328 CheckFieldValidity(kQueryUrlField, query_url)) { |
| 329 edit_controller_->AcceptAddOrEdit(base::UTF8ToUTF16(search_engine), | 329 edit_controller_->AcceptAddOrEdit(base::UTF8ToUTF16(search_engine), |
| 330 base::UTF8ToUTF16(keyword), query_url); | 330 base::UTF8ToUTF16(keyword), query_url); |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 | 333 |
| 334 } // namespace settings | 334 } // namespace settings |
| OLD | NEW |