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

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

Issue 7314018: Don't autocomplete searches of >1 word if they've only been visited once and the user has not yet... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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/history_quick_provider.h" 5 #include "chrome/browser/autocomplete/history_quick_provider.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/i18n/break_iterator.h" 10 #include "base/i18n/break_iterator.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/common/content_notification_types.h" 25 #include "content/common/content_notification_types.h"
26 #include "content/common/notification_source.h" 26 #include "content/common/notification_source.h"
27 #include "googleurl/src/url_util.h" 27 #include "googleurl/src/url_util.h"
28 #include "net/base/escape.h" 28 #include "net/base/escape.h"
29 #include "net/base/net_util.h" 29 #include "net/base/net_util.h"
30 30
31 using history::InMemoryURLIndex; 31 using history::InMemoryURLIndex;
32 using history::ScoredHistoryMatch; 32 using history::ScoredHistoryMatch;
33 using history::ScoredHistoryMatches; 33 using history::ScoredHistoryMatches;
34 34
35 // The initial maximum allowable score for a match which cannot be inlined.
36 const int kMaxNonInliningScore = 1199;
37
38 HistoryQuickProvider::HistoryQuickProvider(ACProviderListener* listener, 35 HistoryQuickProvider::HistoryQuickProvider(ACProviderListener* listener,
39 Profile* profile) 36 Profile* profile)
40 : HistoryProvider(listener, profile, "HistoryQuickProvider"), 37 : HistoryProvider(listener, profile, "HistoryQuickProvider"),
41 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) {} 38 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) {}
42 39
43 HistoryQuickProvider::~HistoryQuickProvider() {} 40 HistoryQuickProvider::~HistoryQuickProvider() {}
44 41
45 void HistoryQuickProvider::Start(const AutocompleteInput& input, 42 void HistoryQuickProvider::Start(const AutocompleteInput& input,
46 bool minimal_changes) { 43 bool minimal_changes) {
47 matches_.clear(); 44 matches_.clear();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (history_match.raw_score > 0) { 113 if (history_match.raw_score > 0) {
117 AutocompleteMatch ac_match = QuickMatchToACMatch( 114 AutocompleteMatch ac_match = QuickMatchToACMatch(
118 history_match, 115 history_match,
119 PreventInlineAutocomplete(autocomplete_input_), 116 PreventInlineAutocomplete(autocomplete_input_),
120 &max_match_score); 117 &max_match_score);
121 matches_.push_back(ac_match); 118 matches_.push_back(ac_match);
122 } 119 }
123 } 120 }
124 } 121 }
125 122
123 // static
124 const int HistoryQuickProvider::kMaxNonInliningScore =
125 AutocompleteResult::kLowestDefaultScore - 1;
126
126 AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch( 127 AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch(
127 const ScoredHistoryMatch& history_match, 128 const ScoredHistoryMatch& history_match,
128 bool prevent_inline_autocomplete, 129 bool prevent_inline_autocomplete,
129 int* max_match_score) { 130 int* max_match_score) {
130 DCHECK(max_match_score); 131 DCHECK(max_match_score);
131 const history::URLRow& info = history_match.url_info; 132 const history::URLRow& info = history_match.url_info;
132 int score = CalculateRelevance(history_match, max_match_score); 133 int score = CalculateRelevance(history_match, max_match_score);
133 AutocompleteMatch match(this, score, !!info.visit_count(), 134 AutocompleteMatch match(this, score, !!info.visit_count(),
134 history_match.url_matches.empty() ? 135 history_match.url_matches.empty() ?
135 AutocompleteMatch::HISTORY_URL : 136 AutocompleteMatch::HISTORY_URL :
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 do { 224 do {
224 offset += matches[i].length; 225 offset += matches[i].length;
225 ++i; 226 ++i;
226 } while ((i < match_count) && (offset == matches[i].offset)); 227 } while ((i < match_count) && (offset == matches[i].offset));
227 if (offset < text_length) 228 if (offset < text_length)
228 spans.push_back(ACMatchClassification(offset, url_style)); 229 spans.push_back(ACMatchClassification(offset, url_style));
229 } 230 }
230 231
231 return spans; 232 return spans;
232 } 233 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698