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/callback.h" | 10 #include "base/callback.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 245 |
246 SearchProvider::SearchProvider(AutocompleteProviderListener* listener, | 246 SearchProvider::SearchProvider(AutocompleteProviderListener* listener, |
247 Profile* profile) | 247 Profile* profile) |
248 : AutocompleteProvider(listener, profile, | 248 : AutocompleteProvider(listener, profile, |
249 AutocompleteProvider::TYPE_SEARCH), | 249 AutocompleteProvider::TYPE_SEARCH), |
250 providers_(TemplateURLServiceFactory::GetForProfile(profile)), | 250 providers_(TemplateURLServiceFactory::GetForProfile(profile)), |
251 suggest_results_pending_(0), | 251 suggest_results_pending_(0), |
252 field_trial_triggered_(false), | 252 field_trial_triggered_(false), |
253 field_trial_triggered_in_session_(false), | 253 field_trial_triggered_in_session_(false), |
254 omnibox_start_margin_(-1), | 254 omnibox_start_margin_(-1), |
255 prevent_search_history_inlining_( | 255 prevent_search_history_inlining_(false), |
256 OmniboxFieldTrial::SearchHistoryPreventInlining()), | 256 disable_search_history_(false) { |
257 disable_search_history_( | |
258 OmniboxFieldTrial::SearchHistoryDisable()) { | |
259 } | 257 } |
260 | 258 |
261 // static | 259 // static |
262 AutocompleteMatch SearchProvider::CreateSearchSuggestion( | 260 AutocompleteMatch SearchProvider::CreateSearchSuggestion( |
263 AutocompleteProvider* autocomplete_provider, | 261 AutocompleteProvider* autocomplete_provider, |
264 int relevance, | 262 int relevance, |
265 AutocompleteMatch::Type type, | 263 AutocompleteMatch::Type type, |
266 const TemplateURL* template_url, | 264 const TemplateURL* template_url, |
267 const string16& query_string, | 265 const string16& query_string, |
268 const string16& input_text, | 266 const string16& input_text, |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 match.contents_class.push_back( | 514 match.contents_class.push_back( |
517 ACMatchClassification(0, ACMatchClassification::NONE)); | 515 ACMatchClassification(0, ACMatchClassification::NONE)); |
518 match.keyword = providers_.default_provider(); | 516 match.keyword = providers_.default_provider(); |
519 matches_.push_back(match); | 517 matches_.push_back(match); |
520 } | 518 } |
521 Stop(false); | 519 Stop(false); |
522 return; | 520 return; |
523 } | 521 } |
524 | 522 |
525 input_ = input; | 523 input_ = input; |
| 524 prevent_search_history_inlining_ = |
| 525 OmniboxFieldTrial::SearchHistoryPreventInlining( |
| 526 input_.current_page_classification()); |
| 527 disable_search_history_ = OmniboxFieldTrial::SearchHistoryDisable( |
| 528 input_.current_page_classification()); |
526 | 529 |
527 DoHistoryQuery(minimal_changes); | 530 DoHistoryQuery(minimal_changes); |
528 StartOrStopSuggestQuery(minimal_changes); | 531 StartOrStopSuggestQuery(minimal_changes); |
529 UpdateMatches(); | 532 UpdateMatches(); |
530 } | 533 } |
531 | 534 |
532 void SearchProvider::Stop(bool clear_cached_results) { | 535 void SearchProvider::Stop(bool clear_cached_results) { |
533 StopSuggest(); | 536 StopSuggest(); |
534 done_ = true; | 537 done_ = true; |
535 | 538 |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 it->set_relevance(max_query_relevance); | 1517 it->set_relevance(max_query_relevance); |
1515 it->set_relevance_from_server(relevance_from_server); | 1518 it->set_relevance_from_server(relevance_from_server); |
1516 } | 1519 } |
1517 } | 1520 } |
1518 | 1521 |
1519 void SearchProvider::UpdateDone() { | 1522 void SearchProvider::UpdateDone() { |
1520 // We're done when the timer isn't running, there are no suggest queries | 1523 // We're done when the timer isn't running, there are no suggest queries |
1521 // pending, and we're not waiting on Instant. | 1524 // pending, and we're not waiting on Instant. |
1522 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); | 1525 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); |
1523 } | 1526 } |
OLD | NEW |