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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 std::string name = "HistoryQuickProvider.QueryIndexTime." + | 140 std::string name = "HistoryQuickProvider.QueryIndexTime." + |
141 base::IntToString(input.text().length()); | 141 base::IntToString(input.text().length()); |
142 base::Histogram* counter = base::Histogram::FactoryGet( | 142 base::Histogram* counter = base::Histogram::FactoryGet( |
143 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); | 143 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); |
144 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); | 144 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); |
145 } | 145 } |
146 UpdateStarredStateOfMatches(); | 146 UpdateStarredStateOfMatches(); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) { | 150 // TODO(mrossetti): Implement this function. (Will happen in next CL.) |
151 DCHECK(match.deletable); | 151 void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) {} |
152 DCHECK(match.destination_url.is_valid()); | |
153 // Delete the match from the InMemoryURLIndex. | |
154 GetIndex()->DeleteURL(match.destination_url); | |
155 DeleteMatchFromMatches(match); | |
156 } | |
157 | 152 |
158 HistoryQuickProvider::~HistoryQuickProvider() {} | 153 HistoryQuickProvider::~HistoryQuickProvider() {} |
159 | 154 |
160 void HistoryQuickProvider::DoAutocomplete() { | 155 void HistoryQuickProvider::DoAutocomplete() { |
161 // Get the matching URLs from the DB. | 156 // Get the matching URLs from the DB. |
162 string16 term_string = autocomplete_input_.text(); | 157 string16 term_string = autocomplete_input_.text(); |
163 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms(term_string); | 158 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms(term_string); |
164 if (matches.empty()) | 159 if (matches.empty()) |
165 return; | 160 return; |
166 | 161 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 do { | 288 do { |
294 offset += matches[i].length; | 289 offset += matches[i].length; |
295 ++i; | 290 ++i; |
296 } while ((i < match_count) && (offset == matches[i].offset)); | 291 } while ((i < match_count) && (offset == matches[i].offset)); |
297 if (offset < text_length) | 292 if (offset < text_length) |
298 spans.push_back(ACMatchClassification(offset, url_style)); | 293 spans.push_back(ACMatchClassification(offset, url_style)); |
299 } | 294 } |
300 | 295 |
301 return spans; | 296 return spans; |
302 } | 297 } |
OLD | NEW |