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

Unified Diff: chrome/browser/privacy_blacklist/blacklist_manager.cc

Issue 341050: Implement loading blacklists from extensions.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: use real extension Created 11 years, 1 month 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: chrome/browser/privacy_blacklist/blacklist_manager.cc
diff --git a/chrome/browser/privacy_blacklist/blacklist_manager.cc b/chrome/browser/privacy_blacklist/blacklist_manager.cc
index f7c93115dee4ada2ae7dddac0c3efb78b54dc887..0629806fb1e2d78282381683fabca110dac73102 100644
--- a/chrome/browser/privacy_blacklist/blacklist_manager.cc
+++ b/chrome/browser/privacy_blacklist/blacklist_manager.cc
@@ -35,7 +35,7 @@ class BlacklistManagerTask : public Task {
protected:
BlacklistManager* blacklist_manager() const { return manager_; }
-
+
MessageLoop* original_loop_;
private:
@@ -59,7 +59,7 @@ class BlacklistManager::CompileBlacklistTask : public BlacklistManagerTask {
virtual void Run() {
bool success = true;
-
+
Blacklist blacklist;
std::string error_string;
@@ -107,7 +107,7 @@ class BlacklistManager::ReadBlacklistTask : public BlacklistManagerTask {
ReportReadResult(NULL);
return;
}
-
+
std::string error_string;
std::vector<FilePath>::const_iterator i;
for (i = transient_blacklists_.begin();
@@ -117,7 +117,7 @@ class BlacklistManager::ReadBlacklistTask : public BlacklistManagerTask {
return;
}
}
-
+
ReportReadResult(blacklist.release());
}
@@ -128,7 +128,7 @@ class BlacklistManager::ReadBlacklistTask : public BlacklistManagerTask {
&BlacklistManager::OnBlacklistReadFinished,
blacklist));
}
-
+
FilePath compiled_blacklist_;
std::vector<FilePath> transient_blacklists_;
@@ -145,7 +145,10 @@ BlacklistManager::BlacklistManager(Profile* profile,
path_provider_(path_provider),
backend_thread_(backend_thread) {
registrar_.Add(this,
- NotificationType::BLACKLIST_PATH_PROVIDER_UPDATED,
+ NotificationType::EXTENSION_LOADED,
+ Source<Profile>(profile));
+ registrar_.Add(this,
+ NotificationType::EXTENSION_UNLOADED,
Source<Profile>(profile));
ReadBlacklist();
}
@@ -153,8 +156,15 @@ BlacklistManager::BlacklistManager(Profile* profile,
void BlacklistManager::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK(type == NotificationType::BLACKLIST_PATH_PROVIDER_UPDATED);
- CompileBlacklist();
+ switch (type.value) {
+ case NotificationType::EXTENSION_LOADED:
+ case NotificationType::EXTENSION_UNLOADED:
+ CompileBlacklist();
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
}
void BlacklistManager::CompileBlacklist() {
@@ -167,7 +177,7 @@ void BlacklistManager::CompileBlacklist() {
void BlacklistManager::ReadBlacklist() {
DCHECK(CalledOnValidThread());
-
+
RunTaskOnBackendThread(new ReadBlacklistTask(
this, compiled_blacklist_path_,
path_provider_->GetTransientBlacklistPaths()));
@@ -175,7 +185,7 @@ void BlacklistManager::ReadBlacklist() {
void BlacklistManager::OnBlacklistCompilationFinished(bool success) {
DCHECK(CalledOnValidThread());
-
+
if (success) {
ReadBlacklist();
} else {
@@ -189,7 +199,7 @@ void BlacklistManager::OnBlacklistCompilationFinished(bool success) {
void BlacklistManager::OnBlacklistReadFinished(Blacklist* blacklist) {
DCHECK(CalledOnValidThread());
-
+
if (!blacklist) {
if (!first_read_finished_) {
// If we're loading for the first time, the compiled blacklist could
@@ -207,7 +217,7 @@ void BlacklistManager::OnBlacklistReadFinished(Blacklist* blacklist) {
}
first_read_finished_ = true;
compiled_blacklist_.reset(blacklist);
-
+
NotificationService::current()->Notify(
NotificationType::BLACKLIST_MANAGER_BLACKLIST_READ_FINISHED,
Source<Profile>(profile_),
« no previous file with comments | « chrome/browser/gtk/browser_actions_toolbar_gtk.cc ('k') | chrome/browser/privacy_blacklist/blacklist_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698