| 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 3fe1074966161124158d27f699cfd3e4a9a5e553..f2f12d3d4b5c62e35d4c2bd73773af925b2fd9ab 100644
|
| --- a/components/omnibox/browser/clipboard_url_provider.cc
|
| +++ b/components/omnibox/browser/clipboard_url_provider.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "components/omnibox/browser/clipboard_url_provider.h"
|
|
|
| +#include <algorithm>
|
| +
|
| #include "base/feature_list.h"
|
| #include "base/logging.h"
|
| #include "base/metrics/histogram_macros.h"
|
| @@ -24,7 +26,8 @@ ClipboardURLProvider::ClipboardURLProvider(
|
| : AutocompleteProvider(AutocompleteProvider::TYPE_CLIPBOARD_URL),
|
| client_(client),
|
| clipboard_content_(clipboard_content),
|
| - history_url_provider_(history_url_provider) {
|
| + history_url_provider_(history_url_provider),
|
| + current_url_suggested_times_(0) {
|
| DCHECK(clipboard_content_);
|
| }
|
|
|
| @@ -39,10 +42,15 @@ void ClipboardURLProvider::Start(const AutocompleteInput& input,
|
| 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())
|
| + // The clipboard does not contain a URL worth suggesting.
|
| + if (!clipboard_content_->GetRecentURLFromClipboard(&url)) {
|
| + current_url_suggested_ = GURL();
|
| + current_url_suggested_times_ = 0;
|
| + return;
|
| + }
|
| + // The URL on the page is the same as the URL in the clipboard. Don't
|
| + // bother suggesting it.
|
| + if (url == input.current_url())
|
| return;
|
|
|
| DCHECK(url.is_valid());
|
| @@ -62,6 +70,18 @@ void ClipboardURLProvider::Start(const AutocompleteInput& input,
|
| !matches_.empty());
|
| UMA_HISTOGRAM_LONG_TIMES_100("Omnibox.ClipboardSuggestionShownAge",
|
| clipboard_content_->GetClipboardContentAge());
|
| + // Record the number of times the currently-offered URL has been suggested.
|
| + // This only works over this run of Chrome; if the URL was in the clipboard
|
| + // on a previous run, those offerings will not be counted.
|
| + if (url == current_url_suggested_) {
|
| + current_url_suggested_times_++;
|
| + } else {
|
| + current_url_suggested_ = url;
|
| + current_url_suggested_times_ = 1;
|
| + }
|
| + UMA_HISTOGRAM_SPARSE_SLOWLY(
|
| + "Omnibox.ClipboardSuggestionShownNumTimes",
|
| + std::min(current_url_suggested_times_, static_cast<size_t>(20)));
|
|
|
| // Add the clipboard match. The relevance is 800 to beat ZeroSuggest results.
|
| AutocompleteMatch match(this, 800, false, AutocompleteMatchType::CLIPBOARD);
|
| @@ -80,3 +100,17 @@ void ClipboardURLProvider::Start(const AutocompleteInput& input,
|
|
|
| matches_.push_back(match);
|
| }
|
| +
|
| +void ClipboardURLProvider::AddProviderInfo(ProvidersInfo* provider_info) const {
|
| + // If a URL wasn't suggested on this most recent focus event, don't bother
|
| + // setting |times_returned_results_in_session|, as in effect this URL has
|
| + // never been suggested during the current session. (For the purpose of
|
| + // this provider, we define a session as intervals between when a URL
|
| + // clipboard suggestion changes.)
|
| + if (current_url_suggested_times_ == 0)
|
| + return;
|
| + provider_info->push_back(metrics::OmniboxEventProto_ProviderInfo());
|
| + metrics::OmniboxEventProto_ProviderInfo& new_entry = provider_info->back();
|
| + new_entry.set_provider(AsOmniboxEventProviderType());
|
| + new_entry.set_times_returned_results_in_session(current_url_suggested_times_);
|
| +}
|
|
|