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

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

Issue 8253002: Move PageTransition into content namespace. While I'm touching all these files, I've also updated... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 // autocompleting this term, so we don't need to worry about confusion as 679 // autocompleting this term, so we don't need to worry about confusion as
680 // much. This also prevents calling Classify() again from inside the 680 // much. This also prevents calling Classify() again from inside the
681 // classifier (which will corrupt state and likely crash), since the 681 // classifier (which will corrupt state and likely crash), since the
682 // classifier always disables inline autocomplete. 682 // classifier always disables inline autocomplete.
683 // * When the user has typed the whole term, the "what you typed" history 683 // * When the user has typed the whole term, the "what you typed" history
684 // match will outrank us for URL-like inputs anyway, so we need not do 684 // match will outrank us for URL-like inputs anyway, so we need not do
685 // anything special. 685 // anything special.
686 if (!prevent_inline_autocomplete && classifier && (i->term != input_text)) { 686 if (!prevent_inline_autocomplete && classifier && (i->term != input_text)) {
687 AutocompleteMatch match; 687 AutocompleteMatch match;
688 classifier->Classify(i->term, string16(), false, false, &match, NULL); 688 classifier->Classify(i->term, string16(), false, false, &match, NULL);
689 prevent_inline_autocomplete = match.transition == PageTransition::TYPED; 689 prevent_inline_autocomplete =
690 match.transition == content::PAGE_TRANSITION_TYPED;
690 } 691 }
691 692
692 int relevance = CalculateRelevanceForHistory(i->time, is_keyword, 693 int relevance = CalculateRelevanceForHistory(i->time, is_keyword,
693 prevent_inline_autocomplete); 694 prevent_inline_autocomplete);
694 scored_terms.push_back(std::make_pair(i->term, relevance)); 695 scored_terms.push_back(std::make_pair(i->term, relevance));
695 } 696 }
696 697
697 // History returns results sorted for us. However, we may have docked some 698 // History returns results sorted for us. However, we may have docked some
698 // results' scores, so things are no longer in order. Do a stable sort to get 699 // results' scores, so things are no longer in order. Do a stable sort to get
699 // things back in order without otherwise disturbing results with equal 700 // things back in order without otherwise disturbing results with equal
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 !match.fill_into_edit.compare(search_start, input_text.length(), 881 !match.fill_into_edit.compare(search_start, input_text.length(),
881 input_text)) 882 input_text))
882 match.inline_autocomplete_offset = search_start + input_text.length(); 883 match.inline_autocomplete_offset = search_start + input_text.length();
883 884
884 const TemplateURLRef* const search_url = provider.url(); 885 const TemplateURLRef* const search_url = provider.url();
885 DCHECK(search_url->SupportsReplacement()); 886 DCHECK(search_url->SupportsReplacement());
886 match.destination_url = GURL(search_url->ReplaceSearchTermsUsingProfile( 887 match.destination_url = GURL(search_url->ReplaceSearchTermsUsingProfile(
887 profile_, provider, query_string, accepted_suggestion, input_text)); 888 profile_, provider, query_string, accepted_suggestion, input_text));
888 889
889 // Search results don't look like URLs. 890 // Search results don't look like URLs.
890 match.transition = 891 match.transition = is_keyword ?
891 is_keyword ? PageTransition::KEYWORD : PageTransition::GENERATED; 892 content::PAGE_TRANSITION_KEYWORD : content::PAGE_TRANSITION_GENERATED;
892 893
893 // Try to add |match| to |map|. If a match for |query_string| is already in 894 // Try to add |match| to |map|. If a match for |query_string| is already in
894 // |map|, replace it if |match| is more relevant. 895 // |map|, replace it if |match| is more relevant.
895 // NOTE: Keep this ToLower() call in sync with url_database.cc. 896 // NOTE: Keep this ToLower() call in sync with url_database.cc.
896 const std::pair<MatchMap::iterator, bool> i = map->insert( 897 const std::pair<MatchMap::iterator, bool> i = map->insert(
897 std::pair<string16, AutocompleteMatch>( 898 std::pair<string16, AutocompleteMatch>(
898 base::i18n::ToLower(query_string), match)); 899 base::i18n::ToLower(query_string), match));
899 // NOTE: We purposefully do a direct relevance comparison here instead of 900 // NOTE: We purposefully do a direct relevance comparison here instead of
900 // using AutocompleteMatch::MoreRelevant(), so that we'll prefer "items added 901 // using AutocompleteMatch::MoreRelevant(), so that we'll prefer "items added
901 // first" rather than "items alphabetically first" when the scores are equal. 902 // first" rather than "items alphabetically first" when the scores are equal.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 942
942 return match; 943 return match;
943 } 944 }
944 945
945 void SearchProvider::UpdateDone() { 946 void SearchProvider::UpdateDone() {
946 // We're done when there are no more suggest queries pending (this is set to 1 947 // We're done when there are no more suggest queries pending (this is set to 1
947 // when the timer is started) and we're not waiting on instant. 948 // when the timer is started) and we're not waiting on instant.
948 done_ = ((suggest_results_pending_ == 0) && 949 done_ = ((suggest_results_pending_ == 0) &&
949 (instant_finalized_ || !InstantController::IsEnabled(profile_))); 950 (instant_finalized_ || !InstantController::IsEnabled(profile_)));
950 } 951 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/keyword_provider.cc ('k') | chrome/browser/automation/automation_provider_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698