Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: chrome/browser/autocomplete/search_provider.cc

Issue 22364007: AutocompleteInput::PageClassification -> AutocompleteInput::OmniboxContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 619
620 void SearchProvider::DoHistoryQuery(bool minimal_changes) { 620 void SearchProvider::DoHistoryQuery(bool minimal_changes) {
621 // The history query results are synchronous, so if minimal_changes is true, 621 // The history query results are synchronous, so if minimal_changes is true,
622 // we still have the last results and don't need to do anything. 622 // we still have the last results and don't need to do anything.
623 if (minimal_changes) 623 if (minimal_changes)
624 return; 624 return;
625 625
626 keyword_history_results_.clear(); 626 keyword_history_results_.clear();
627 default_history_results_.clear(); 627 default_history_results_.clear();
628 628
629 if (OmniboxFieldTrial::SearchHistoryDisable( 629 if (OmniboxFieldTrial::SearchHistoryDisable(input_.omnibox_context()))
630 input_.current_page_classification()))
631 return; 630 return;
632 631
633 HistoryService* const history_service = 632 HistoryService* const history_service =
634 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 633 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
635 history::URLDatabase* url_db = history_service ? 634 history::URLDatabase* url_db = history_service ?
636 history_service->InMemoryDatabase() : NULL; 635 history_service->InMemoryDatabase() : NULL;
637 if (!url_db) 636 if (!url_db)
638 return; 637 return;
639 638
640 // Request history for both the keyword and default provider. We grab many 639 // Request history for both the keyword and default provider. We grab many
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults( 1193 SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults(
1195 const HistoryResults& results, 1194 const HistoryResults& results,
1196 bool base_prevent_inline_autocomplete, 1195 bool base_prevent_inline_autocomplete,
1197 bool input_multiple_words, 1196 bool input_multiple_words,
1198 const string16& input_text, 1197 const string16& input_text,
1199 bool is_keyword) { 1198 bool is_keyword) {
1200 AutocompleteClassifier* classifier = 1199 AutocompleteClassifier* classifier =
1201 AutocompleteClassifierFactory::GetForProfile(profile_); 1200 AutocompleteClassifierFactory::GetForProfile(profile_);
1202 SuggestResults scored_results; 1201 SuggestResults scored_results;
1203 const bool prevent_search_history_inlining = 1202 const bool prevent_search_history_inlining =
1204 OmniboxFieldTrial::SearchHistoryPreventInlining( 1203 OmniboxFieldTrial::SearchHistoryPreventInlining(input_.omnibox_context());
1205 input_.current_page_classification());
1206 for (HistoryResults::const_iterator i(results.begin()); i != results.end(); 1204 for (HistoryResults::const_iterator i(results.begin()); i != results.end();
1207 ++i) { 1205 ++i) {
1208 // Don't autocomplete multi-word queries that have only been seen once 1206 // Don't autocomplete multi-word queries that have only been seen once
1209 // unless the user has typed more than one word. 1207 // unless the user has typed more than one word.
1210 bool prevent_inline_autocomplete = base_prevent_inline_autocomplete || 1208 bool prevent_inline_autocomplete = base_prevent_inline_autocomplete ||
1211 (!input_multiple_words && (i->visits < 2) && HasMultipleWords(i->term)); 1209 (!input_multiple_words && (i->visits < 2) && HasMultipleWords(i->term));
1212 1210
1213 // Don't autocomplete search terms that would normally be treated as URLs 1211 // Don't autocomplete search terms that would normally be treated as URLs
1214 // when typed. For example, if the user searched for "google.com" and types 1212 // when typed. For example, if the user searched for "google.com" and types
1215 // "goog", don't autocomplete to the search term "google.com". Otherwise, 1213 // "goog", don't autocomplete to the search term "google.com". Otherwise,
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 it->set_relevance(max_query_relevance); 1514 it->set_relevance(max_query_relevance);
1517 it->set_relevance_from_server(relevance_from_server); 1515 it->set_relevance_from_server(relevance_from_server);
1518 } 1516 }
1519 } 1517 }
1520 1518
1521 void SearchProvider::UpdateDone() { 1519 void SearchProvider::UpdateDone() {
1522 // We're done when the timer isn't running, there are no suggest queries 1520 // We're done when the timer isn't running, there are no suggest queries
1523 // pending, and we're not waiting on Instant. 1521 // pending, and we're not waiting on Instant.
1524 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); 1522 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0);
1525 } 1523 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698