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

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

Issue 2749693003: Reland of Moving previews code from components/ to chrome/ (Closed)
Patch Set: fixed vector copy Created 3 years, 9 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
« no previous file with comments | « components/previews/core/previews_io_data.h ('k') | components/previews/core/previews_io_data_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/previews/core/previews_io_data.cc
diff --git a/components/previews/core/previews_io_data.cc b/components/previews/core/previews_io_data.cc
index 0a7af37fda2653d9ddf580fe6411677afb1a1d84..9645fa249513ccc186559024eee32088444a2ec5 100644
--- a/components/previews/core/previews_io_data.cc
+++ b/components/previews/core/previews_io_data.cc
@@ -51,8 +51,10 @@ PreviewsIOData::~PreviewsIOData() {}
void PreviewsIOData::Initialize(
base::WeakPtr<PreviewsUIService> previews_ui_service,
- std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store) {
+ std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store,
+ const PreviewsIsEnabledCallback& is_enabled_callback) {
DCHECK(ui_task_runner_->BelongsToCurrentThread());
+ is_enabled_callback_ = is_enabled_callback;
previews_ui_service_ = previews_ui_service;
// Set up the IO thread portion of |this|.
@@ -88,15 +90,16 @@ void PreviewsIOData::ClearBlackList(base::Time begin_time,
bool PreviewsIOData::ShouldAllowPreview(const net::URLRequest& request,
PreviewsType type) const {
- if (!IsPreviewsTypeEnabled(type))
- return false;
- // The blacklist will disallow certain hosts for periods of time based on
- // user's opting out of the preview
- if (!previews_black_list_) {
+ if (is_enabled_callback_.is_null() || !previews_black_list_) {
LogPreviewsEligibilityReason(
PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE, type);
return false;
}
+ if (!is_enabled_callback_.Run(type))
+ return false;
+
+ // The blacklist will disallow certain hosts for periods of time based on
+ // user's opting out of the preview
PreviewsEligibilityReason status =
previews_black_list_->IsLoadedAndAllowed(request.url(), type);
if (status != PreviewsEligibilityReason::ALLOWED) {
« no previous file with comments | « components/previews/core/previews_io_data.h ('k') | components/previews/core/previews_io_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698