OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 } | 448 } |
449 | 449 |
450 ListValue* result_list = static_cast<ListValue*>(result_val); | 450 ListValue* result_list = static_cast<ListValue*>(result_val); |
451 for (size_t i = 0; i < result_list->GetSize(); ++i) { | 451 for (size_t i = 0; i < result_list->GetSize(); ++i) { |
452 Value* suggestion_val; | 452 Value* suggestion_val; |
453 string16 suggestion_str; | 453 string16 suggestion_str; |
454 if (!result_list->Get(i, &suggestion_val) || | 454 if (!result_list->Get(i, &suggestion_val) || |
455 !suggestion_val->GetAsString(&suggestion_str)) | 455 !suggestion_val->GetAsString(&suggestion_str)) |
456 return false; | 456 return false; |
457 | 457 |
| 458 // Google search may return empty suggestions for weird input characters, |
| 459 // they make no sense at all and can cause problem in our code. |
| 460 // See http://crbug.com/56214 |
| 461 if (!suggestion_str.length()) |
| 462 continue; |
| 463 |
458 Value* type_val; | 464 Value* type_val; |
459 std::string type_str; | 465 std::string type_str; |
460 if (type_list && type_list->Get(i, &type_val) && | 466 if (type_list && type_list->Get(i, &type_val) && |
461 type_val->GetAsString(&type_str) && (type_str == "NAVIGATION")) { | 467 type_val->GetAsString(&type_str) && (type_str == "NAVIGATION")) { |
462 Value* site_val; | 468 Value* site_val; |
463 string16 site_name; | 469 string16 site_name; |
464 NavigationResults& navigation_results = | 470 NavigationResults& navigation_results = |
465 is_keyword ? keyword_navigation_results_ : | 471 is_keyword ? keyword_navigation_results_ : |
466 default_navigation_results_; | 472 default_navigation_results_; |
467 if ((navigation_results.size() < kMaxMatches) && | 473 if ((navigation_results.size() < kMaxMatches) && |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 if (input_.type() == AutocompleteInput::FORCED_QUERY) | 788 if (input_.type() == AutocompleteInput::FORCED_QUERY) |
783 match.fill_into_edit.assign(L"?"); | 789 match.fill_into_edit.assign(L"?"); |
784 match.fill_into_edit.append( | 790 match.fill_into_edit.append( |
785 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url, | 791 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url, |
786 match.contents)); | 792 match.contents)); |
787 // TODO(pkasting): http://b/1112879 These should perhaps be | 793 // TODO(pkasting): http://b/1112879 These should perhaps be |
788 // inline-autocompletable? | 794 // inline-autocompletable? |
789 | 795 |
790 return match; | 796 return match; |
791 } | 797 } |
OLD | NEW |