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

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

Issue 2963883002: Omnibox UI Experiments: Refactor HTTPS trimming into UrlFormatter. (Closed)
Patch Set: update comment 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 =
90 url, true /* trim_scheme */, nullptr)); 90 AutocompleteMatch::GetFormatForSuggestionDisplay(true /* trim_scheme*/);
91 match.contents.assign(url_formatter::FormatUrl(
92 url, format_types, net::UnescapeRule::SPACES, nullptr, nullptr, nullptr));
91 AutocompleteMatch::ClassifyLocationInString( 93 AutocompleteMatch::ClassifyLocationInString(
92 base::string16::npos, 0, match.contents.length(), 94 base::string16::npos, 0, match.contents.length(),
93 ACMatchClassification::URL, &match.contents_class); 95 ACMatchClassification::URL, &match.contents_class);
94 96
95 match.description.assign(l10n_util::GetStringUTF16(IDS_LINK_FROM_CLIPBOARD)); 97 match.description.assign(l10n_util::GetStringUTF16(IDS_LINK_FROM_CLIPBOARD));
96 AutocompleteMatch::ClassifyLocationInString( 98 AutocompleteMatch::ClassifyLocationInString(
97 base::string16::npos, 0, match.description.length(), 99 base::string16::npos, 0, match.description.length(),
98 ACMatchClassification::NONE, &match.description_class); 100 ACMatchClassification::NONE, &match.description_class);
99 101
100 matches_.push_back(match); 102 matches_.push_back(match);
101 } 103 }
102 104
103 void ClipboardURLProvider::AddProviderInfo(ProvidersInfo* provider_info) const { 105 void ClipboardURLProvider::AddProviderInfo(ProvidersInfo* provider_info) const {
104 // If a URL wasn't suggested on this most recent focus event, don't bother 106 // 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 107 // setting |times_returned_results_in_session|, as in effect this URL has
106 // never been suggested during the current session. (For the purpose of 108 // never been suggested during the current session. (For the purpose of
107 // this provider, we define a session as intervals between when a URL 109 // this provider, we define a session as intervals between when a URL
108 // clipboard suggestion changes.) 110 // clipboard suggestion changes.)
109 if (current_url_suggested_times_ == 0) 111 if (current_url_suggested_times_ == 0)
110 return; 112 return;
111 provider_info->push_back(metrics::OmniboxEventProto_ProviderInfo()); 113 provider_info->push_back(metrics::OmniboxEventProto_ProviderInfo());
112 metrics::OmniboxEventProto_ProviderInfo& new_entry = provider_info->back(); 114 metrics::OmniboxEventProto_ProviderInfo& new_entry = provider_info->back();
113 new_entry.set_provider(AsOmniboxEventProviderType()); 115 new_entry.set_provider(AsOmniboxEventProviderType());
114 new_entry.set_times_returned_results_in_session(current_url_suggested_times_); 116 new_entry.set_times_returned_results_in_session(current_url_suggested_times_);
115 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698