| 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/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 "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 260 |
| 261 input_ = input; | 261 input_ = input; |
| 262 | 262 |
| 263 DoHistoryQuery(minimal_changes); | 263 DoHistoryQuery(minimal_changes); |
| 264 DoAnswersQuery(input); | 264 DoAnswersQuery(input); |
| 265 StartOrStopSuggestQuery(minimal_changes); | 265 StartOrStopSuggestQuery(minimal_changes); |
| 266 UpdateMatches(); | 266 UpdateMatches(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void SearchProvider::SortResults(bool is_keyword, | 269 void SearchProvider::SortResults(bool is_keyword, |
| 270 bool relevances_from_server, | |
| 271 SearchSuggestionParser::Results* results) { | 270 SearchSuggestionParser::Results* results) { |
| 272 // Ignore suggested scores for non-keyword matches in keyword mode; if the | 271 // Ignore suggested scores for non-keyword matches in keyword mode; if the |
| 273 // server is allowed to score these, it could interfere with the user's | 272 // server is allowed to score these, it could interfere with the user's |
| 274 // ability to get good keyword results. | 273 // ability to get good keyword results. |
| 275 const bool abandon_suggested_scores = | 274 const bool abandon_suggested_scores = |
| 276 !is_keyword && !providers_.keyword_provider().empty(); | 275 !is_keyword && !providers_.keyword_provider().empty(); |
| 277 // Apply calculated relevance scores to suggestions if valid relevances were | 276 // Apply calculated relevance scores to suggestions if valid relevances were |
| 278 // not provided or we're abandoning suggested scores entirely. | 277 // not provided or we're abandoning suggested scores entirely. |
| 279 if (!relevances_from_server || abandon_suggested_scores) { | 278 if (!results->relevances_from_server || abandon_suggested_scores) { |
| 280 ApplyCalculatedSuggestRelevance(&results->suggest_results); | 279 ApplyCalculatedSuggestRelevance(&results->suggest_results); |
| 281 ApplyCalculatedNavigationRelevance(&results->navigation_results); | 280 ApplyCalculatedNavigationRelevance(&results->navigation_results); |
| 282 // If abandoning scores entirely, also abandon the verbatim score. | 281 // If abandoning scores entirely, also abandon the verbatim score. |
| 283 if (abandon_suggested_scores) | 282 if (abandon_suggested_scores) |
| 284 results->verbatim_relevance = -1; | 283 results->verbatim_relevance = -1; |
| 285 } | 284 } |
| 286 | 285 |
| 287 // Keep the result lists sorted. | 286 // Keep the result lists sorted. |
| 288 const CompareScoredResults comparator = CompareScoredResults(); | 287 const CompareScoredResults comparator = CompareScoredResults(); |
| 289 std::stable_sort(results->suggest_results.begin(), | 288 std::stable_sort(results->suggest_results.begin(), |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 last_answer_seen_.query_type = match->answer_type; | 1241 last_answer_seen_.query_type = match->answer_type; |
| 1243 } | 1242 } |
| 1244 | 1243 |
| 1245 void SearchProvider::DoAnswersQuery(const AutocompleteInput& input) { | 1244 void SearchProvider::DoAnswersQuery(const AutocompleteInput& input) { |
| 1246 // If the query text starts with trimmed input, this is valid prefetch data. | 1245 // If the query text starts with trimmed input, this is valid prefetch data. |
| 1247 prefetch_data_ = StartsWith(last_answer_seen_.full_query_text, | 1246 prefetch_data_ = StartsWith(last_answer_seen_.full_query_text, |
| 1248 base::CollapseWhitespace(input.text(), false), | 1247 base::CollapseWhitespace(input.text(), false), |
| 1249 false) ? | 1248 false) ? |
| 1250 last_answer_seen_ : AnswersQueryData(); | 1249 last_answer_seen_ : AnswersQueryData(); |
| 1251 } | 1250 } |
| OLD | NEW |