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