| 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 896507deee1e3391ed33a620df2b9e2777e7eba6..37a0af6d3dac7759ed94b2fa1bf31897ef77982f 100644
|
| --- a/components/previews/core/previews_black_list.cc
|
| +++ b/components/previews/core/previews_black_list.cc
|
| @@ -55,20 +55,23 @@ PreviewsBlackList::PreviewsBlackList(
|
| }
|
| }
|
|
|
| PreviewsBlackList::~PreviewsBlackList() {}
|
|
|
| void PreviewsBlackList::AddPreviewNavigation(const GURL& url,
|
| bool opt_out,
|
| PreviewsType type) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| DCHECK(url.has_host());
|
| + if (opt_out) {
|
| + last_opt_out_time_ = clock_->Now();
|
| + }
|
| // If the |black_list_item_map_| has been loaded from |opt_out_store_|,
|
| // synchronous operations will be accurate. Otherwise, queue the task to run
|
| // asynchronously.
|
| if (loaded_) {
|
| AddPreviewNavigationSync(url, opt_out, type);
|
| } else {
|
| QueuePendingTask(base::Bind(&PreviewsBlackList::AddPreviewNavigationSync,
|
| base::Unretained(this), url, opt_out, type));
|
| }
|
| }
|
| @@ -90,20 +93,25 @@ void PreviewsBlackList::AddPreviewNavigationSync(const GURL& url,
|
| return;
|
| opt_out_store_->AddPreviewNavigation(opt_out, host_name, type, now);
|
| }
|
|
|
| bool PreviewsBlackList::IsLoadedAndAllowed(const GURL& url,
|
| PreviewsType type) const {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| DCHECK(url.has_host());
|
| if (!loaded_)
|
| return false;
|
| + if (last_opt_out_time_ &&
|
| + clock_->Now() <
|
| + last_opt_out_time_.value() + params::SingleOptOutBlackOutDuration()) {
|
| + return false;
|
| + }
|
| PreviewsBlackListItem* black_list_item =
|
| GetBlackListItem(*black_list_item_map_, url.host());
|
| return !black_list_item || !black_list_item->IsBlackListed(clock_->Now());
|
| }
|
|
|
| void PreviewsBlackList::ClearBlackList(base::Time begin_time,
|
| base::Time end_time) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| DCHECK_LE(begin_time, end_time);
|
| // If the |black_list_item_map_| has been loaded from |opt_out_store_|,
|
|
|