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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 std::string name = "HistoryQuickProvider.QueryIndexTime." + | 83 std::string name = "HistoryQuickProvider.QueryIndexTime." + |
84 base::IntToString(input.text().length()); | 84 base::IntToString(input.text().length()); |
85 base::HistogramBase* counter = base::Histogram::FactoryGet( | 85 base::HistogramBase* counter = base::Histogram::FactoryGet( |
86 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); | 86 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); |
87 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); | 87 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); |
88 } | 88 } |
89 UpdateStarredStateOfMatches(); | 89 UpdateStarredStateOfMatches(); |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) { | |
94 DCHECK(match.deletable); | |
95 DCHECK(match.destination_url.is_valid()); | |
96 // Delete the match from the InMemoryURLIndex. | |
97 GetIndex()->DeleteURL(match.destination_url); | |
98 DeleteMatchFromMatches(match); | |
99 } | |
100 | |
101 HistoryQuickProvider::~HistoryQuickProvider() {} | 93 HistoryQuickProvider::~HistoryQuickProvider() {} |
102 | 94 |
103 void HistoryQuickProvider::DoAutocomplete() { | 95 void HistoryQuickProvider::DoAutocomplete() { |
104 // Get the matching URLs from the DB. | 96 // Get the matching URLs from the DB. |
105 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms( | 97 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms( |
106 autocomplete_input_.text(), | 98 autocomplete_input_.text(), |
107 autocomplete_input_.cursor_position(), | 99 autocomplete_input_.cursor_position(), |
108 AutocompleteProvider::kMaxMatches); | 100 AutocompleteProvider::kMaxMatches); |
109 if (matches.empty()) | 101 if (matches.empty()) |
110 return; | 102 return; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 if (index_for_testing_.get()) | 291 if (index_for_testing_.get()) |
300 return index_for_testing_.get(); | 292 return index_for_testing_.get(); |
301 | 293 |
302 HistoryService* const history_service = | 294 HistoryService* const history_service = |
303 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 295 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
304 if (!history_service) | 296 if (!history_service) |
305 return NULL; | 297 return NULL; |
306 | 298 |
307 return history_service->InMemoryIndex(); | 299 return history_service->InMemoryIndex(); |
308 } | 300 } |
OLD | NEW |