OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/search/instant_controller.h" | 5 #include "chrome/browser/ui/search/instant_controller.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 for (AutocompleteResult::const_iterator match(autocomplete_result.begin()); | 645 for (AutocompleteResult::const_iterator match(autocomplete_result.begin()); |
646 match != autocomplete_result.end(); ++match) { | 646 match != autocomplete_result.end(); ++match) { |
647 InstantAutocompleteResult result; | 647 InstantAutocompleteResult result; |
648 PopulateInstantAutocompleteResultFromMatch( | 648 PopulateInstantAutocompleteResultFromMatch( |
649 *match, std::distance(autocomplete_result.begin(), match), &result); | 649 *match, std::distance(autocomplete_result.begin(), match), &result); |
650 results.push_back(result); | 650 results.push_back(result); |
651 } | 651 } |
652 } else { | 652 } else { |
653 for (ACProviders::const_iterator provider = providers.begin(); | 653 for (ACProviders::const_iterator provider = providers.begin(); |
654 provider != providers.end(); ++provider) { | 654 provider != providers.end(); ++provider) { |
655 // We are talking to remote NTP, skip SearchProvider, since it only echoes | |
656 // suggestions. | |
657 if ((*provider)->type() == AutocompleteProvider::TYPE_SEARCH) | |
658 continue; | |
659 | |
660 for (ACMatches::const_iterator match = (*provider)->matches().begin(); | 655 for (ACMatches::const_iterator match = (*provider)->matches().begin(); |
661 match != (*provider)->matches().end(); ++match) { | 656 match != (*provider)->matches().end(); ++match) { |
| 657 // When the top match is an inline history URL, the page calls |
| 658 // SetSuggestions(url) which calls FinalizeInstantQuery() in |
| 659 // SearchProvider creating a NAVSUGGEST match for the URL. If we sent |
| 660 // this NAVSUGGEST match back to the page, it would be deduped against |
| 661 // the original history match and replace it. But since the page ignores |
| 662 // SearchProvider suggestions, the match would then disappear. Yuck. |
| 663 // TODO(jered): Remove this when FinalizeInstantQuery() is ripped out. |
| 664 if ((*provider)->type() == AutocompleteProvider::TYPE_SEARCH && |
| 665 match->type == AutocompleteMatchType::NAVSUGGEST) { |
| 666 continue; |
| 667 } |
662 InstantAutocompleteResult result; | 668 InstantAutocompleteResult result; |
663 PopulateInstantAutocompleteResultFromMatch(*match, kNoMatchIndex, | 669 PopulateInstantAutocompleteResultFromMatch(*match, kNoMatchIndex, |
664 &result); | 670 &result); |
665 results.push_back(result); | 671 results.push_back(result); |
666 } | 672 } |
667 } | 673 } |
668 } | 674 } |
669 LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( | 675 LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( |
670 "HandleAutocompleteResults: total_results=%d", | 676 "HandleAutocompleteResults: total_results=%d", |
671 static_cast<int>(results.size()))); | 677 static_cast<int>(results.size()))); |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1875 result->transition = match.transition; | 1881 result->transition = match.transition; |
1876 result->relevance = match.relevance; | 1882 result->relevance = match.relevance; |
1877 result->autocomplete_match_index = autocomplete_match_index; | 1883 result->autocomplete_match_index = autocomplete_match_index; |
1878 | 1884 |
1879 DVLOG(1) << " " << result->relevance << " " | 1885 DVLOG(1) << " " << result->relevance << " " |
1880 << UTF8ToUTF16(AutocompleteMatchType::ToString(result->type)) << " " | 1886 << UTF8ToUTF16(AutocompleteMatchType::ToString(result->type)) << " " |
1881 << result->provider << " " << result->destination_url << " '" | 1887 << result->provider << " " << result->destination_url << " '" |
1882 << result->description << "' '" << result->search_query << "' " | 1888 << result->description << "' '" << result->search_query << "' " |
1883 << result->transition << " " << result->autocomplete_match_index; | 1889 << result->transition << " " << result->autocomplete_match_index; |
1884 } | 1890 } |
OLD | NEW |