OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/verbatim_match.h" | 5 #include "components/omnibox/browser/verbatim_match.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "components/omnibox/browser/autocomplete_classifier.h" | 8 #include "components/omnibox/browser/autocomplete_classifier.h" |
9 #include "components/omnibox/browser/autocomplete_input.h" | 9 #include "components/omnibox/browser/autocomplete_input.h" |
10 #include "components/omnibox/browser/autocomplete_provider_client.h" | 10 #include "components/omnibox/browser/autocomplete_provider_client.h" |
11 #include "components/omnibox/browser/history_url_provider.h" | 11 #include "components/omnibox/browser/history_url_provider.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 AutocompleteMatch VerbatimMatchForURL( | 14 AutocompleteMatch VerbatimMatchForURL( |
15 AutocompleteProviderClient* client, | 15 AutocompleteProviderClient* client, |
16 const AutocompleteInput& input, | 16 const AutocompleteInput& input, |
17 const GURL& destination_url, | 17 const GURL& destination_url, |
| 18 const base::string16& destination_description, |
18 HistoryURLProvider* history_url_provider, | 19 HistoryURLProvider* history_url_provider, |
19 int verbatim_relevance) { | 20 int verbatim_relevance) { |
20 DCHECK(!input.text().empty()); | 21 DCHECK(!input.text().empty()); |
21 AutocompleteMatch match; | 22 AutocompleteMatch match; |
22 // If the caller already knows where the verbatim match should go and has | 23 // If the caller already knows where the verbatim match should go and has |
23 // provided a HistoryURLProvider to aid in its construction, construct the | 24 // provided a HistoryURLProvider to aid in its construction, construct the |
24 // match directly, don't call Classify() on the input. Classify() runs all | 25 // match directly, don't call Classify() on the input. Classify() runs all |
25 // providers' synchronous passes. Some providers such as HistoryQuick can | 26 // providers' synchronous passes. Some providers such as HistoryQuick can |
26 // have a slow synchronous pass on some inputs. | 27 // have a slow synchronous pass on some inputs. |
27 if (history_url_provider && destination_url.is_valid()) { | 28 if (history_url_provider && destination_url.is_valid()) { |
28 match = history_url_provider->SuggestExactInput( | 29 match = history_url_provider->SuggestExactInput( |
29 input, | 30 input, |
30 destination_url, | 31 destination_url, |
31 !AutocompleteInput::HasHTTPScheme(input.text())); | 32 !AutocompleteInput::HasHTTPScheme(input.text())); |
| 33 match.description = destination_description; |
| 34 AutocompleteMatch::ClassifyLocationInString( |
| 35 base::string16::npos, 0, match.description.length(), |
| 36 ACMatchClassification::NONE, &match.description_class); |
32 } else { | 37 } else { |
33 client->Classify(input.text(), false, true, | 38 client->Classify(input.text(), false, true, |
34 input.current_page_classification(), &match, nullptr); | 39 input.current_page_classification(), &match, nullptr); |
35 } | 40 } |
36 match.allowed_to_be_default_match = true; | 41 match.allowed_to_be_default_match = true; |
37 // The default relevance to use for relevance match. Should be greater than | 42 // The default relevance to use for relevance match. Should be greater than |
38 // all relevance matches returned by the ZeroSuggest server. | 43 // all relevance matches returned by the ZeroSuggest server. |
39 const int kDefaultVerbatimRelevance = 1300; | 44 const int kDefaultVerbatimRelevance = 1300; |
40 match.relevance = | 45 match.relevance = |
41 verbatim_relevance >= 0 ? verbatim_relevance : kDefaultVerbatimRelevance; | 46 verbatim_relevance >= 0 ? verbatim_relevance : kDefaultVerbatimRelevance; |
42 return match; | 47 return match; |
43 } | 48 } |
OLD | NEW |