Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: components/previews/core/previews_black_list.cc

Issue 2439203002: Adding a short blacklist period after every previews opt out (Closed)
Patch Set: tbansal comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_|,

Powered by Google App Engine
This is Rietveld 408576698