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 18 matching lines...) Expand all Loading... | |
29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
30 #include "components/bookmarks/browser/bookmark_model.h" | 30 #include "components/bookmarks/browser/bookmark_model.h" |
31 #include "components/history/core/browser/history_database.h" | 31 #include "components/history/core/browser/history_database.h" |
32 #include "components/history/core/browser/history_service.h" | 32 #include "components/history/core/browser/history_service.h" |
33 #include "components/metrics/proto/omnibox_input_type.pb.h" | 33 #include "components/metrics/proto/omnibox_input_type.pb.h" |
34 #include "components/omnibox/autocomplete_match_type.h" | 34 #include "components/omnibox/autocomplete_match_type.h" |
35 #include "components/omnibox/autocomplete_result.h" | 35 #include "components/omnibox/autocomplete_result.h" |
36 #include "components/omnibox/omnibox_field_trial.h" | 36 #include "components/omnibox/omnibox_field_trial.h" |
37 #include "components/search_engines/template_url.h" | 37 #include "components/search_engines/template_url.h" |
38 #include "components/search_engines/template_url_service.h" | 38 #include "components/search_engines/template_url_service.h" |
39 #include "components/url_formatter/url_formatter.h" | |
39 #include "content/public/browser/notification_source.h" | 40 #include "content/public/browser/notification_source.h" |
40 #include "content/public/browser/notification_types.h" | 41 #include "content/public/browser/notification_types.h" |
41 #include "net/base/escape.h" | 42 #include "net/base/escape.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 Profile* profile, | 50 Profile* profile, |
51 InMemoryURLIndex* in_memory_url_index) | 51 InMemoryURLIndex* in_memory_url_index) |
52 : HistoryProvider(profile, AutocompleteProvider::TYPE_HISTORY_QUICK), | 52 : HistoryProvider(profile, AutocompleteProvider::TYPE_HISTORY_QUICK), |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 AutocompleteMatch match( | 219 AutocompleteMatch match( |
220 this, score, !!info.visit_count(), | 220 this, score, !!info.visit_count(), |
221 history_match.url_matches.empty() ? | 221 history_match.url_matches.empty() ? |
222 AutocompleteMatchType::HISTORY_TITLE : | 222 AutocompleteMatchType::HISTORY_TITLE : |
223 AutocompleteMatchType::HISTORY_URL); | 223 AutocompleteMatchType::HISTORY_URL); |
224 match.typed_count = info.typed_count(); | 224 match.typed_count = info.typed_count(); |
225 match.destination_url = info.url(); | 225 match.destination_url = info.url(); |
226 DCHECK(match.destination_url.is_valid()); | 226 DCHECK(match.destination_url.is_valid()); |
227 | 227 |
228 // Format the URL autocomplete presentation. | 228 // Format the URL autocomplete presentation. |
229 const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll & | 229 const url_formatter::FormatUrlTypes format_types = |
230 ~(!history_match.match_in_scheme ? 0 : net::kFormatUrlOmitHTTP); | 230 url_formatter::kFormatUrlOmitAll & |
231 ~(!history_match.match_in_scheme ? 0 : url_formatter::kFormatUrlOmitHTTP); | |
231 match.fill_into_edit = | 232 match.fill_into_edit = |
232 AutocompleteInput::FormattedStringWithEquivalentMeaning( | 233 AutocompleteInput::FormattedStringWithEquivalentMeaning( |
233 info.url(), | 234 info.url(), url_formatter::FormatUrl( |
234 net::FormatUrl(info.url(), languages_, format_types, | 235 info.url(), languages_, format_types, |
235 net::UnescapeRule::SPACES, NULL, NULL, NULL), | 236 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr), |
Peter Kasting
2015/06/11 05:12:21
Man, this formatting seems gross :/
| |
236 ChromeAutocompleteSchemeClassifier(profile_)); | 237 ChromeAutocompleteSchemeClassifier(profile_)); |
237 std::vector<size_t> offsets = | 238 std::vector<size_t> offsets = |
238 OffsetsFromTermMatches(history_match.url_matches); | 239 OffsetsFromTermMatches(history_match.url_matches); |
239 base::OffsetAdjuster::Adjustments adjustments; | 240 base::OffsetAdjuster::Adjustments adjustments; |
240 match.contents = net::FormatUrlWithAdjustments( | 241 match.contents = url_formatter::FormatUrlWithAdjustments( |
241 info.url(), languages_, format_types, net::UnescapeRule::SPACES, NULL, | 242 info.url(), languages_, format_types, net::UnescapeRule::SPACES, nullptr, |
242 NULL, &adjustments); | 243 nullptr, &adjustments); |
243 base::OffsetAdjuster::AdjustOffsets(adjustments, &offsets); | 244 base::OffsetAdjuster::AdjustOffsets(adjustments, &offsets); |
244 TermMatches new_matches = | 245 TermMatches new_matches = |
245 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); | 246 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); |
246 match.contents_class = | 247 match.contents_class = |
247 SpansFromTermMatch(new_matches, match.contents.length(), true); | 248 SpansFromTermMatch(new_matches, match.contents.length(), true); |
248 | 249 |
249 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. | 250 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. |
250 if (history_match.can_inline) { | 251 if (history_match.can_inline) { |
251 base::debug::ScopedCrashKey crash_info( | 252 base::debug::ScopedCrashKey crash_info( |
252 crash_keys::kBug464926CrashKey, | 253 crash_keys::kBug464926CrashKey, |
(...skipping 23 matching lines...) Expand all Loading... | |
276 match.description = info.title(); | 277 match.description = info.title(); |
277 match.description_class = SpansFromTermMatch( | 278 match.description_class = SpansFromTermMatch( |
278 history_match.title_matches, match.description.length(), false); | 279 history_match.title_matches, match.description.length(), false); |
279 | 280 |
280 match.RecordAdditionalInfo("typed count", info.typed_count()); | 281 match.RecordAdditionalInfo("typed count", info.typed_count()); |
281 match.RecordAdditionalInfo("visit count", info.visit_count()); | 282 match.RecordAdditionalInfo("visit count", info.visit_count()); |
282 match.RecordAdditionalInfo("last visit", info.last_visit()); | 283 match.RecordAdditionalInfo("last visit", info.last_visit()); |
283 | 284 |
284 return match; | 285 return match; |
285 } | 286 } |
OLD | NEW |