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 "components/omnibox/browser/history_quick_provider.h" | 5 #include "components/omnibox/browser/history_quick_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
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/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/trace_event/trace_event.h" |
17 #include "components/bookmarks/browser/bookmark_model.h" | 18 #include "components/bookmarks/browser/bookmark_model.h" |
18 #include "components/history/core/browser/history_database.h" | 19 #include "components/history/core/browser/history_database.h" |
19 #include "components/history/core/browser/history_service.h" | 20 #include "components/history/core/browser/history_service.h" |
20 #include "components/metrics/proto/omnibox_input_type.pb.h" | 21 #include "components/metrics/proto/omnibox_input_type.pb.h" |
21 #include "components/omnibox/browser/autocomplete_match_type.h" | 22 #include "components/omnibox/browser/autocomplete_match_type.h" |
22 #include "components/omnibox/browser/autocomplete_provider_client.h" | 23 #include "components/omnibox/browser/autocomplete_provider_client.h" |
23 #include "components/omnibox/browser/autocomplete_result.h" | 24 #include "components/omnibox/browser/autocomplete_result.h" |
24 #include "components/omnibox/browser/history_url_provider.h" | 25 #include "components/omnibox/browser/history_url_provider.h" |
25 #include "components/omnibox/browser/in_memory_url_index.h" | 26 #include "components/omnibox/browser/in_memory_url_index.h" |
26 #include "components/omnibox/browser/in_memory_url_index_types.h" | 27 #include "components/omnibox/browser/in_memory_url_index_types.h" |
27 #include "components/omnibox/browser/omnibox_field_trial.h" | 28 #include "components/omnibox/browser/omnibox_field_trial.h" |
28 #include "components/omnibox/browser/url_prefix.h" | 29 #include "components/omnibox/browser/url_prefix.h" |
29 #include "components/prefs/pref_service.h" | 30 #include "components/prefs/pref_service.h" |
30 #include "components/url_formatter/url_formatter.h" | 31 #include "components/url_formatter/url_formatter.h" |
31 #include "net/base/escape.h" | 32 #include "net/base/escape.h" |
32 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 33 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
33 #include "url/third_party/mozilla/url_parse.h" | 34 #include "url/third_party/mozilla/url_parse.h" |
34 #include "url/url_util.h" | 35 #include "url/url_util.h" |
35 | 36 |
36 bool HistoryQuickProvider::disabled_ = false; | 37 bool HistoryQuickProvider::disabled_ = false; |
37 | 38 |
38 HistoryQuickProvider::HistoryQuickProvider(AutocompleteProviderClient* client) | 39 HistoryQuickProvider::HistoryQuickProvider(AutocompleteProviderClient* client) |
39 : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_QUICK, client), | 40 : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_QUICK, client), |
40 languages_(client->GetAcceptLanguages()), | 41 languages_(client->GetAcceptLanguages()), |
41 in_memory_url_index_(client->GetInMemoryURLIndex()) { | 42 in_memory_url_index_(client->GetInMemoryURLIndex()) { |
42 } | 43 } |
43 | 44 |
44 void HistoryQuickProvider::Start(const AutocompleteInput& input, | 45 void HistoryQuickProvider::Start(const AutocompleteInput& input, |
45 bool minimal_changes) { | 46 bool minimal_changes) { |
| 47 TRACE_EVENT0("omnibox", "HistoryQuickProvider::Start"); |
46 matches_.clear(); | 48 matches_.clear(); |
47 if (disabled_ || input.from_omnibox_focus()) | 49 if (disabled_ || input.from_omnibox_focus()) |
48 return; | 50 return; |
49 | 51 |
50 // Don't bother with INVALID and FORCED_QUERY. | 52 // Don't bother with INVALID and FORCED_QUERY. |
51 if ((input.type() == metrics::OmniboxInputType::INVALID) || | 53 if ((input.type() == metrics::OmniboxInputType::INVALID) || |
52 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) | 54 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) |
53 return; | 55 return; |
54 | 56 |
55 autocomplete_input_ = input; | 57 autocomplete_input_ = input; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 match.description = info.title(); | 251 match.description = info.title(); |
250 match.description_class = SpansFromTermMatch( | 252 match.description_class = SpansFromTermMatch( |
251 history_match.title_matches, match.description.length(), false); | 253 history_match.title_matches, match.description.length(), false); |
252 | 254 |
253 match.RecordAdditionalInfo("typed count", info.typed_count()); | 255 match.RecordAdditionalInfo("typed count", info.typed_count()); |
254 match.RecordAdditionalInfo("visit count", info.visit_count()); | 256 match.RecordAdditionalInfo("visit count", info.visit_count()); |
255 match.RecordAdditionalInfo("last visit", info.last_visit()); | 257 match.RecordAdditionalInfo("last visit", info.last_visit()); |
256 | 258 |
257 return match; | 259 return match; |
258 } | 260 } |
OLD | NEW |