| OLD | NEW |
| 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 Loading... |
| 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()); |
| 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 Loading... |
| 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 } |
| OLD | NEW |