| 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" |
| 11 #include "base/i18n/break_iterator.h" | 11 #include "base/i18n/break_iterator.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_result.h" | 20 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 21 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 21 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 22 #include "chrome/browser/autocomplete/history_url_provider.h" | 22 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | |
| 24 #include "chrome/browser/history/history_database.h" | 23 #include "chrome/browser/history/history_database.h" |
| 25 #include "chrome/browser/history/history_service.h" | 24 #include "chrome/browser/history/history_service.h" |
| 26 #include "chrome/browser/history/history_service_factory.h" | 25 #include "chrome/browser/history/history_service_factory.h" |
| 27 #include "chrome/browser/history/in_memory_url_index.h" | 26 #include "chrome/browser/history/in_memory_url_index.h" |
| 28 #include "chrome/browser/history/in_memory_url_index_types.h" | 27 #include "chrome/browser/history/in_memory_url_index_types.h" |
| 29 #include "chrome/browser/history/scored_history_match.h" | 28 #include "chrome/browser/history/scored_history_match.h" |
| 30 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 29 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/browser/search_engines/template_url_service_factory.h" | 31 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 33 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 base::TimeTicks start_time = base::TimeTicks::Now(); | 75 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 77 DoAutocomplete(); | 76 DoAutocomplete(); |
| 78 if (input.text().length() < 6) { | 77 if (input.text().length() < 6) { |
| 79 base::TimeTicks end_time = base::TimeTicks::Now(); | 78 base::TimeTicks end_time = base::TimeTicks::Now(); |
| 80 std::string name = "HistoryQuickProvider.QueryIndexTime." + | 79 std::string name = "HistoryQuickProvider.QueryIndexTime." + |
| 81 base::IntToString(input.text().length()); | 80 base::IntToString(input.text().length()); |
| 82 base::HistogramBase* counter = base::Histogram::FactoryGet( | 81 base::HistogramBase* counter = base::Histogram::FactoryGet( |
| 83 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); | 82 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); |
| 84 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); | 83 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); |
| 85 } | 84 } |
| 86 UpdateStarredStateOfMatches(BookmarkModelFactory::GetForProfile(profile_)); | |
| 87 } | 85 } |
| 88 } | 86 } |
| 89 | 87 |
| 90 HistoryQuickProvider::~HistoryQuickProvider() {} | 88 HistoryQuickProvider::~HistoryQuickProvider() {} |
| 91 | 89 |
| 92 void HistoryQuickProvider::DoAutocomplete() { | 90 void HistoryQuickProvider::DoAutocomplete() { |
| 93 // Get the matching URLs from the DB. | 91 // Get the matching URLs from the DB. |
| 94 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms( | 92 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms( |
| 95 autocomplete_input_.text(), | 93 autocomplete_input_.text(), |
| 96 autocomplete_input_.cursor_position(), | 94 autocomplete_input_.cursor_position(), |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 if (index_for_testing_.get()) | 291 if (index_for_testing_.get()) |
| 294 return index_for_testing_.get(); | 292 return index_for_testing_.get(); |
| 295 | 293 |
| 296 HistoryService* const history_service = | 294 HistoryService* const history_service = |
| 297 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 295 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 298 if (!history_service) | 296 if (!history_service) |
| 299 return NULL; | 297 return NULL; |
| 300 | 298 |
| 301 return history_service->InMemoryIndex(); | 299 return history_service->InMemoryIndex(); |
| 302 } | 300 } |
| OLD | NEW |