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/clipboard_url_provider.h" | 5 #include "components/omnibox/browser/clipboard_url_provider.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.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" |
(...skipping 30 matching lines...) Expand all Loading... |
41 AutocompleteMatch verbatim_match = VerbatimMatchForURL( | 41 AutocompleteMatch verbatim_match = VerbatimMatchForURL( |
42 client_, input.text(), input.current_page_classification(), -1); | 42 client_, input.text(), input.current_page_classification(), -1); |
43 if (verbatim_match.destination_url.is_valid()) | 43 if (verbatim_match.destination_url.is_valid()) |
44 matches_.push_back(verbatim_match); | 44 matches_.push_back(verbatim_match); |
45 | 45 |
46 // Add a clipboard match just below the verbatim match. | 46 // Add a clipboard match just below the verbatim match. |
47 AutocompleteMatch match(this, verbatim_match.relevance - 1, false, | 47 AutocompleteMatch match(this, verbatim_match.relevance - 1, false, |
48 AutocompleteMatchType::CLIPBOARD); | 48 AutocompleteMatchType::CLIPBOARD); |
49 match.destination_url = url; | 49 match.destination_url = url; |
50 match.contents.assign(url_formatter::FormatUrl( | 50 match.contents.assign(url_formatter::FormatUrl( |
51 url, client_->GetAcceptLanguages(), url_formatter::kFormatUrlOmitAll, | 51 url, url_formatter::kFormatUrlOmitAll, net::UnescapeRule::SPACES, |
52 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); | 52 nullptr, nullptr, nullptr)); |
53 AutocompleteMatch::ClassifyLocationInString( | 53 AutocompleteMatch::ClassifyLocationInString( |
54 base::string16::npos, 0, match.contents.length(), | 54 base::string16::npos, 0, match.contents.length(), |
55 ACMatchClassification::URL, &match.contents_class); | 55 ACMatchClassification::URL, &match.contents_class); |
56 | 56 |
57 match.description.assign(l10n_util::GetStringUTF16(IDS_LINK_FROM_CLIPBOARD)); | 57 match.description.assign(l10n_util::GetStringUTF16(IDS_LINK_FROM_CLIPBOARD)); |
58 AutocompleteMatch::ClassifyLocationInString( | 58 AutocompleteMatch::ClassifyLocationInString( |
59 base::string16::npos, 0, match.description.length(), | 59 base::string16::npos, 0, match.description.length(), |
60 ACMatchClassification::NONE, &match.description_class); | 60 ACMatchClassification::NONE, &match.description_class); |
61 | 61 |
62 // At least one match must be default, so if verbatim_match was invalid, | 62 // At least one match must be default, so if verbatim_match was invalid, |
63 // the clipboard match is allowed to be default. | 63 // the clipboard match is allowed to be default. |
64 match.allowed_to_be_default_match = matches_.empty(); | 64 match.allowed_to_be_default_match = matches_.empty(); |
65 matches_.push_back(match); | 65 matches_.push_back(match); |
66 } | 66 } |
OLD | NEW |