Index: components/previews/core/previews_black_list.cc |
diff --git a/components/previews/core/previews_black_list.cc b/components/previews/core/previews_black_list.cc |
index fa5d1262f1eaa03ba1770685997668769fceecc2..ea5de7d822f6ebb8cf9d5504a500ad896895303a 100644 |
--- a/components/previews/core/previews_black_list.cc |
+++ b/components/previews/core/previews_black_list.cc |
@@ -6,6 +6,7 @@ |
#include "base/bind.h" |
#include "base/memory/ptr_util.h" |
+#include "base/metrics/histogram_macros.h" |
#include "base/optional.h" |
#include "base/time/clock.h" |
#include "components/previews/core/previews_black_list_item.h" |
@@ -73,6 +74,13 @@ void PreviewsBlackList::AddPreviewNavigation(const GURL& url, |
PreviewsType type) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
DCHECK(url.has_host()); |
+ switch (type) { |
+ case PreviewsType::OFFLINE: |
+ UMA_HISTOGRAM_BOOLEAN("Previews.OptOut.UserOptedOut.Offline", opt_out); |
+ break; |
+ default: |
+ NOTREACHED(); |
+ } |
if (opt_out) { |
last_opt_out_time_ = clock_->Now(); |
} |
@@ -108,23 +116,26 @@ void PreviewsBlackList::AddPreviewNavigationSync(const GURL& url, |
opt_out_store_->AddPreviewNavigation(opt_out, host_name, type, now); |
} |
-bool PreviewsBlackList::IsLoadedAndAllowed(const GURL& url, |
- PreviewsType type) const { |
+PreviewsEligibilityReason PreviewsBlackList::IsLoadedAndAllowed( |
+ const GURL& url, |
+ PreviewsType type) const { |
DCHECK(thread_checker_.CalledOnValidThread()); |
DCHECK(url.has_host()); |
if (!loaded_) |
- return false; |
+ return PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED; |
DCHECK(black_list_item_map_); |
if (last_opt_out_time_ && |
clock_->Now() < |
last_opt_out_time_.value() + params::SingleOptOutDuration()) { |
- return false; |
+ return PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT; |
} |
if (host_indifferent_black_list_item_->IsBlackListed(clock_->Now())) |
- return false; |
+ return PreviewsEligibilityReason::USER_BLACKLISTED; |
PreviewsBlackListItem* black_list_item = |
GetBlackListItemFromMap(*black_list_item_map_, url.host()); |
- return !black_list_item || !black_list_item->IsBlackListed(clock_->Now()); |
+ if (black_list_item && black_list_item->IsBlackListed(clock_->Now())) |
+ return PreviewsEligibilityReason::HOST_BLACKLISTED; |
+ return PreviewsEligibilityReason::ALLOWED; |
} |
void PreviewsBlackList::ClearBlackList(base::Time begin_time, |