Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: components/open_from_clipboard/clipboard_url_provider.cc

Issue 1072003002: Early return the Clipboard Url Provider when the omnibox wasn't focused. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/open_from_clipboard/clipboard_url_provider.h" 5 #include "components/open_from_clipboard/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/autocomplete_input.h" 9 #include "components/omnibox/autocomplete_input.h"
10 #include "components/open_from_clipboard/clipboard_recent_content.h" 10 #include "components/open_from_clipboard/clipboard_recent_content.h"
(...skipping 13 matching lines...) Expand all
24 DCHECK(clipboard_recent_content_); 24 DCHECK(clipboard_recent_content_);
25 } 25 }
26 26
27 ClipboardURLProvider::~ClipboardURLProvider() { 27 ClipboardURLProvider::~ClipboardURLProvider() {
28 } 28 }
29 29
30 void ClipboardURLProvider::Start(const AutocompleteInput& input, 30 void ClipboardURLProvider::Start(const AutocompleteInput& input,
31 bool minimal_changes, 31 bool minimal_changes,
32 bool called_due_to_focus) { 32 bool called_due_to_focus) {
33 matches_.clear(); 33 matches_.clear();
34 if (!called_due_to_focus)
35 return;
34 // Attempt to add an AutocompleteMatch only if the user has not entered 36 // Attempt to add an AutocompleteMatch only if the user has not entered
35 // anything in the omnibox. 37 // anything in the omnibox.
36 if (input.cursor_position() == base::string16::npos) { 38 if (input.cursor_position() == base::string16::npos) {
37 GURL url; 39 GURL url;
38 if (clipboard_recent_content_->GetRecentURLFromClipboard(&url)) { 40 if (clipboard_recent_content_->GetRecentURLFromClipboard(&url)) {
39 DCHECK(url.is_valid()); 41 DCHECK(url.is_valid());
40 AutocompleteMatch match(this, kClipboardURLProviderRelevance, false, 42 AutocompleteMatch match(this, kClipboardURLProviderRelevance, false,
41 AutocompleteMatchType::NAVSUGGEST_PERSONALIZED); 43 AutocompleteMatchType::NAVSUGGEST_PERSONALIZED);
42 match.allowed_to_be_default_match = true; 44 match.allowed_to_be_default_match = true;
43 match.destination_url = url; 45 match.destination_url = url;
44 match.contents.assign(base::UTF8ToUTF16(url.spec())); 46 match.contents.assign(base::UTF8ToUTF16(url.spec()));
45 AutocompleteMatch::ClassifyLocationInString( 47 AutocompleteMatch::ClassifyLocationInString(
46 base::string16::npos, 0, match.contents.length(), 48 base::string16::npos, 0, match.contents.length(),
47 ACMatchClassification::URL, &match.contents_class); 49 ACMatchClassification::URL, &match.contents_class);
48 50
49 match.description.assign( 51 match.description.assign(
50 l10n_util::GetStringUTF16(IDS_LINK_FROM_CLIPBOARD)); 52 l10n_util::GetStringUTF16(IDS_LINK_FROM_CLIPBOARD));
51 AutocompleteMatch::ClassifyLocationInString( 53 AutocompleteMatch::ClassifyLocationInString(
52 base::string16::npos, 0, match.description.length(), 54 base::string16::npos, 0, match.description.length(),
53 ACMatchClassification::URL, &match.description_class); 55 ACMatchClassification::URL, &match.description_class);
54 56
55 matches_.push_back(match); 57 matches_.push_back(match);
56 } 58 }
57 } 59 }
58 done_ = true; 60 done_ = true;
59 } 61 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698