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/debug/crash_logging.h" | 10 #include "base/debug/crash_logging.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 #include "content/public/browser/notification_types.h" | 40 #include "content/public/browser/notification_types.h" |
41 #include "net/base/escape.h" | 41 #include "net/base/escape.h" |
42 #include "net/base/net_util.h" | 42 #include "net/base/net_util.h" |
43 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 43 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
44 #include "url/third_party/mozilla/url_parse.h" | 44 #include "url/third_party/mozilla/url_parse.h" |
45 #include "url/url_util.h" | 45 #include "url/url_util.h" |
46 | 46 |
47 bool HistoryQuickProvider::disabled_ = false; | 47 bool HistoryQuickProvider::disabled_ = false; |
48 | 48 |
49 HistoryQuickProvider::HistoryQuickProvider( | 49 HistoryQuickProvider::HistoryQuickProvider( |
50 scoped_ptr<AutocompleteProviderClient> client, | |
50 Profile* profile, | 51 Profile* profile, |
51 InMemoryURLIndex* in_memory_url_index) | 52 InMemoryURLIndex* in_memory_url_index) |
52 : HistoryProvider(profile, AutocompleteProvider::TYPE_HISTORY_QUICK), | 53 : HistoryProvider(client.Pass(), AutocompleteProvider::TYPE_HISTORY_QUICK), |
54 profile_(profile), | |
53 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), | 55 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), |
54 in_memory_url_index_(in_memory_url_index) { | 56 in_memory_url_index_(in_memory_url_index) { |
55 } | 57 } |
56 | 58 |
57 void HistoryQuickProvider::Start(const AutocompleteInput& input, | 59 void HistoryQuickProvider::Start(const AutocompleteInput& input, |
58 bool minimal_changes, | 60 bool minimal_changes, |
59 bool called_due_to_focus) { | 61 bool called_due_to_focus) { |
60 matches_.clear(); | 62 matches_.clear(); |
61 if (disabled_ || called_due_to_focus) | 63 if (disabled_ || called_due_to_focus) |
62 return; | 64 return; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 // provider won't promote the URL-what-you-typed match to first | 102 // provider won't promote the URL-what-you-typed match to first |
101 // for these inputs. | 103 // for these inputs. |
102 const bool can_have_url_what_you_typed_match_first = | 104 const bool can_have_url_what_you_typed_match_first = |
103 (autocomplete_input_.type() != metrics::OmniboxInputType::QUERY) && | 105 (autocomplete_input_.type() != metrics::OmniboxInputType::QUERY) && |
104 (!autocomplete_input_.parts().username.is_nonempty() || | 106 (!autocomplete_input_.parts().username.is_nonempty() || |
105 autocomplete_input_.parts().password.is_nonempty() || | 107 autocomplete_input_.parts().password.is_nonempty() || |
106 autocomplete_input_.parts().path.is_nonempty()); | 108 autocomplete_input_.parts().path.is_nonempty()); |
107 if (can_have_url_what_you_typed_match_first) { | 109 if (can_have_url_what_you_typed_match_first) { |
108 history::HistoryService* const history_service = | 110 history::HistoryService* const history_service = |
109 HistoryServiceFactory::GetForProfile( | 111 HistoryServiceFactory::GetForProfile( |
110 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 112 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
Peter Kasting
2015/06/12 16:20:23
Seems like this ought to be using the client's His
blundell
2015/06/15 08:51:33
Done.
| |
111 // We expect HistoryService to be available. In case it's not, | 113 // We expect HistoryService to be available. In case it's not, |
112 // (e.g., due to Profile corruption) we let HistoryQuick provider | 114 // (e.g., due to Profile corruption) we let HistoryQuick provider |
113 // completions (which may be available because it's a different | 115 // completions (which may be available because it's a different |
114 // data structure) compete with the URL-what-you-typed match as | 116 // data structure) compete with the URL-what-you-typed match as |
115 // normal. | 117 // normal. |
116 if (history_service) { | 118 if (history_service) { |
117 history::URLDatabase* url_db = history_service->InMemoryDatabase(); | 119 history::URLDatabase* url_db = history_service->InMemoryDatabase(); |
118 // url_db can be NULL if it hasn't finished initializing (or | 120 // url_db can be NULL if it hasn't finished initializing (or |
119 // failed to to initialize). In this case, we let HistoryQuick | 121 // failed to to initialize). In this case, we let HistoryQuick |
120 // provider completions compete with the URL-what-you-typed | 122 // provider completions compete with the URL-what-you-typed |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 match.description = info.title(); | 278 match.description = info.title(); |
277 match.description_class = SpansFromTermMatch( | 279 match.description_class = SpansFromTermMatch( |
278 history_match.title_matches, match.description.length(), false); | 280 history_match.title_matches, match.description.length(), false); |
279 | 281 |
280 match.RecordAdditionalInfo("typed count", info.typed_count()); | 282 match.RecordAdditionalInfo("typed count", info.typed_count()); |
281 match.RecordAdditionalInfo("visit count", info.visit_count()); | 283 match.RecordAdditionalInfo("visit count", info.visit_count()); |
282 match.RecordAdditionalInfo("last visit", info.last_visit()); | 284 match.RecordAdditionalInfo("last visit", info.last_visit()); |
283 | 285 |
284 return match; | 286 return match; |
285 } | 287 } |
OLD | NEW |