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

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

Issue 11757004: Omnibox: Add Mid-Input Matching to HistoryQuick Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: actually put users in the experiment group Created 7 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/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/command_line.h" 10 #include "base/command_line.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 DCHECK(match.destination_url.is_valid()); 156 DCHECK(match.destination_url.is_valid());
157 // Delete the match from the InMemoryURLIndex. 157 // Delete the match from the InMemoryURLIndex.
158 GetIndex()->DeleteURL(match.destination_url); 158 GetIndex()->DeleteURL(match.destination_url);
159 DeleteMatchFromMatches(match); 159 DeleteMatchFromMatches(match);
160 } 160 }
161 161
162 HistoryQuickProvider::~HistoryQuickProvider() {} 162 HistoryQuickProvider::~HistoryQuickProvider() {}
163 163
164 void HistoryQuickProvider::DoAutocomplete() { 164 void HistoryQuickProvider::DoAutocomplete() {
165 // Get the matching URLs from the DB. 165 // Get the matching URLs from the DB.
166 string16 term_string = autocomplete_input_.text(); 166 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms(
167 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms(term_string); 167 autocomplete_input_.text(),
168 autocomplete_input_.cursor_position());
sky 2013/02/06 04:59:43 If the cursor position factors into the results do
Mark P 2013/02/06 17:53:34 Kind of, yes. But we decided that in order to avo
168 if (matches.empty()) 169 if (matches.empty())
169 return; 170 return;
170 171
171 // If we're allowed to reorder results in order to get an inlineable 172 // If we're allowed to reorder results in order to get an inlineable
172 // result to appear first (and hence have a HistoryQuickProvider 173 // result to appear first (and hence have a HistoryQuickProvider
173 // suggestion possibly appear first), find the first inlineable 174 // suggestion possibly appear first), find the first inlineable
174 // result and then swap it to the front. Obviously, don't do this 175 // result and then swap it to the front. Obviously, don't do this
175 // if we're told to prevent inline autocompletion. (If we're told 176 // if we're told to prevent inline autocompletion. (If we're told
176 // we're going to prevent inline autocompletion, we're going to 177 // we're going to prevent inline autocompletion, we're going to
177 // later demote the score of all results so none will be inlined. 178 // later demote the score of all results so none will be inlined.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 do { 397 do {
397 offset += matches[i].length; 398 offset += matches[i].length;
398 ++i; 399 ++i;
399 } while ((i < match_count) && (offset == matches[i].offset)); 400 } while ((i < match_count) && (offset == matches[i].offset));
400 if (offset < text_length) 401 if (offset < text_length)
401 spans.push_back(ACMatchClassification(offset, url_style)); 402 spans.push_back(ACMatchClassification(offset, url_style));
402 } 403 }
403 404
404 return spans; 405 return spans;
405 } 406 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698