Commit 2fd18739 authored by treib's avatar treib Committed by Commit bot

Supervised user blacklist: Don't download the blacklist file on every startup

BUG=410824

Review URL: https://codereview.chromium.org/1086393002

Cr-Commit-Position: refs/heads/master@{#325462}
parent a5d00767
......@@ -6,10 +6,12 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_runner_util.h"
#include "base/version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/component_updater/supervised_user_whitelist_installer.h"
......@@ -620,8 +622,18 @@ void SupervisedUserService::OnSiteListUpdated() {
void SupervisedUserService::LoadBlacklist(const base::FilePath& path,
const GURL& url) {
// TODO(treib): Don't re-download the blacklist if the local file exists!
if (!url.is_valid()) {
base::PostTaskAndReplyWithResult(
BrowserThread::GetBlockingPool(),
FROM_HERE,
base::Bind(&base::PathExists, path),
base::Bind(&SupervisedUserService::OnBlacklistFileChecked,
weak_ptr_factory_.GetWeakPtr(), path, url));
}
void SupervisedUserService::OnBlacklistFileChecked(const base::FilePath& path,
const GURL& url,
bool file_exists) {
if (file_exists) {
LoadBlacklistFromFile(path);
return;
}
......
......@@ -281,13 +281,17 @@ class SupervisedUserService : public KeyedService,
void OnSiteListsChanged(
const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists);
// Asynchronously downloads a static blacklist file from |url|, stores it at
// |path|, loads it, and applies it to the URL filters. If |url| is not valid
// (e.g. empty), directly tries to load from |path|.
// Asynchronously loads a blacklist from a binary file at |path| and applies
// it to the URL filters. If no file exists at |path| yet, downloads a file
// from |url| and stores it at |path| first.
void LoadBlacklist(const base::FilePath& path, const GURL& url);
// Asynchronously loads a static blacklist from a binary file at |path| and
// applies it to the URL filters.
void OnBlacklistFileChecked(const base::FilePath& path,
const GURL& url,
bool file_exists);
// Asynchronously loads a blacklist from a binary file at |path| and applies
// it to the URL filters.
void LoadBlacklistFromFile(const base::FilePath& path);
void OnBlacklistDownloadDone(const base::FilePath& path, bool success);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment