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

Unified Diff: components/precache/content/precache_manager.cc

Issue 1176253002: Fix IsPrecachingAllowed() to check Sync instead of Data Saver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change IsSyncEnabledAndLoggedIn to CanSyncStart. Created 5 years, 6 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/precache/content/precache_manager.cc
diff --git a/components/precache/content/precache_manager.cc b/components/precache/content/precache_manager.cc
index c8fc3dbe469b91356d7184da1d363045f4533f8a..08e05620634d24a5c34bf5d21968c56affa58d56 100644
--- a/components/precache/content/precache_manager.cc
+++ b/components/precache/content/precache_manager.cc
@@ -15,10 +15,10 @@
#include "base/metrics/field_trial.h"
#include "base/prefs/pref_service.h"
#include "base/time/time.h"
-#include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
#include "components/history/core/browser/history_service.h"
#include "components/precache/core/precache_database.h"
#include "components/precache/core/precache_switches.h"
+#include "components/sync_driver/sync_service.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -40,8 +40,10 @@ int NumTopHosts() {
return kNumTopHosts;
}
-PrecacheManager::PrecacheManager(content::BrowserContext* browser_context)
+PrecacheManager::PrecacheManager(content::BrowserContext* browser_context,
+ sync_driver::SyncService* sync_service)
: browser_context_(browser_context),
+ sync_service_(sync_service),
precache_database_(new PrecacheDatabase()),
is_precaching_(false) {
base::FilePath db_path(browser_context_->GetPath().Append(
@@ -64,9 +66,10 @@ bool PrecacheManager::IsPrecachingEnabled() {
}
bool PrecacheManager::IsPrecachingAllowed() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- return user_prefs::UserPrefs::Get(browser_context_)->GetBoolean(
- data_reduction_proxy::prefs::kDataReductionProxyEnabled);
+ return sync_service_ && sync_service_->CanSyncStart() &&
+ sync_service_->HasSyncSetupCompleted() &&
+ sync_service_->GetPreferredDataTypes().Has(syncer::SESSIONS) &&
+ !sync_service_->GetEncryptedDataTypes().Has(syncer::SESSIONS);
}
void PrecacheManager::StartPrecaching(

Powered by Google App Engine
This is Rietveld 408576698