summaryrefslogtreecommitdiffstats
path: root/chrome/browser/privacy_blacklist
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 09:21:50 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 09:21:50 +0000
commit8c6335d3d176a06d41252fd4a4c5335fa2113aa6 (patch)
treea10ff8fc3f25db04c9426c009feb8c92790e6c06 /chrome/browser/privacy_blacklist
parent1e52ae9f050e47ec670e0b3ad931652709a59ae7 (diff)
downloadchromium_src-8c6335d3d176a06d41252fd4a4c5335fa2113aa6.zip
chromium_src-8c6335d3d176a06d41252fd4a4c5335fa2113aa6.tar.gz
chromium_src-8c6335d3d176a06d41252fd4a4c5335fa2113aa6.tar.bz2
Drop the code allowing privacy blacklists to be shipped in extensions.
The plan is to implement it in a different way. TEST=Covered by unit_tests. BUG=21541 Review URL: http://codereview.chromium.org/552025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36626 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/privacy_blacklist')
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_interceptor.cc9
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_interceptor_unittest.cc41
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_listener.cc92
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_listener.h68
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_listener_unittest.cc183
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_manager.cc234
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_manager.h107
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_manager_browsertest.cc84
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_manager_unittest.cc199
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_request_info.cc6
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_request_info.h10
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_test_util.cc76
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_test_util.h64
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_ui.cc5
14 files changed, 20 insertions, 1158 deletions
diff --git a/chrome/browser/privacy_blacklist/blacklist_interceptor.cc b/chrome/browser/privacy_blacklist/blacklist_interceptor.cc
index 2a571e9..b187141 100644
--- a/chrome/browser/privacy_blacklist/blacklist_interceptor.cc
+++ b/chrome/browser/privacy_blacklist/blacklist_interceptor.cc
@@ -9,7 +9,6 @@
#include "base/string_util.h"
#include "base/values.h"
#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
#include "chrome/common/jstemplate_builder.h"
#include "net/url_request/url_request_simple_job.h"
@@ -78,9 +77,7 @@ class URLRequestBlacklistJob : public URLRequestSimpleJob {
const Blacklist::Provider* GetBestMatchingEntryProvider() const {
// If kBlockAll is specified, assign blame to such an entry.
// Otherwise pick the first one.
- const BlacklistManager* blacklist_manager =
- request_info_.GetBlacklistManager();
- const Blacklist* blacklist = blacklist_manager->GetCompiledBlacklist();
+ const Blacklist* blacklist = request_info_.GetBlacklist();
scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request_->url()));
const Blacklist::Entry* entry = NULL;
if (match->attributes() & Blacklist::kBlockAll) {
@@ -120,9 +117,7 @@ URLRequestJob* BlacklistInterceptor::MaybeIntercept(URLRequest* request) {
return NULL;
}
- const BlacklistManager* blacklist_manager =
- request_info->GetBlacklistManager();
- const Blacklist* blacklist = blacklist_manager->GetCompiledBlacklist();
+ const Blacklist* blacklist = request_info->GetBlacklist();
scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request->url()));
if (!match.get()) {
diff --git a/chrome/browser/privacy_blacklist/blacklist_interceptor_unittest.cc b/chrome/browser/privacy_blacklist/blacklist_interceptor_unittest.cc
index f1cadcf..35ec289 100644
--- a/chrome/browser/privacy_blacklist/blacklist_interceptor_unittest.cc
+++ b/chrome/browser/privacy_blacklist/blacklist_interceptor_unittest.cc
@@ -4,13 +4,8 @@
#include "app/l10n_util.h"
#include "base/message_loop.h"
-#include "base/path_service.h"
-#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/privacy_blacklist/blacklist_interceptor.h"
-#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
-#include "chrome/browser/privacy_blacklist/blacklist_test_util.h"
-#include "chrome/common/chrome_paths.h"
#include "grit/browser_resources.h"
#include "grit/generated_resources.h"
#include "net/base/io_buffer.h"
@@ -26,16 +21,7 @@ const char kBlockedUrl[] = "http://example.com/annoying_ads/ad.jpg";
class BlacklistInterceptorTest : public testing::Test {
public:
- BlacklistInterceptorTest()
- : loop_(MessageLoop::TYPE_IO),
- ui_thread_(ChromeThread::UI, &loop_),
- file_thread_(ChromeThread::FILE, &loop_),
- io_thread_(ChromeThread::IO, &loop_) {
- }
-
- virtual void SetUp() {
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_));
- test_data_dir_ = test_data_dir_.AppendASCII("blacklist_samples");
+ BlacklistInterceptorTest() : loop_(MessageLoop::TYPE_IO) {
}
protected:
@@ -55,18 +41,12 @@ class BlacklistInterceptorTest : public testing::Test {
BlacklistInterceptor interceptor_;
- FilePath test_data_dir_;
-
private:
bool ContainsResourceString(const std::string& text, int string_id) {
return text.find(l10n_util::GetStringUTF8(string_id)) != std::string::npos;
}
MessageLoop loop_;
-
- ChromeThread ui_thread_;
- ChromeThread file_thread_;
- ChromeThread io_thread_;
};
TEST_F(BlacklistInterceptorTest, Basic) {
@@ -74,20 +54,19 @@ TEST_F(BlacklistInterceptorTest, Basic) {
}
TEST_F(BlacklistInterceptorTest, Intercepted) {
- BlacklistTestingProfile profile;
- TestBlacklistPathProvider path_provider(&profile);
- path_provider.AddTransientPath(
- test_data_dir_.AppendASCII("annoying_ads.pbl"));
- scoped_refptr<BlacklistManager> blacklist_manager(
- new BlacklistManager(&profile, &path_provider));
- blacklist_manager->Initialize();
- MessageLoop::current()->RunAllPending();
-
EXPECT_FALSE(InterceptedTestRequest(kDataUrl, NULL));
+ Blacklist blacklist;
+ Blacklist::Provider* provider = new Blacklist::Provider();
+ blacklist.AddProvider(provider);
+ Blacklist::Entry* entry =
+ new Blacklist::Entry("@/annoying_ads/@", provider, false);
+ entry->AddAttributes(Blacklist::kBlockAll);
+ blacklist.AddEntry(entry);
+
BlacklistRequestInfo* request_info =
new BlacklistRequestInfo(GURL(kBlockedUrl), ResourceType::MAIN_FRAME,
- blacklist_manager.get());
+ &blacklist);
EXPECT_TRUE(InterceptedTestRequest(kBlockedUrl, request_info));
}
diff --git a/chrome/browser/privacy_blacklist/blacklist_listener.cc b/chrome/browser/privacy_blacklist/blacklist_listener.cc
deleted file mode 100644
index 5e00236..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_listener.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/privacy_blacklist/blacklist_listener.h"
-
-#include "chrome/browser/chrome_thread.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
-#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/renderer_host/global_request_id.h"
-#include "chrome/common/notification_service.h"
-#include "chrome/common/notification_type.h"
-#include "net/url_request/url_request.h"
-
-BlacklistListener::BlacklistListener(ResourceQueue* resource_queue)
- : resource_queue_(resource_queue) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
-
- registrar_.Add(this,
- NotificationType::BLACKLIST_MANAGER_ERROR,
- NotificationService::AllSources());
- registrar_.Add(this,
- NotificationType::BLACKLIST_MANAGER_BLACKLIST_READ_FINISHED,
- NotificationService::AllSources());
-}
-
-BlacklistListener::~BlacklistListener() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
-}
-
-void BlacklistListener::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
-
- switch (type.value) {
- // TODO(phajdan.jr): Do not resume requests silently after an error.
- case NotificationType::BLACKLIST_MANAGER_ERROR:
- case NotificationType::BLACKLIST_MANAGER_BLACKLIST_READ_FINISHED:
- {
- Profile* profile = Source<Profile>(source).ptr();
- ChromeThread::PostTask(ChromeThread::IO, FROM_HERE,
- NewRunnableMethod(this, &BlacklistListener::StartDelayedRequests,
- profile->GetBlacklistManager()));
- }
- break;
- default:
- NOTREACHED();
- }
-}
-
-bool BlacklistListener::ShouldDelayRequest(
- URLRequest* request,
- const ResourceDispatcherHostRequestInfo& request_info,
- const GlobalRequestID& request_id) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
-
- BlacklistRequestInfo* blacklist_request_info =
- BlacklistRequestInfo::FromURLRequest(request);
- const BlacklistManager* blacklist_manager =
- blacklist_request_info->GetBlacklistManager();
-
- if (blacklist_manager->GetCompiledBlacklist()) {
- // We have a blacklist ready. No need to delay the request.
- return false;
- }
-
- delayed_requests_[blacklist_manager].push_back(request_id);
- return true;
-}
-
-void BlacklistListener::WillShutdownResourceQueue() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- resource_queue_ = NULL;
-}
-
-void BlacklistListener::StartDelayedRequests(
- BlacklistManager* blacklist_manager) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
-
- if (resource_queue_) {
- const RequestList& requests = delayed_requests_[blacklist_manager];
- for (RequestList::const_iterator i = requests.begin();
- i != requests.end(); ++i) {
- resource_queue_->StartDelayedRequest(this, *i);
- }
- }
-
- delayed_requests_[blacklist_manager].clear();
-}
diff --git a/chrome/browser/privacy_blacklist/blacklist_listener.h b/chrome/browser/privacy_blacklist/blacklist_listener.h
deleted file mode 100644
index a74ed8e..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_listener.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_LISTENER_H_
-#define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_LISTENER_H_
-
-#include <map>
-#include <vector>
-
-#include "base/ref_counted.h"
-#include "chrome/browser/chrome_thread.h"
-#include "chrome/browser/renderer_host/resource_queue.h"
-#include "chrome/common/notification_observer.h"
-#include "chrome/common/notification_registrar.h"
-
-class BlacklistManager;
-
-// Delays requests until privacy blacklists are ready.
-class BlacklistListener
- : public ResourceQueueDelegate,
- public NotificationObserver,
- public base::RefCountedThreadSafe<BlacklistListener,
- ChromeThread::DeleteOnUIThread> {
- public:
- // UI THREAD ONLY ------------------------------------------------------------
-
- explicit BlacklistListener(ResourceQueue* resource_queue);
- virtual ~BlacklistListener();
-
- // NotificationObserver:
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- // IO THREAD ONLY ------------------------------------------------------------
-
- // ResourceQueueDelegate:
- virtual bool ShouldDelayRequest(
- URLRequest* request,
- const ResourceDispatcherHostRequestInfo& request_info,
- const GlobalRequestID& request_id);
- virtual void WillShutdownResourceQueue();
-
- private:
- friend class ChromeThread;
- friend class DeleteTask<BlacklistListener>;
-
- // Tell our resource queue to start the requests we requested to be delayed.
- void StartDelayedRequests(BlacklistManager* blacklist_manager);
-
- // Resource queue we're delegate of.
- ResourceQueue* resource_queue_;
-
- typedef std::vector<GlobalRequestID> RequestList;
- typedef std::map<const BlacklistManager*, RequestList> DelayedRequestMap;
-
- // Keep track of requests we have requested to delay so that we can resume
- // them as the blacklists load (note that we have a request list per blacklist
- // manager).
- DelayedRequestMap delayed_requests_;
-
- NotificationRegistrar registrar_;
-
- DISALLOW_COPY_AND_ASSIGN(BlacklistListener);
-};
-
-#endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_LISTENER_H_
diff --git a/chrome/browser/privacy_blacklist/blacklist_listener_unittest.cc b/chrome/browser/privacy_blacklist/blacklist_listener_unittest.cc
deleted file mode 100644
index 0625009..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_listener_unittest.cc
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/privacy_blacklist/blacklist_listener.h"
-
-#include "base/message_loop.h"
-#include "base/thread.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
-#include "chrome/browser/privacy_blacklist/blacklist_test_util.h"
-#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
-#include "chrome/browser/renderer_host/resource_handler.h"
-#include "chrome/browser/renderer_host/resource_queue.h"
-#include "chrome/common/notification_observer.h"
-#include "chrome/common/notification_registrar.h"
-#include "chrome/common/notification_source.h"
-#include "chrome/common/notification_type.h"
-#include "net/url_request/url_request_unittest.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-const char kTestUrl[] = "data:text/plain,Hello World!";
-
-// Dummy ResourceHandler required for ResourceDispatcherHostRequestInfo.
-class DummyResourceHandler : public ResourceHandler {
- public:
- DummyResourceHandler() {
- }
-
- virtual bool OnRequestRedirected(int request_id, const GURL& url,
- ResourceResponse* response,
- bool* defer) {
- NOTREACHED();
- return true;
- }
-
- virtual bool OnResponseStarted(int request_id,
- ResourceResponse* response) {
- NOTREACHED();
- return true;
- }
-
- virtual bool OnWillRead(int request_id,
- net::IOBuffer** buf,
- int* buf_size,
- int min_size) {
- NOTREACHED();
- return true;
- }
-
- virtual bool OnReadCompleted(int request_id, int* bytes_read) {
- NOTREACHED();
- return true;
- }
-
- virtual bool OnResponseCompleted(int request_id,
- const URLRequestStatus& status,
- const std::string& security_info) {
- NOTREACHED();
- return true;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DummyResourceHandler);
-};
-
-ResourceDispatcherHostRequestInfo* GetRequestInfo(int request_id) {
- return new ResourceDispatcherHostRequestInfo(
- new DummyResourceHandler(), ChildProcessInfo::RENDER_PROCESS, 0, 0,
- request_id, "null", "null", ResourceType::MAIN_FRAME,
- 0, false, false, -1, -1);
-}
-
-class BlacklistListenerTest
- : public testing::Test,
- public NotificationObserver {
- public:
- BlacklistListenerTest()
- : path_provider_(&profile_),
- loop_(MessageLoop::TYPE_IO),
- mock_ui_thread_(ChromeThread::UI, MessageLoop::current()),
- mock_file_thread_(ChromeThread::FILE, MessageLoop::current()),
- mock_io_thread_(ChromeThread::IO, MessageLoop::current()) {
- }
-
- virtual void SetUp() {
- blacklist_manager_ = new BlacklistManager(&profile_, &path_provider_);
- blacklist_listener_ = new BlacklistListener(&resource_queue_);
-
- profile_.set_blacklist_manager(blacklist_manager_.get());
-
- ResourceQueue::DelegateSet delegates;
- delegates.insert(blacklist_listener_.get());
- resource_queue_.Initialize(delegates);
- }
-
- virtual void TearDown() {
- resource_queue_.Shutdown();
- blacklist_listener_ = NULL;
- blacklist_manager_ = NULL;
- loop_.RunAllPending();
- }
-
- // NotificationObserver
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- MessageLoop::current()->Quit();
- }
-
- protected:
- void WaitForBlacklistUpdate() {
- NotificationRegistrar registrar;
- registrar.Add(this,
- NotificationType::BLACKLIST_MANAGER_BLACKLIST_READ_FINISHED,
- Source<Profile>(&profile_));
- MessageLoop::current()->Run();
- }
-
- TestURLRequest* StartTestRequest(URLRequest::Delegate* delegate) {
- TestURLRequest* request = new TestURLRequest(GURL(kTestUrl), delegate);
- BlacklistRequestInfo* request_info =
- new BlacklistRequestInfo(request->url(), ResourceType::MAIN_FRAME,
- blacklist_manager_.get());
- request->SetUserData(&BlacklistRequestInfo::kURLRequestDataKey,
- request_info);
- scoped_ptr<ResourceDispatcherHostRequestInfo> rdh_info(GetRequestInfo(0));
- resource_queue_.AddRequest(request, *rdh_info.get());
- return request;
- }
-
- BlacklistTestingProfile profile_;
-
- TestBlacklistPathProvider path_provider_;
-
- scoped_refptr<BlacklistManager> blacklist_manager_;
-
- scoped_refptr<BlacklistListener> blacklist_listener_;
-
- private:
- MessageLoop loop_;
-
- ChromeThread mock_ui_thread_;
- ChromeThread mock_file_thread_;
- ChromeThread mock_io_thread_;
-
- ResourceQueue resource_queue_;
-};
-
-TEST_F(BlacklistListenerTest, Delay) {
- blacklist_manager_->Initialize();
-
- TestDelegate delegate;
- scoped_ptr<TestURLRequest> request(StartTestRequest(&delegate));
-
- // The request should get delayed, because the BlacklistManager is not yet
- // ready. When we run pending tasks, it should initialize itself, notify
- // the BlacklistListener, and start the request.
- ASSERT_FALSE(request->is_pending());
-
- MessageLoop::current()->RunAllPending();
- EXPECT_EQ("Hello World!", delegate.data_received());
-}
-
-TEST_F(BlacklistListenerTest, NoDelay) {
- blacklist_manager_->Initialize();
-
- // Make sure that the BlacklistManager is ready before we start the request.
- WaitForBlacklistUpdate();
-
- TestDelegate delegate;
- scoped_ptr<TestURLRequest> request(StartTestRequest(&delegate));
-
- // The request should be started immediately.
- ASSERT_TRUE(request->is_pending());
-
- MessageLoop::current()->RunAllPending();
- EXPECT_EQ("Hello World!", delegate.data_received());
-}
-
-} // namespace
diff --git a/chrome/browser/privacy_blacklist/blacklist_manager.cc b/chrome/browser/privacy_blacklist/blacklist_manager.cc
deleted file mode 100644
index c2253ef..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_manager.cc
+++ /dev/null
@@ -1,234 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
-
-#include "base/message_loop.h"
-#include "base/string_util.h"
-#include "base/task.h"
-#include "base/thread.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "chrome/browser/privacy_blacklist/blacklist_io.h"
-#include "chrome/browser/profile.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/notification_service.h"
-#include "chrome/common/notification_source.h"
-#include "chrome/common/notification_type.h"
-
-BlacklistPathProvider::~BlacklistPathProvider() {
-}
-
-BlacklistManager::BlacklistManager(Profile* profile,
- BlacklistPathProvider* path_provider)
- : first_read_finished_(false),
- profile_(profile),
- compiled_blacklist_path_(
- profile->GetPath().Append(chrome::kPrivacyBlacklistFileName)),
- path_provider_(path_provider) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- DCHECK(path_provider_);
-
- registrar_.Add(this,
- NotificationType::EXTENSIONS_READY,
- Source<Profile>(profile));
- registrar_.Add(this,
- NotificationType::EXTENSION_LOADED,
- Source<Profile>(profile));
- registrar_.Add(this,
- NotificationType::EXTENSION_UNLOADED,
- Source<Profile>(profile));
-}
-
-void BlacklistManager::Initialize() {
- if (path_provider_->AreBlacklistPathsReady())
- ReadBlacklist();
-}
-
-const Blacklist* BlacklistManager::GetCompiledBlacklist() const {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- return compiled_blacklist_.get();
-}
-
-void BlacklistManager::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
-
- switch (type.value) {
- case NotificationType::EXTENSIONS_READY:
- ReadBlacklist();
- break;
- case NotificationType::EXTENSION_LOADED:
- case NotificationType::EXTENSION_UNLOADED:
- // Don't do anything if the path provider isn't ready. We're going to get
- // the paths when it becomes ready.
- // This makes an assumption that it isn't possible to install an extension
- // before ExtensionsService becomes ready.
- if (!path_provider_->AreBlacklistPathsReady())
- break;
-
- // We don't need to recompile the on-disk blacklist when the extension
- // doesn't have any blacklist.
- if (Details<Extension>(details).ptr()->privacy_blacklists().empty())
- break;
-
- CompileBlacklist();
- break;
- default:
- NOTREACHED();
- break;
- }
-}
-
-BlacklistManager::~BlacklistManager() {
-}
-
-void BlacklistManager::CompileBlacklist() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- DCHECK(path_provider_->AreBlacklistPathsReady());
-
- // The compiled blacklist is going to change. Make sure our clients don't use
- // the old one and wait for the update instead by indicating that the compiled
- // blacklist is not ready.
- ChromeThread::PostTask(ChromeThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &BlacklistManager::ResetPublishedCompiledBlacklist));
-
- // Schedule actual compilation on the background thread.
- ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE,
- NewRunnableMethod(this, &BlacklistManager::DoCompileBlacklist,
- path_provider_->GetPersistentBlacklistPaths()));
-}
-
-void BlacklistManager::DoCompileBlacklist(
- const std::vector<FilePath>& source_blacklists) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
-
- Blacklist blacklist;
- std::string error_string;
- std::vector<string16> errors;
- for (std::vector<FilePath>::const_iterator i = source_blacklists.begin();
- i != source_blacklists.end(); ++i) {
- std::string error_string;
- if (!BlacklistIO::ReadText(&blacklist, *i, &error_string)) {
- string16 path = WideToUTF16(i->ToWStringHack());
- errors.push_back(path + ASCIIToUTF16(": " + error_string));
- }
- }
-
- if (!errors.empty()) {
- ChromeThread::PostTask(ChromeThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &BlacklistManager::OnBlacklistCompilationReadErrors,
- errors));
- }
-
- // Write the new compiled blacklist based on the data we could read
- // successfully.
- bool success = BlacklistIO::WriteBinary(&blacklist, compiled_blacklist_path_);
- ChromeThread::PostTask(ChromeThread::UI, FROM_HERE,
- NewRunnableMethod(this, &BlacklistManager::OnBlacklistCompilationFinished,
- success));
-}
-
-void BlacklistManager::OnBlacklistCompilationFinished(bool success) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
-
- if (success) {
- ReadBlacklist();
- } else {
- string16 error_message(ASCIIToUTF16("Blacklist compilation failed."));
- NotificationService::current()->Notify(
- NotificationType::BLACKLIST_MANAGER_ERROR,
- Source<Profile>(profile_),
- Details<string16>(&error_message));
- }
-}
-
-void BlacklistManager::OnBlacklistCompilationReadErrors(
- const std::vector<string16>& errors) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
-
- string16 error_message(ASCIIToUTF16("Blacklist compilation failed.\n"));
- for (std::vector<string16>::const_iterator i = errors.begin();
- i != errors.end(); ++i) {
- error_message += *i + ASCIIToUTF16("\n");
- }
- NotificationService::current()->Notify(
- NotificationType::BLACKLIST_MANAGER_ERROR,
- Source<Profile>(profile_),
- Details<string16>(&error_message));
-}
-
-void BlacklistManager::ReadBlacklist() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- DCHECK(path_provider_->AreBlacklistPathsReady());
-
- ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE,
- NewRunnableMethod(this, &BlacklistManager::DoReadBlacklist,
- path_provider_->GetTransientBlacklistPaths()));
-}
-
-void BlacklistManager::DoReadBlacklist(
- const std::vector<FilePath>& transient_blacklists) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
-
- scoped_ptr<Blacklist> blacklist(new Blacklist);
- if (BlacklistIO::ReadBinary(blacklist.get(), compiled_blacklist_path_)) {
- std::string error_string;
- std::vector<FilePath>::const_iterator i;
- for (i = transient_blacklists.begin();
- i != transient_blacklists.end(); ++i) {
- if (!BlacklistIO::ReadText(blacklist.get(), *i, &error_string)) {
- blacklist.reset();
- break;
- }
- }
- } else {
- blacklist.reset();
- }
- ChromeThread::PostTask(ChromeThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &BlacklistManager::UpdatePublishedCompiledBlacklist,
- blacklist.release()));
-}
-
-void BlacklistManager::UpdatePublishedCompiledBlacklist(Blacklist* blacklist) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- if (blacklist)
- compiled_blacklist_.reset(blacklist);
- ChromeThread::PostTask(ChromeThread::UI, FROM_HERE,
- NewRunnableMethod(this, &BlacklistManager::OnBlacklistReadFinished,
- blacklist != NULL));
-}
-
-void BlacklistManager::OnBlacklistReadFinished(bool success) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
-
- if (success) {
- NotificationService::current()->Notify(
- NotificationType::BLACKLIST_MANAGER_BLACKLIST_READ_FINISHED,
- Source<Profile>(profile_),
- NotificationService::NoDetails());
- } else {
- string16 error_message(ASCIIToUTF16("Blacklist read failed."));
- NotificationService::current()->Notify(
- NotificationType::BLACKLIST_MANAGER_ERROR,
- Source<Profile>(profile_),
- Details<string16>(&error_message));
- if (!first_read_finished_) {
- // If we're loading for the first time, the compiled blacklist could
- // just not exist. Try compiling it once.
- CompileBlacklist();
- }
- }
- first_read_finished_ = true;
-}
-
-void BlacklistManager::ResetPublishedCompiledBlacklist() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- compiled_blacklist_.reset();
-}
diff --git a/chrome/browser/privacy_blacklist/blacklist_manager.h b/chrome/browser/privacy_blacklist/blacklist_manager.h
deleted file mode 100644
index 1ababd6..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_manager.h
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_MANAGER_H_
-#define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_MANAGER_H_
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/file_path.h"
-#include "base/ref_counted.h"
-#include "base/scoped_ptr.h"
-#include "chrome/browser/chrome_thread.h"
-#include "chrome/common/notification_registrar.h"
-
-class Blacklist;
-class Profile;
-
-class BlacklistPathProvider {
- public:
- // Returns true if the provider is ready (has loaded the blacklist paths
- // and we can query them). Called on UI thread.
- virtual bool AreBlacklistPathsReady() const = 0;
-
- // Returns paths that will still be there after browser shutdown
- // (installed extensions). Called on UI thread.
- virtual std::vector<FilePath> GetPersistentBlacklistPaths() = 0;
-
- // Returns paths that will disappear after browser shutdown
- // (unpacked extensions). Called on UI thread.
- virtual std::vector<FilePath> GetTransientBlacklistPaths() = 0;
-
- protected:
- virtual ~BlacklistPathProvider();
-};
-
-// Updates one compiled binary blacklist based on a list of plaintext
-// blacklists.
-class BlacklistManager
- : public NotificationObserver,
- public base::RefCountedThreadSafe<BlacklistManager,
- ChromeThread::DeleteOnUIThread> {
- public:
- // Create BlacklistManager (must be done on UI thread).
- BlacklistManager(Profile* profile, BlacklistPathProvider* path_provider);
-
- // Initialize the BlacklistManager (on UI thread).
- void Initialize();
-
- // Returns compiled blacklist, or NULL if not ready. Only valid to call on IO
- // thread.
- const Blacklist* GetCompiledBlacklist() const;
-
- // NotificationObserver
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
-#ifdef UNIT_TEST
- const FilePath& compiled_blacklist_path() { return compiled_blacklist_path_; }
-#endif // UNIT_TEST
-
- private:
- friend class ChromeThread;
- friend class DeleteTask<BlacklistManager>;
-
- virtual ~BlacklistManager();
-
- // Compile all persistent blacklists to one binary blacklist stored on disk.
- void CompileBlacklist();
- void DoCompileBlacklist(const std::vector<FilePath>& source_blacklists);
- void OnBlacklistCompilationReadErrors(const std::vector<string16>& errors);
- void OnBlacklistCompilationFinished(bool success);
-
- // Read all blacklists from disk (the compiled one and also the transient
- // blacklists). In case of failure, if we haven't loaded any blacklist yet,
- // we'll compile the blacklist and try to read it again.
- void ReadBlacklist();
- void DoReadBlacklist(const std::vector<FilePath>& transient_blacklists);
- void UpdatePublishedCompiledBlacklist(Blacklist* blacklist);
- void OnBlacklistReadFinished(bool success);
-
- // Sets the |compiled_blacklist_| to NULL to indicate that the blacklist is
- // not ready.
- void ResetPublishedCompiledBlacklist();
-
- // True after the first blacklist read has finished (regardless of success).
- // Used to avoid an infinite loop.
- bool first_read_finished_;
-
- Profile* profile_;
-
- // Path where we store the compiled blacklist.
- FilePath compiled_blacklist_path_;
-
- // Keep the compiled blacklist object in memory.
- scoped_ptr<Blacklist> compiled_blacklist_;
-
- BlacklistPathProvider* path_provider_;
-
- NotificationRegistrar registrar_;
-
- DISALLOW_COPY_AND_ASSIGN(BlacklistManager);
-};
-
-#endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_MANAGER_H_
diff --git a/chrome/browser/privacy_blacklist/blacklist_manager_browsertest.cc b/chrome/browser/privacy_blacklist/blacklist_manager_browsertest.cc
deleted file mode 100644
index d6e6992..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_manager_browsertest.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
-
-#include "app/l10n_util.h"
-#include "base/command_line.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/extensions/extension_browsertest.h"
-#include "chrome/browser/extensions/extensions_service.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
-#include "chrome/browser/profile.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/test/in_process_browser_test.h"
-#include "chrome/test/ui_test_utils.h"
-#include "grit/browser_resources.h"
-#include "grit/generated_resources.h"
-#include "net/base/mock_host_resolver.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-void GetBlacklistHasMatchOnIOThread(const BlacklistManager* manager,
- const GURL& url,
- bool *has_match) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- const Blacklist* blacklist = manager->GetCompiledBlacklist();
- scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(url));
- *has_match = (match.get() != NULL);
- ChromeThread::PostTask(ChromeThread::UI, FROM_HERE,
- new MessageLoop::QuitTask());
-}
-
-} // namespace
-
-class BlacklistManagerBrowserTest : public ExtensionBrowserTest {
- public:
- virtual void SetUp() {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnablePrivacyBlacklists);
- ExtensionBrowserTest::SetUp();
- }
-
- virtual void SetUpInProcessBrowserTestFixture() {
- ExtensionBrowserTest::SetUpInProcessBrowserTestFixture();
-
- host_resolver()->AddSimulatedFailure("www.example.com");
- }
-
- protected:
- BlacklistManager* GetBlacklistManager() {
- return browser()->profile()->GetBlacklistManager();
- }
-
- bool BlacklistHasMatch(const std::string& url) {
- bool has_match = false;
- ChromeThread::PostTask(ChromeThread::IO, FROM_HERE,
- NewRunnableFunction(GetBlacklistHasMatchOnIOThread,
- GetBlacklistManager(),
- GURL(url),
- &has_match));
- ui_test_utils::RunMessageLoop();
- return has_match;
- }
-};
-
-IN_PROC_BROWSER_TEST_F(BlacklistManagerBrowserTest, Basic) {
- static const char kTestUrl[] = "http://www.example.com/annoying_ads/ad.jpg";
-
- // Test loading an extension with blacklist.
- ASSERT_TRUE(LoadExtension(
- test_data_dir_.AppendASCII("common").AppendASCII("privacy_blacklist")));
-
- // Navigate to a blacklisted URL. The request should be blocked.
- ui_test_utils::NavigateToURL(browser(), GURL(kTestUrl));
- string16 expected_title(l10n_util::GetStringUTF16(IDS_BLACKLIST_TITLE));
- string16 tab_title;
- ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title));
- EXPECT_EQ(expected_title, tab_title);
- EXPECT_TRUE(BlacklistHasMatch(kTestUrl));
-}
diff --git a/chrome/browser/privacy_blacklist/blacklist_manager_unittest.cc b/chrome/browser/privacy_blacklist/blacklist_manager_unittest.cc
deleted file mode 100644
index 55089a4..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_manager_unittest.cc
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
-
-#include "base/message_loop.h"
-#include "base/path_service.h"
-#include "base/thread.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "chrome/browser/privacy_blacklist/blacklist_test_util.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/notification_observer.h"
-#include "chrome/common/notification_registrar.h"
-#include "chrome/common/notification_source.h"
-#include "chrome/common/notification_type.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class BlacklistManagerTest : public testing::Test, public NotificationObserver {
- public:
- BlacklistManagerTest()
- : path_provider_(&profile_),
- mock_ui_thread_(ChromeThread::UI, MessageLoop::current()),
- mock_file_thread_(ChromeThread::FILE),
- mock_io_thread_(ChromeThread::IO, MessageLoop::current()) {
- }
-
- virtual void SetUp() {
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_));
- test_data_dir_ = test_data_dir_.AppendASCII("blacklist_samples");
- ASSERT_TRUE(mock_file_thread_.Start());
- }
-
- virtual void TearDown() {
- mock_file_thread_.Stop();
- loop_.RunAllPending();
- }
-
- // NotificationObserver
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- MessageLoop::current()->Quit();
- }
-
- protected:
- void WaitForBlacklistError() {
- NotificationRegistrar registrar;
- registrar.Add(this,
- NotificationType::BLACKLIST_MANAGER_ERROR,
- Source<Profile>(&profile_));
- MessageLoop::current()->Run();
- }
-
- void WaitForBlacklistUpdate() {
- NotificationRegistrar registrar;
- registrar.Add(this,
- NotificationType::BLACKLIST_MANAGER_BLACKLIST_READ_FINISHED,
- Source<Profile>(&profile_));
- MessageLoop::current()->Run();
- }
-
- FilePath test_data_dir_;
-
- BlacklistTestingProfile profile_;
-
- TestBlacklistPathProvider path_provider_;
-
- private:
- MessageLoop loop_;
-
- ChromeThread mock_ui_thread_;
- ChromeThread mock_file_thread_;
- ChromeThread mock_io_thread_;
-};
-
-// Returns true if |blacklist| contains a match for |url|.
-bool BlacklistHasMatch(const Blacklist* blacklist, const char* url) {
- Blacklist::Match* match = blacklist->FindMatch(GURL(url));
-
- if (!match)
- return false;
-
- delete match;
- return true;
-}
-
-TEST_F(BlacklistManagerTest, Basic) {
- scoped_refptr<BlacklistManager> manager(
- new BlacklistManager(&profile_, &path_provider_));
- manager->Initialize();
- WaitForBlacklistUpdate();
-
- const Blacklist* blacklist = manager->GetCompiledBlacklist();
- EXPECT_TRUE(blacklist);
-
- // Repeated invocations of GetCompiledBlacklist should return the same object.
- EXPECT_EQ(blacklist, manager->GetCompiledBlacklist());
-}
-
-TEST_F(BlacklistManagerTest, BlacklistPathProvider) {
- scoped_refptr<BlacklistManager> manager(
- new BlacklistManager(&profile_, &path_provider_));
- manager->Initialize();
- WaitForBlacklistUpdate();
-
- const Blacklist* blacklist1 = manager->GetCompiledBlacklist();
- EXPECT_FALSE(BlacklistHasMatch(blacklist1,
- "http://host/annoying_ads/ad.jpg"));
-
- path_provider_.AddPersistentPath(
- test_data_dir_.AppendASCII("annoying_ads.pbl"));
- WaitForBlacklistUpdate();
-
- const Blacklist* blacklist2 = manager->GetCompiledBlacklist();
-
- // Added a real blacklist, the manager should recompile.
- EXPECT_TRUE(BlacklistHasMatch(blacklist2, "http://host/annoying_ads/ad.jpg"));
- EXPECT_FALSE(BlacklistHasMatch(blacklist2, "http://host/other_ads/ad.jpg"));
-
- path_provider_.AddTransientPath(test_data_dir_.AppendASCII("other_ads.pbl"));
- WaitForBlacklistUpdate();
-
- const Blacklist* blacklist3 = manager->GetCompiledBlacklist();
-
- // In theory blacklist2 and blacklist3 could be the same object, so we're
- // not checking for inequality.
- EXPECT_TRUE(BlacklistHasMatch(blacklist3, "http://host/annoying_ads/ad.jpg"));
- EXPECT_TRUE(BlacklistHasMatch(blacklist3, "http://host/other_ads/ad.jpg"));
-
- // Now make sure that transient blacklists don't survive after re-creating
- // the BlacklistManager.
- manager = NULL;
- path_provider_.clear();
- path_provider_.AddPersistentPath(
- test_data_dir_.AppendASCII("annoying_ads.pbl"));
- manager = new BlacklistManager(&profile_, &path_provider_);
- manager->Initialize();
- WaitForBlacklistUpdate();
-
- const Blacklist* blacklist4 = manager->GetCompiledBlacklist();
-
- EXPECT_TRUE(BlacklistHasMatch(blacklist4, "http://host/annoying_ads/ad.jpg"));
- EXPECT_FALSE(BlacklistHasMatch(blacklist4, "http://host/other_ads/ad.jpg"));
-}
-
-TEST_F(BlacklistManagerTest, BlacklistPathReadError) {
- scoped_refptr<BlacklistManager> manager(
- new BlacklistManager(&profile_, &path_provider_));
- manager->Initialize();
- WaitForBlacklistUpdate();
-
- FilePath bogus_path(test_data_dir_.AppendASCII("does_not_exist_randomness"));
- ASSERT_FALSE(file_util::PathExists(bogus_path));
- path_provider_.AddPersistentPath(bogus_path);
- WaitForBlacklistUpdate();
-
- const Blacklist* blacklist = manager->GetCompiledBlacklist();
- EXPECT_TRUE(blacklist);
-}
-
-TEST_F(BlacklistManagerTest, CompiledBlacklistReadError) {
- FilePath compiled_blacklist_path;
-
- {
- scoped_refptr<BlacklistManager> manager(
- new BlacklistManager(&profile_, &path_provider_));
- manager->Initialize();
- WaitForBlacklistUpdate();
-
- path_provider_.AddPersistentPath(
- test_data_dir_.AppendASCII("annoying_ads.pbl"));
- WaitForBlacklistUpdate();
- const Blacklist* blacklist = manager->GetCompiledBlacklist();
- EXPECT_TRUE(BlacklistHasMatch(blacklist,
- "http://host/annoying_ads/ad.jpg"));
-
- compiled_blacklist_path = manager->compiled_blacklist_path();
- }
-
- ASSERT_TRUE(file_util::PathExists(compiled_blacklist_path));
- ASSERT_TRUE(file_util::Delete(compiled_blacklist_path, false));
-
- {
- scoped_refptr<BlacklistManager> manager(
- new BlacklistManager(&profile_, &path_provider_));
- manager->Initialize();
- WaitForBlacklistUpdate();
-
- // The manager should recompile the blacklist.
- const Blacklist* blacklist = manager->GetCompiledBlacklist();
- EXPECT_TRUE(BlacklistHasMatch(blacklist,
- "http://host/annoying_ads/ad.jpg"));
- }
-}
-
-} // namespace
diff --git a/chrome/browser/privacy_blacklist/blacklist_request_info.cc b/chrome/browser/privacy_blacklist/blacklist_request_info.cc
index b5ecfb5..ff60513 100644
--- a/chrome/browser/privacy_blacklist/blacklist_request_info.cc
+++ b/chrome/browser/privacy_blacklist/blacklist_request_info.cc
@@ -4,17 +4,15 @@
#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
-#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
-
// static
const void* const BlacklistRequestInfo::kURLRequestDataKey = 0;
BlacklistRequestInfo::BlacklistRequestInfo(const GURL& url,
ResourceType::Type resource_type,
- BlacklistManager* blacklist_manager)
+ const Blacklist* blacklist)
: url_(url),
resource_type_(resource_type),
- blacklist_manager_(blacklist_manager) {
+ blacklist_(blacklist) {
}
BlacklistRequestInfo::~BlacklistRequestInfo() {
diff --git a/chrome/browser/privacy_blacklist/blacklist_request_info.h b/chrome/browser/privacy_blacklist/blacklist_request_info.h
index 84a74d1..f662d41 100644
--- a/chrome/browser/privacy_blacklist/blacklist_request_info.h
+++ b/chrome/browser/privacy_blacklist/blacklist_request_info.h
@@ -19,12 +19,12 @@ class BlacklistRequestInfo : public URLRequest::UserData {
static const void* const kURLRequestDataKey;
BlacklistRequestInfo(const GURL& url, ResourceType::Type resource_type,
- BlacklistManager* blacklist_manager);
+ const Blacklist* blacklist);
~BlacklistRequestInfo();
ResourceType::Type resource_type() const { return resource_type_; }
- const BlacklistManager* GetBlacklistManager() const {
- return blacklist_manager_.get();
+ const Blacklist* GetBlacklist() const {
+ return blacklist_;
}
// Get the blacklist request info stored in |request|, or NULL if there is no
@@ -38,8 +38,8 @@ class BlacklistRequestInfo : public URLRequest::UserData {
// Type of the requested resource (main frame, image, etc).
const ResourceType::Type resource_type_;
- // BlacklistManager used for the request.
- scoped_refptr<BlacklistManager> blacklist_manager_;
+ // Blacklist used for the request.
+ const Blacklist* blacklist_;
DISALLOW_COPY_AND_ASSIGN(BlacklistRequestInfo);
};
diff --git a/chrome/browser/privacy_blacklist/blacklist_test_util.cc b/chrome/browser/privacy_blacklist/blacklist_test_util.cc
deleted file mode 100644
index da4fdc9..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_test_util.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/privacy_blacklist/blacklist_test_util.h"
-
-#include "base/file_path.h"
-#include "base/values.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/notification_service.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-BlacklistTestingProfile::BlacklistTestingProfile() {
- EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
- path_ = temp_dir_.path();
-}
-
-TestBlacklistPathProvider::TestBlacklistPathProvider(Profile* profile)
- : profile_(profile) {
-}
-
-bool TestBlacklistPathProvider::AreBlacklistPathsReady() const {
- return true;
-}
-
-std::vector<FilePath> TestBlacklistPathProvider::GetPersistentBlacklistPaths() {
- return persistent_paths_;
-}
-
-std::vector<FilePath> TestBlacklistPathProvider::GetTransientBlacklistPaths() {
- return transient_paths_;
-}
-
-void TestBlacklistPathProvider::AddPersistentPath(const FilePath& path) {
- persistent_paths_.push_back(path);
- SendUpdateNotification();
-}
-
-void TestBlacklistPathProvider::AddTransientPath(const FilePath& path) {
- transient_paths_.push_back(path);
- SendUpdateNotification();
-}
-
-void TestBlacklistPathProvider::clear() {
- persistent_paths_.clear();
- transient_paths_.clear();
- SendUpdateNotification();
-}
-
-void TestBlacklistPathProvider::SendUpdateNotification() {
- ListValue* privacy_blacklists = new ListValue;
- privacy_blacklists->Append(new StringValue("dummy.pbl"));
-
- DictionaryValue manifest;
- manifest.SetString(extension_manifest_keys::kVersion, "1.0");
- manifest.SetString(extension_manifest_keys::kName, "test");
- manifest.Set(extension_manifest_keys::kPrivacyBlacklists,
- privacy_blacklists);
-
- // Create an extension with dummy path.
-#if defined(OS_WIN)
- FilePath path(FILE_PATH_LITERAL("c:\\foo"));
-#elif defined(OS_POSIX)
- FilePath path(FILE_PATH_LITERAL("/foo"));
-#endif
- Extension extension(path);
- std::string error;
- ASSERT_TRUE(extension.InitFromValue(manifest, false, &error));
- ASSERT_TRUE(error.empty());
-
- NotificationService::current()->Notify(
- NotificationType::EXTENSION_LOADED,
- Source<Profile>(profile_),
- Details<Extension>(&extension));
-}
diff --git a/chrome/browser/privacy_blacklist/blacklist_test_util.h b/chrome/browser/privacy_blacklist/blacklist_test_util.h
deleted file mode 100644
index 1b79c3d..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_test_util.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_TEST_UTIL_H_
-#define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_TEST_UTIL_H_
-
-#include <vector>
-
-#include "base/scoped_temp_dir.h"
-#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
-#include "chrome/test/testing_profile.h"
-
-class FilePath;
-
-// Testing profile which uses a temporary directory.
-class BlacklistTestingProfile : public TestingProfile {
- public:
- BlacklistTestingProfile();
-
- BlacklistManager* GetBlacklistManager() { return blacklist_manager_; }
- void set_blacklist_manager(BlacklistManager* manager) {
- blacklist_manager_ = manager;
- }
-
- private:
- ScopedTempDir temp_dir_;
-
- BlacklistManager* blacklist_manager_;
-
- DISALLOW_COPY_AND_ASSIGN(BlacklistTestingProfile);
-};
-
-// Path provider which allows easy updates from the outside and sends
-// notifications for each change.
-class TestBlacklistPathProvider : public BlacklistPathProvider {
- public:
- explicit TestBlacklistPathProvider(Profile* profile);
-
- // BlacklistPathProvider:
- virtual bool AreBlacklistPathsReady() const;
- virtual std::vector<FilePath> GetPersistentBlacklistPaths();
- virtual std::vector<FilePath> GetTransientBlacklistPaths();
-
- // Adds a path to the provder and sends an update notification.
- void AddPersistentPath(const FilePath& path);
- void AddTransientPath(const FilePath& path);
-
- // Removes all paths from the provider and send an update notification.
- void clear();
-
- private:
- void SendUpdateNotification();
-
- Profile* profile_;
-
- // Keep track of added paths.
- std::vector<FilePath> persistent_paths_;
- std::vector<FilePath> transient_paths_;
-
- DISALLOW_COPY_AND_ASSIGN(TestBlacklistPathProvider);
-};
-
-#endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_TEST_UTIL_H_
diff --git a/chrome/browser/privacy_blacklist/blacklist_ui.cc b/chrome/browser/privacy_blacklist/blacklist_ui.cc
index 9425176..354e2d4 100644
--- a/chrome/browser/privacy_blacklist/blacklist_ui.cc
+++ b/chrome/browser/privacy_blacklist/blacklist_ui.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/blocked_popup_container.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "chrome/browser/privacy_blacklist/blacklist_manager.h"
#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
@@ -69,9 +68,7 @@ void BlacklistUI::OnNonvisualContentBlocked(const URLRequest* request) {
BlacklistRequestInfo* request_info =
BlacklistRequestInfo::FromURLRequest(request);
- const BlacklistManager* blacklist_manager =
- request_info->GetBlacklistManager();
- const Blacklist* blacklist = blacklist_manager->GetCompiledBlacklist();
+ const Blacklist* blacklist = request_info->GetBlacklist();
scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request->url()));
const ResourceDispatcherHostRequestInfo* info =
ResourceDispatcherHost::InfoForRequest(request);