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