Index: components/omnibox/browser/clipboard_url_provider.cc |
diff --git a/components/omnibox/browser/clipboard_url_provider.cc b/components/omnibox/browser/clipboard_url_provider.cc |
index e4459e75747fc562b4693b6c554cdd8db61498bd..395ef991a7d8c508f868bd82785bdf8e505a7a87 100644 |
--- a/components/omnibox/browser/clipboard_url_provider.cc |
+++ b/components/omnibox/browser/clipboard_url_provider.cc |
@@ -30,23 +30,32 @@ ClipboardURLProvider::~ClipboardURLProvider() {} |
void ClipboardURLProvider::Start(const AutocompleteInput& input, |
bool minimal_changes) { |
matches_.clear(); |
+ |
+ // If the user started typing, do not offer clipboard based match. |
if (!input.from_omnibox_focus()) |
return; |
GURL url; |
+ // If the clipboard does not contain any URL, or the URL on the page is the |
+ // same as the URL in the clipboard, early return. |
if (!clipboard_content_->GetRecentURLFromClipboard(&url) || |
url == input.current_url()) |
return; |
DCHECK(url.is_valid()); |
- // Adds a default match. This match will be opened when the user presses "Go". |
- AutocompleteMatch verbatim_match = VerbatimMatchForURL( |
- client_, input, input.current_url(), history_url_provider_, -1); |
- if (verbatim_match.destination_url.is_valid()) |
- matches_.push_back(verbatim_match); |
+ // If the omnibox is not empty, adds a default match. |
sdefresne
2016/07/05 10:08:56
nit: I would use if (!input.text().empty())
Mark P
2016/07/06 18:56:47
nit: adds -> add
jif
2016/07/11 15:09:36
Done.
jif
2016/07/11 15:09:36
Done.
|
+ // This match will be opened when the user presses "Enter". |
+ if (input.text().length()) { |
+ AutocompleteMatch verbatim_match = VerbatimMatchForURL( |
+ client_, input, input.current_url(), history_url_provider_, -1); |
+ if (verbatim_match.destination_url.is_valid()) |
Mark P
2016/07/06 18:56:47
This if test shouldn't be necessary anymore. (It
jif
2016/07/11 15:09:36
Good catch. Done.
|
+ matches_.push_back(verbatim_match); |
+ } |
- // Add a clipboard match just below the verbatim match. |
- AutocompleteMatch match(this, verbatim_match.relevance - 1, false, |
+ // Add the clipboard match. The relevance can be '1' because there can only be |
Mark P
2016/07/06 18:56:47
side comment: once iOS enables ZeroSuggest to most
jif
2016/07/11 15:09:36
Done.
|
+ // 0 or 1 match before: more matches will appear once the user starts typing, |
+ // but when the user starts typing the clipboard based match stops showing up. |
+ AutocompleteMatch match(this, 1, false, |
AutocompleteMatchType::CLIPBOARD); |
match.destination_url = url; |
match.contents.assign(url_formatter::FormatUrl( |