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 896507deee1e3391ed33a620df2b9e2777e7eba6..ee4877040b1d81a76b2bbf241346a53c188eee48 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, |
|
tbansal1
2016/10/25 00:47:41
At some point in future, it might be useful for th
RyanSturm
2016/10/25 17:15:38
Agreed. Seperate CL when someone wants it. We'd ne
|
| 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::SingleOptOutDuration()) { |
| + 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_|, |