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

Side by Side Diff: components/omnibox/browser/clipboard_url_provider.cc

Issue 2963883002: Omnibox UI Experiments: Refactor HTTPS trimming into UrlFormatter. (Closed)
Patch Set: fix Created 3 years, 5 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
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/omnibox/browser/clipboard_url_provider.h" 5 #include "components/omnibox/browser/clipboard_url_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 current_url_suggested_ = url; 79 current_url_suggested_ = url;
80 current_url_suggested_times_ = 1; 80 current_url_suggested_times_ = 1;
81 } 81 }
82 UMA_HISTOGRAM_SPARSE_SLOWLY( 82 UMA_HISTOGRAM_SPARSE_SLOWLY(
83 "Omnibox.ClipboardSuggestionShownNumTimes", 83 "Omnibox.ClipboardSuggestionShownNumTimes",
84 std::min(current_url_suggested_times_, static_cast<size_t>(20))); 84 std::min(current_url_suggested_times_, static_cast<size_t>(20)));
85 85
86 // Add the clipboard match. The relevance is 800 to beat ZeroSuggest results. 86 // Add the clipboard match. The relevance is 800 to beat ZeroSuggest results.
87 AutocompleteMatch match(this, 800, false, AutocompleteMatchType::CLIPBOARD); 87 AutocompleteMatch match(this, 800, false, AutocompleteMatchType::CLIPBOARD);
88 match.destination_url = url; 88 match.destination_url = url;
89 match.contents.assign(AutocompleteMatch::FormatUrlForSuggestionDisplay( 89 auto format_types = AutocompleteMatch::GetFormatTypes(true);
90 url, true /* trim_scheme */, nullptr)); 90 match.contents.assign(url_formatter::FormatUrl(
91 url, format_types, net::UnescapeRule::SPACES, nullptr, nullptr, nullptr));
91 AutocompleteMatch::ClassifyLocationInString( 92 AutocompleteMatch::ClassifyLocationInString(
92 base::string16::npos, 0, match.contents.length(), 93 base::string16::npos, 0, match.contents.length(),
93 ACMatchClassification::URL, &match.contents_class); 94 ACMatchClassification::URL, &match.contents_class);
94 95
95 match.description.assign(l10n_util::GetStringUTF16(IDS_LINK_FROM_CLIPBOARD)); 96 match.description.assign(l10n_util::GetStringUTF16(IDS_LINK_FROM_CLIPBOARD));
96 AutocompleteMatch::ClassifyLocationInString( 97 AutocompleteMatch::ClassifyLocationInString(
97 base::string16::npos, 0, match.description.length(), 98 base::string16::npos, 0, match.description.length(),
98 ACMatchClassification::NONE, &match.description_class); 99 ACMatchClassification::NONE, &match.description_class);
99 100
100 matches_.push_back(match); 101 matches_.push_back(match);
101 } 102 }
102 103
103 void ClipboardURLProvider::AddProviderInfo(ProvidersInfo* provider_info) const { 104 void ClipboardURLProvider::AddProviderInfo(ProvidersInfo* provider_info) const {
104 // If a URL wasn't suggested on this most recent focus event, don't bother 105 // If a URL wasn't suggested on this most recent focus event, don't bother
105 // setting |times_returned_results_in_session|, as in effect this URL has 106 // setting |times_returned_results_in_session|, as in effect this URL has
106 // never been suggested during the current session. (For the purpose of 107 // never been suggested during the current session. (For the purpose of
107 // this provider, we define a session as intervals between when a URL 108 // this provider, we define a session as intervals between when a URL
108 // clipboard suggestion changes.) 109 // clipboard suggestion changes.)
109 if (current_url_suggested_times_ == 0) 110 if (current_url_suggested_times_ == 0)
110 return; 111 return;
111 provider_info->push_back(metrics::OmniboxEventProto_ProviderInfo()); 112 provider_info->push_back(metrics::OmniboxEventProto_ProviderInfo());
112 metrics::OmniboxEventProto_ProviderInfo& new_entry = provider_info->back(); 113 metrics::OmniboxEventProto_ProviderInfo& new_entry = provider_info->back();
113 new_entry.set_provider(AsOmniboxEventProviderType()); 114 new_entry.set_provider(AsOmniboxEventProviderType());
114 new_entry.set_times_returned_results_in_session(current_url_suggested_times_); 115 new_entry.set_times_returned_results_in_session(current_url_suggested_times_);
115 } 116 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/autocomplete_match_unittest.cc ('k') | components/omnibox/browser/history_quick_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698