| 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 <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 10 matching lines...) Expand all Loading... |
| 21 #include "components/metrics/proto/omnibox_input_type.pb.h" | 21 #include "components/metrics/proto/omnibox_input_type.pb.h" |
| 22 #include "components/omnibox/browser/autocomplete_match_type.h" | 22 #include "components/omnibox/browser/autocomplete_match_type.h" |
| 23 #include "components/omnibox/browser/autocomplete_provider_client.h" | 23 #include "components/omnibox/browser/autocomplete_provider_client.h" |
| 24 #include "components/omnibox/browser/autocomplete_result.h" | 24 #include "components/omnibox/browser/autocomplete_result.h" |
| 25 #include "components/omnibox/browser/history_url_provider.h" | 25 #include "components/omnibox/browser/history_url_provider.h" |
| 26 #include "components/omnibox/browser/in_memory_url_index.h" | 26 #include "components/omnibox/browser/in_memory_url_index.h" |
| 27 #include "components/omnibox/browser/in_memory_url_index_types.h" | 27 #include "components/omnibox/browser/in_memory_url_index_types.h" |
| 28 #include "components/omnibox/browser/omnibox_field_trial.h" | 28 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 29 #include "components/search_engines/template_url.h" | 29 #include "components/search_engines/template_url.h" |
| 30 #include "components/search_engines/template_url_service.h" | 30 #include "components/search_engines/template_url_service.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/net_util.h" | |
| 33 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 33 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 34 #include "url/third_party/mozilla/url_parse.h" | 34 #include "url/third_party/mozilla/url_parse.h" |
| 35 #include "url/url_util.h" | 35 #include "url/url_util.h" |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 // Used to help investigate bug 464926. NOTE: This value is defined multiple | 39 // Used to help investigate bug 464926. NOTE: This value is defined multiple |
| 40 // places in the codebase due to layering issues. DO NOT change the value here | 40 // places in the codebase due to layering issues. DO NOT change the value here |
| 41 // without changing it in all other places that it is defined in the codebase | 41 // without changing it in all other places that it is defined in the codebase |
| 42 // (search for |kBug464926CrashKey|). | 42 // (search for |kBug464926CrashKey|). |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 AutocompleteMatch match( | 214 AutocompleteMatch match( |
| 215 this, score, !!info.visit_count(), | 215 this, score, !!info.visit_count(), |
| 216 history_match.url_matches.empty() ? | 216 history_match.url_matches.empty() ? |
| 217 AutocompleteMatchType::HISTORY_TITLE : | 217 AutocompleteMatchType::HISTORY_TITLE : |
| 218 AutocompleteMatchType::HISTORY_URL); | 218 AutocompleteMatchType::HISTORY_URL); |
| 219 match.typed_count = info.typed_count(); | 219 match.typed_count = info.typed_count(); |
| 220 match.destination_url = info.url(); | 220 match.destination_url = info.url(); |
| 221 DCHECK(match.destination_url.is_valid()); | 221 DCHECK(match.destination_url.is_valid()); |
| 222 | 222 |
| 223 // Format the URL autocomplete presentation. | 223 // Format the URL autocomplete presentation. |
| 224 const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll & | 224 const url_formatter::FormatUrlTypes format_types = |
| 225 ~(!history_match.match_in_scheme ? 0 : net::kFormatUrlOmitHTTP); | 225 url_formatter::kFormatUrlOmitAll & |
| 226 ~(!history_match.match_in_scheme ? 0 : url_formatter::kFormatUrlOmitHTTP); |
| 226 match.fill_into_edit = | 227 match.fill_into_edit = |
| 227 AutocompleteInput::FormattedStringWithEquivalentMeaning( | 228 AutocompleteInput::FormattedStringWithEquivalentMeaning( |
| 228 info.url(), | 229 info.url(), url_formatter::FormatUrl( |
| 229 net::FormatUrl(info.url(), languages_, format_types, | 230 info.url(), languages_, format_types, |
| 230 net::UnescapeRule::SPACES, NULL, NULL, NULL), | 231 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr), |
| 231 client()->GetSchemeClassifier()); | 232 client()->GetSchemeClassifier()); |
| 232 std::vector<size_t> offsets = | 233 std::vector<size_t> offsets = |
| 233 OffsetsFromTermMatches(history_match.url_matches); | 234 OffsetsFromTermMatches(history_match.url_matches); |
| 234 base::OffsetAdjuster::Adjustments adjustments; | 235 base::OffsetAdjuster::Adjustments adjustments; |
| 235 match.contents = net::FormatUrlWithAdjustments( | 236 match.contents = url_formatter::FormatUrlWithAdjustments( |
| 236 info.url(), languages_, format_types, net::UnescapeRule::SPACES, NULL, | 237 info.url(), languages_, format_types, net::UnescapeRule::SPACES, nullptr, |
| 237 NULL, &adjustments); | 238 nullptr, &adjustments); |
| 238 base::OffsetAdjuster::AdjustOffsets(adjustments, &offsets); | 239 base::OffsetAdjuster::AdjustOffsets(adjustments, &offsets); |
| 239 TermMatches new_matches = | 240 TermMatches new_matches = |
| 240 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); | 241 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); |
| 241 match.contents_class = | 242 match.contents_class = |
| 242 SpansFromTermMatch(new_matches, match.contents.length(), true); | 243 SpansFromTermMatch(new_matches, match.contents.length(), true); |
| 243 | 244 |
| 244 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. | 245 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. |
| 245 if (history_match.can_inline) { | 246 if (history_match.can_inline) { |
| 246 base::debug::ScopedCrashKey crash_info( | 247 base::debug::ScopedCrashKey crash_info( |
| 247 kBug464926CrashKey, | 248 kBug464926CrashKey, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 272 match.description = info.title(); | 273 match.description = info.title(); |
| 273 match.description_class = SpansFromTermMatch( | 274 match.description_class = SpansFromTermMatch( |
| 274 history_match.title_matches, match.description.length(), false); | 275 history_match.title_matches, match.description.length(), false); |
| 275 | 276 |
| 276 match.RecordAdditionalInfo("typed count", info.typed_count()); | 277 match.RecordAdditionalInfo("typed count", info.typed_count()); |
| 277 match.RecordAdditionalInfo("visit count", info.visit_count()); | 278 match.RecordAdditionalInfo("visit count", info.visit_count()); |
| 278 match.RecordAdditionalInfo("last visit", info.last_visit()); | 279 match.RecordAdditionalInfo("last visit", info.last_visit()); |
| 279 | 280 |
| 280 return match; | 281 return match; |
| 281 } | 282 } |
| OLD | NEW |