Chromium Code Reviews| 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..4140fcd6a4db7bcabc2d0240bcf7618203adadef 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.h" |
|
tbansal1
2016/11/09 17:50:51
include base/metrics/histogram_macros.h instead of
RyanSturm
2016/11/09 18:48:29
Done.
|
| #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); |
|
tbansal1
2016/11/09 17:50:51
May be add a test for this?
RyanSturm
2016/11/09 18:48:29
Done.
|
| + 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, |