| 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 (reorder_for_inlining_) { | 172 if (reorder_for_inlining_) { |
| 172 // If we're allowed to reorder results in order to get an | 173 // If we're allowed to reorder results in order to get an |
| 173 // inlineable result to appear first (and hence have a | 174 // inlineable result to appear first (and hence have a |
| 174 // HistoryQuickProvider suggestion possibly appear first), find | 175 // HistoryQuickProvider suggestion possibly appear first), find |
| 175 // the first inlineable result and then swap it to the front. | 176 // the first inlineable result and then swap it to the front. |
| 176 for (ScoredHistoryMatches::iterator i(matches.begin()); | 177 for (ScoredHistoryMatches::iterator i(matches.begin()); |
| 177 (i != matches.end()) && | 178 (i != matches.end()) && |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 do { | 391 do { |
| 391 offset += matches[i].length; | 392 offset += matches[i].length; |
| 392 ++i; | 393 ++i; |
| 393 } while ((i < match_count) && (offset == matches[i].offset)); | 394 } while ((i < match_count) && (offset == matches[i].offset)); |
| 394 if (offset < text_length) | 395 if (offset < text_length) |
| 395 spans.push_back(ACMatchClassification(offset, url_style)); | 396 spans.push_back(ACMatchClassification(offset, url_style)); |
| 396 } | 397 } |
| 397 | 398 |
| 398 return spans; | 399 return spans; |
| 399 } | 400 } |
| OLD | NEW |