summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-02 13:25:31 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-02 13:25:31 +0000
commitaa43b4d1623f3480929e8e5d659702a3eaacb769 (patch)
tree5fb50980e721b75cf5f5bec3c95fc0e7ae36e8f3
parentd68ac2aace5bb58425b60162795ba48c819369c6 (diff)
downloadchromium_src-aa43b4d1623f3480929e8e5d659702a3eaacb769.zip
chromium_src-aa43b4d1623f3480929e8e5d659702a3eaacb769.tar.gz
chromium_src-aa43b4d1623f3480929e8e5d659702a3eaacb769.tar.bz2
Remove abonded privacy blacklist implementation.
BUG=16932 TEST=compiles Review URL: http://codereview.chromium.org/2862041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51525 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd8
-rw-r--r--chrome/browser/browser_prefs.cc2
-rw-r--r--chrome/browser/browser_resources.grd2
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc43
-rw-r--r--chrome/browser/net/chrome_url_request_context.h22
-rw-r--r--chrome/browser/options_util.cc1
-rw-r--r--chrome/browser/privacy_blacklist/blacklist.cc223
-rw-r--r--chrome/browser/privacy_blacklist/blacklist.h227
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_interceptor.cc136
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_interceptor.h23
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_interceptor_unittest.cc73
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_perftest.cc214
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_request_info.cc27
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_request_info.h47
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_ui.cc26
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_ui.h18
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_unittest.cc248
-rw-r--r--chrome/browser/profile.cc14
-rw-r--r--chrome/browser/profile.h6
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc10
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.h4
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc29
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h9
-rw-r--r--chrome/browser/resources/privacy_blacklist_block.html44
-rw-r--r--chrome/browser/resources/privacy_blacklist_block.pngbin4645 -> 0 bytes
-rw-r--r--chrome/chrome_browser.gypi8
-rw-r--r--chrome/chrome_tests.gypi3
-rw-r--r--chrome/common/chrome_constants.cc1
-rw-r--r--chrome/common/chrome_constants.h1
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/common/notification_type.h7
-rw-r--r--chrome/common/pref_names.cc3
-rw-r--r--chrome/common/pref_names.h1
-rw-r--r--chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/blacklist.pbl12
-rw-r--r--chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json3
-rw-r--r--chrome/test/data/profiles/blacklist_prefs/Preferences41
-rw-r--r--chrome/test/testing_profile.h1
-rw-r--r--net/url_request/url_request_context.h14
-rw-r--r--net/url_request/url_request_http_job.cc9
40 files changed, 4 insertions, 1560 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index a3d637e..9e847ab 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -7379,14 +7379,6 @@ Keep your key file in a safe place. You will need it to create new versions of y
Open Files
</message>
- <!-- Privacy Blacklist -->
- <message name="IDS_BLACKLIST_TITLE" desc="Title of the page displayed when a page is blocked.">
- Blocked Resource
- </message>
- <message name="IDS_BLACKLIST_MESSAGE" desc="Message shown instead of a blocked element.">
- The following Privacy Blacklists prevented this content from showing:
- </message>
-
<!-- Geolocation messages -->
<message name="IDS_GEOLOCATION_INFOBAR_QUESTION" desc="Question asked on the info bar whenever URL wants to access the user's physical location">
<ph name="URL">
diff --git a/chrome/browser/browser_prefs.cc b/chrome/browser/browser_prefs.cc
index a9affc2..04962f8 100644
--- a/chrome/browser/browser_prefs.cc
+++ b/chrome/browser/browser_prefs.cc
@@ -31,7 +31,6 @@
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/page_info_model.h"
#include "chrome/browser/password_manager/password_manager.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
@@ -115,7 +114,6 @@ void RegisterUserPrefs(PrefService* user_prefs) {
HostContentSettingsMap::RegisterUserPrefs(user_prefs);
HostZoomMap::RegisterUserPrefs(user_prefs);
DevToolsManager::RegisterUserPrefs(user_prefs);
- Blacklist::RegisterUserPrefs(user_prefs);
PinnedTabCodec::RegisterUserPrefs(user_prefs);
ExtensionPrefs::RegisterUserPrefs(user_prefs);
GeolocationContentSettingsMap::RegisterUserPrefs(user_prefs);
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 36fe829..0604e7a 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -67,8 +67,6 @@ without changes to the corresponding grd file. sew -->
<include name="IDR_SYNC_CHOOSE_DATATYPES_HTML" file="sync\resources\choose_datatypes.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_SYNC_SETUP_FLOW_HTML" file="sync\resources\setup_flow.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_SYNC_SETUP_DONE_HTML" file="sync\resources\setup_done.html" flattenhtml="true" type="BINDATA" />
- <include name="IDR_BLACKLIST_HTML" file="resources\privacy_blacklist_block.html" flattenhtml="true" type="BINDATA" />
- <include name="IDR_BLACKLIST_IMAGE" file="resources\privacy_blacklist_block.png" type="BINDATA" />
<include name="IDR_NOTIFICATION_ICON_HTML" file="resources\notification_icon.html" type="BINDATA" />
<include name="IDR_NOTIFICATION_2LINE_HTML" file="resources\notification_2line.html" type="BINDATA" />
<include name="IDR_NOTIFICATION_1LINE_HTML" file="resources\notification_1line.html" type="BINDATA" />
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index e5208ae..712fbf7 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -17,8 +17,6 @@
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/sqlite_persistent_cookie_store.h"
#include "chrome/browser/net/predictor_api.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
#include "chrome/browser/profile.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
@@ -814,44 +812,6 @@ const std::string& ChromeURLRequestContext::GetUserAgent(
return webkit_glue::GetUserAgent(url);
}
-bool ChromeURLRequestContext::InterceptRequestCookies(
- const URLRequest* request, const std::string& cookies) const {
- return InterceptCookie(request, cookies);
-}
-
-bool ChromeURLRequestContext::InterceptResponseCookie(
- const URLRequest* request, const std::string& cookie) const {
- return InterceptCookie(request, cookie);
-}
-
-bool ChromeURLRequestContext::InterceptCookie(
- const URLRequest* request, const std::string& cookie) const {
- BlacklistRequestInfo* request_info =
- BlacklistRequestInfo::FromURLRequest(request);
- // Requests which don't go through ResourceDispatcherHost don't have privacy
- // blacklist request data.
- if (!request_info)
- return true;
- const Blacklist* blacklist = request_info->GetBlacklist();
- // TODO(phajdan.jr): remove the NULL check when blacklists are stable.
- if (!blacklist)
- return true;
- scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request->url()));
- if (match.get() && (match->attributes() & Blacklist::kBlockCookies)) {
- NotificationService::current()->Notify(
- NotificationType::BLACKLIST_NONVISUAL_RESOURCE_BLOCKED,
- Source<const ChromeURLRequestContext>(this),
- Details<const URLRequest>(request));
- return false;
- }
-
- return true;
-}
-
-const Blacklist* ChromeURLRequestContext::GetPrivacyBlacklist() const {
- return privacy_blacklist_.get();
-}
-
void ChromeURLRequestContext::OnNewExtensions(const std::string& id,
ExtensionInfo* info) {
if (!is_off_the_record_)
@@ -907,7 +867,6 @@ ChromeURLRequestContext::ChromeURLRequestContext(
chrome_cookie_policy_ = other->chrome_cookie_policy_;
host_content_settings_map_ = other->host_content_settings_map_;
host_zoom_map_ = other->host_zoom_map_;
- privacy_blacklist_ = other->privacy_blacklist_;
is_media_ = other->is_media_;
is_off_the_record_ = other->is_off_the_record_;
}
@@ -965,7 +924,6 @@ ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile)
host_content_settings_map_ = profile->GetHostContentSettingsMap();
host_zoom_map_ = profile->GetHostZoomMap();
- privacy_blacklist_ = profile->GetPrivacyBlacklist();
transport_security_state_ = profile->GetTransportSecurityState();
if (profile->GetExtensionsService()) {
@@ -1013,7 +971,6 @@ void ChromeURLRequestContextFactory::ApplyProfileParametersToContext(
context->set_user_script_dir_path(user_script_dir_path_);
context->set_host_content_settings_map(host_content_settings_map_);
context->set_host_zoom_map(host_zoom_map_);
- context->set_privacy_blacklist(privacy_blacklist_);
context->set_transport_security_state(
transport_security_state_);
context->set_ssl_config_service(ssl_config_service_);
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index 2b6d08d..6964460 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -17,7 +17,6 @@
#include "chrome/browser/host_zoom_map.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/pref_service.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
#include "chrome/browser/net/chrome_cookie_policy.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/net/url_request_context_getter.h"
@@ -107,23 +106,12 @@ class ChromeURLRequestContext : public URLRequestContext {
virtual const std::string& GetUserAgent(const GURL& url) const;
- // Returns true if cookies can be added to request.
- virtual bool InterceptRequestCookies(const URLRequest* request,
- const std::string& cookie) const;
-
- // Returns true if response cookies should be stored.
- virtual bool InterceptResponseCookie(const URLRequest* request,
- const std::string& cookie) const;
-
HostContentSettingsMap* host_content_settings_map() {
return host_content_settings_map_;
}
const HostZoomMap* host_zoom_map() const { return host_zoom_map_; }
- // Gets the Privacy Blacklist, if any for this context.
- const Blacklist* GetPrivacyBlacklist() const;
-
// Callback for when new extensions are loaded. Takes ownership of
// |extension_info|.
void OnNewExtensions(const std::string& id, ExtensionInfo* extension_info);
@@ -208,9 +196,6 @@ class ChromeURLRequestContext : public URLRequestContext {
void set_host_zoom_map(HostZoomMap* host_zoom_map) {
host_zoom_map_ = host_zoom_map;
}
- void set_privacy_blacklist(Blacklist* privacy_blacklist) {
- privacy_blacklist_ = privacy_blacklist;
- }
void set_appcache_service(ChromeAppCacheService* service) {
appcache_service_ = service;
}
@@ -242,17 +227,11 @@ class ChromeURLRequestContext : public URLRequestContext {
scoped_refptr<ChromeCookiePolicy> chrome_cookie_policy_;
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
scoped_refptr<HostZoomMap> host_zoom_map_;
- scoped_refptr<Blacklist> privacy_blacklist_;
bool is_media_;
bool is_off_the_record_;
private:
- // Blacklist implementation of InterceptRequestCookie and
- // InterceptResponseCookie. Returns true if cookies are allowed and false
- // if the request matches a Blacklist rule and cookies should be blocked.
- bool InterceptCookie(const URLRequest* request,
- const std::string& cookie) const;
DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext);
};
@@ -406,7 +385,6 @@ class ChromeURLRequestContextFactory {
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
scoped_refptr<HostZoomMap> host_zoom_map_;
- scoped_refptr<Blacklist> privacy_blacklist_;
scoped_refptr<net::TransportSecurityState> transport_security_state_;
scoped_refptr<net::SSLConfigService> ssl_config_service_;
scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate_;
diff --git a/chrome/browser/options_util.cc b/chrome/browser/options_util.cc
index 17b064d..8bcf063 100644
--- a/chrome/browser/options_util.cc
+++ b/chrome/browser/options_util.cc
@@ -47,7 +47,6 @@ void OptionsUtil::ResetToDefaults(Profile* profile) {
prefs::kAutoFillEnabled,
prefs::kHomePage,
prefs::kHomePageIsNewTabPage,
- prefs::kPrivacyFilterRules,
prefs::kPromptForDownload,
prefs::kPasswordManagerEnabled,
prefs::kRestoreOnStartup,
diff --git a/chrome/browser/privacy_blacklist/blacklist.cc b/chrome/browser/privacy_blacklist/blacklist.cc
deleted file mode 100644
index 9b4bda1..0000000
--- a/chrome/browser/privacy_blacklist/blacklist.cc
+++ /dev/null
@@ -1,223 +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.h"
-
-#include <algorithm>
-#include <limits>
-#include <string>
-
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/string_util.h"
-#include "chrome/browser/pref_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
-#include "net/http/http_util.h"
-
-namespace {
-
-const char* const cookie_headers[2] = { "cookie", "set-cookie" };
-
-} // namespace
-
-const unsigned int Blacklist::kBlockAll = 1;
-const unsigned int Blacklist::kBlockCookies = 1 << 1;
-const unsigned int Blacklist::kDontSendReferrer = 1 << 2;
-const unsigned int Blacklist::kDontSendUserAgent = 1 << 3;
-const unsigned int Blacklist::kBlockUnsecure = 1 << 4;
-const unsigned int Blacklist::kBlockRequest = kBlockAll | kBlockUnsecure;
-const unsigned int Blacklist::kModifySentHeaders =
- kBlockCookies | kDontSendUserAgent | kDontSendReferrer;
-const unsigned int Blacklist::kModifyReceivedHeaders = kBlockCookies;
-
-// static
-bool Blacklist::Matches(const std::string& pattern, const std::string& url) {
- if (pattern.size() > url.size())
- return false;
-
- std::string::size_type p = 0;
- std::string::size_type u = 0;
-
- while (pattern[p] != '\0' && url[u] != '\0') {
- if (pattern[p] == '@') {
- while (pattern[++p] == '@') {} // Consecutive @ are redundant.
-
- if (pattern[p] == '\0')
- return true; // Nothing to match after the @.
-
- // Look for another wildcard to determine pattern-chunk.
- std::string::size_type tp = pattern.find_first_of("@", p);
-
- // If it must match until the end, compare the last characters.
- if (tp == std::string::npos) {
- std::string::size_type ur = url.size() - u;
- std::string::size_type pr = pattern.size() - p;
- return (pr <= ur) &&
- (url.compare(url.size() - pr, pr, pattern.c_str() + p) == 0);
- }
-
- // Else find the pattern chunk which is pattern[p:tp]
- std::string::size_type tu = url.find(pattern.c_str() + p, u, tp - p);
- if (tu == std::string::npos)
- return false; // Pattern chunk not found.
-
- // Since tp is strictly greater than p, both u and p always increase.
- u = tu + tp - p;
- p = tp;
- continue;
- }
-
- // Match non-wildcard character.
- if (pattern[p++] != url[u++])
- return false;
- }
- return pattern[p] == '\0';
-}
-
-bool Blacklist::Entry::IsBlocked(const GURL& url) const {
- return (attributes_ & kBlockAll) ||
- ((attributes_ & kBlockUnsecure) && !url.SchemeIsSecure());
-}
-
-Blacklist::Entry::Entry(const std::string& pattern, const Provider* provider,
- bool is_exception)
- : attributes_(0),
- is_exception_(is_exception),
- pattern_(pattern),
- provider_(provider) {}
-
-void Blacklist::Entry::AddAttributes(unsigned int attributes) {
- attributes_ |= attributes;
-}
-
-bool Blacklist::Match::IsBlocked(const GURL& url) const {
- return (attributes() & kBlockAll) ||
- ((attributes() & kBlockUnsecure) && !url.SchemeIsSecure());
-}
-
-Blacklist::Match::Match() : matching_attributes_(0), exception_attributes_(0) {}
-
-void Blacklist::Match::AddEntry(const Entry* entry) {
- if (entry->is_exception()) {
- exception_attributes_ |= entry->attributes();
- exception_entries_.push_back(entry);
- } else {
- matching_attributes_ |= entry->attributes();
- matching_entries_.push_back(entry);
- }
-}
-
-Blacklist::Blacklist(PrefService* prefs) : prefs_(prefs) {
- LoadPreferences();
-}
-
-Blacklist::~Blacklist() {
-}
-
-void Blacklist::AddEntry(Entry* entry) {
- DCHECK(entry);
- blacklist_.push_back(linked_ptr<Entry>(entry));
-}
-
-void Blacklist::AddProvider(Provider* provider) {
- DCHECK(provider);
- providers_.push_back(linked_ptr<Provider>(provider));
-}
-
-// Returns a pointer to the Blacklist-owned entry which matches the given
-// URL. If no matching Entry is found, returns null.
-Blacklist::Match* Blacklist::FindMatch(const GURL& url) const {
- // Never match something which is not http, https or ftp.
- // TODO(idanan): Investigate if this would be an inclusion test instead of an
- // exclusion test and if there are other schemes to test for.
- if (!url.SchemeIs(chrome::kHttpScheme) &&
- !url.SchemeIs(chrome::kHttpsScheme) &&
- !url.SchemeIs(chrome::kFtpScheme))
- return 0;
- std::string url_spec = GetURLAsLookupString(url);
- Match* match = NULL;
- for (EntryList::const_iterator i = blacklist_.begin();
- i != blacklist_.end(); ++i) {
- if (Matches((*i)->pattern(), url_spec)) {
- if (!match)
- match = new Match;
- match->AddEntry(i->get());
- }
- }
- return match;
-}
-
-bool Blacklist::LoadEntryPreference(const ListValue& pref,
- const Provider* provider) {
- EntryList entries;
- for (ListValue::const_iterator i = pref.begin(); i != pref.end(); ++i) {
- if (!(*i)->IsType(Value::TYPE_DICTIONARY))
- return false;
- const DictionaryValue* entry_pref = static_cast<DictionaryValue*>(*i);
- std::string pattern;
- int attributes;
- bool is_exception;
- if (!(entry_pref->GetString(L"pattern", &pattern) &&
- entry_pref->GetInteger(L"attributes", &attributes) &&
- entry_pref->GetBoolean(L"exception", &is_exception)))
- return false;
- Entry* entry = new Entry(pattern, provider, is_exception);
- entry->AddAttributes(static_cast<unsigned int>(attributes));
- entries.push_back(linked_ptr<Entry>(entry));
- }
- blacklist_.insert(blacklist_.end(), entries.begin(), entries.end());
- return true;
-}
-
-bool Blacklist::LoadProviderPreference(const DictionaryValue& pref,
- const std::wstring& path) {
- std::string name, url;
- ListValue* entries;
- if (!(pref.GetString(L"name", &name) && pref.GetString(L"url", &url) &&
- pref.GetList(L"entries", &entries)))
- return false;
- linked_ptr<Provider> provider(new Provider(name, url, path));
- if (LoadEntryPreference(*entries, provider.get()))
- providers_.push_back(provider);
- return true;
- return false;
-}
-
-bool Blacklist::LoadPreferences() {
- DCHECK(prefs_);
- const DictionaryValue* blacklist_rules = prefs_->GetDictionary(
- prefs::kPrivacyFilterRules);
- if (!blacklist_rules)
- return false;
- bool result = true;
- for (DictionaryValue::key_iterator key = blacklist_rules->begin_keys();
- key != blacklist_rules->end_keys(); ++key) {
- DictionaryValue* provider;
- if (!(blacklist_rules->GetDictionaryWithoutPathExpansion(*key, &provider) &&
- LoadProviderPreference(*provider, *key)))
- result = false;
- }
- return result;
-}
-
-// static
-std::string Blacklist::GetURLAsLookupString(const GURL& url) {
- std::string url_spec = url.host() + url.path();
- if (!url.query().empty())
- url_spec = url_spec + "?" + url.query();
-
- return url_spec;
-}
-
-// static
-void Blacklist::RegisterUserPrefs(PrefService* user_prefs) {
- user_prefs->RegisterDictionaryPref(prefs::kPrivacyFilterRules);
-}
-
-// static
-std::string Blacklist::StripCookies(const std::string& header) {
- return net::HttpUtil::StripHeaders(header, cookie_headers, 2);
-}
diff --git a/chrome/browser/privacy_blacklist/blacklist.h b/chrome/browser/privacy_blacklist/blacklist.h
deleted file mode 100644
index e5d1b5f..0000000
--- a/chrome/browser/privacy_blacklist/blacklist.h
+++ /dev/null
@@ -1,227 +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.
-
-#ifndef CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_H_
-#define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_H_
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/gtest_prod_util.h"
-#include "base/linked_ptr.h"
-#include "base/ref_counted.h"
-#include "googleurl/src/gurl.h"
-#include "net/url_request/url_request.h"
-
-class DictionaryValue;
-class FilePath;
-class ListValue;
-class PrefService;
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// Blacklist Class
-//
-// Represents a blacklist used to protect user from privacy and annoyances.
-// A blacklist is essentially a map from resource-match patterns to filter-
-// attributes. Each time a resources matches a pattern the filter-attributes
-// are used to determine how the browser handles the matching resource.
-////////////////////////////////////////////////////////////////////////////////
-class Blacklist : public base::RefCountedThreadSafe<Blacklist> {
- public:
- class Entry;
- class Provider;
-
- typedef std::vector<linked_ptr<Entry> > EntryList;
- typedef std::vector<linked_ptr<Provider> > ProviderList;
-
- // Filter attributes (more to come):
- static const unsigned int kBlockAll;
- static const unsigned int kBlockCookies;
- static const unsigned int kDontSendReferrer;
- static const unsigned int kDontSendUserAgent;
- static const unsigned int kBlockUnsecure;
-
- // Aggregate filter types:
- static const unsigned int kBlockRequest;
- static const unsigned int kBlockResponse;
- static const unsigned int kModifySentHeaders;
- static const unsigned int kModifyReceivedHeaders;
-
- // Blacklist entries come from a provider, defined by a name and source URL.
- class Provider {
- public:
- Provider() {}
- Provider(const std::string& name, const std::string& url,
- const std::wstring& pref_path)
- : name_(name),
- pref_path_(pref_path),
- url_(url) {}
-
- const std::string& name() const { return name_; }
- void set_name(const std::string& name) { name_ = name; }
-
- const std::wstring& pref_path() const { return pref_path_; }
- void set_pref_path(const std::wstring& pref_path) {
- pref_path_ = pref_path;
- }
-
- const std::string& url() const { return url_; }
- void set_url(const std::string& url) { url_ = url; }
-
- private:
- std::string name_;
- std::wstring pref_path_;
- std::string url_;
- };
-
- // A single blacklist entry which is returned when a URL matches one of
- // the patterns. Entry objects are owned by the Blacklist that stores them.
- class Entry {
- public:
- // Construct with given pattern.
- Entry(const std::string& pattern, const Provider* provider,
- bool is_exception);
-
- // Returns the pattern which this entry matches.
- const std::string& pattern() const { return pattern_; }
-
- // Bitfield of filter-attributes matching the pattern.
- unsigned int attributes() const { return attributes_; }
-
- // True if this entry is an exception to the blacklist.
- bool is_exception() const { return is_exception_; }
-
- // Provider of this blacklist entry, used for assigning blame ;)
- const Provider* provider() const { return provider_; }
-
- // Returns true of the given URL is blocked, assumes it matches the
- // pattern of this entry.
- bool IsBlocked(const GURL&) const;
-
- void AddAttributes(unsigned int attributes);
-
- private:
- unsigned int attributes_;
-
- // True if this entry is an exception to the blacklist.
- bool is_exception_;
- std::string pattern_;
-
- // Points to the provider of this entry, the providers are all
- // owned by the blacklist.
- const Provider* provider_;
- };
-
- // A request may match one or more Blacklist rules. The Match class packages
- // all the matching entries behind a single interface with access to the
- // underlying set of entries so that we can display provider information.
- // Often a match must be applied after a URLRequest has started, so it gets
- // tagged with the Match object to avoid doing lookups more than once per
- // request.
- class Match : public URLRequest::UserData {
- public:
- // Functions that return combined results from all entries.
- unsigned int attributes() const {
- return (matching_attributes_ & (~exception_attributes_));
- }
- bool IsBlocked(const GURL&) const;
-
- // Access to individual entries, mostly for display/logging purposes.
- const std::vector<const Entry*>& entries() const {
- return matching_entries_;
- }
-
- private:
- Match();
- void AddEntry(const Entry* entry);
-
- std::vector<const Entry*> matching_entries_;
- std::vector<const Entry*> exception_entries_;
-
- // Precomputed ORed attributes of matching/exception entries.
- unsigned int matching_attributes_;
- unsigned int exception_attributes_;
-
- friend class Blacklist; // Only blacklist constructs and sets these.
- };
-
- // Constructs a blacklist and populates it from the preferences associated
- // with this profile.
- explicit Blacklist(PrefService* prefs);
-
-#ifdef UNIT_TEST
- // Constructs an empty blacklist.
- Blacklist() : prefs_(NULL) {}
-#endif
-
- // Destructor.
- ~Blacklist();
-
- // Adds a new entry to the blacklist. It is now owned by the blacklist.
- void AddEntry(Entry* entry);
-
- // Adds a new provider to the blacklist. It is now owned by the blacklist.
- void AddProvider(Provider* provider);
-
- EntryList::const_iterator entries_begin() const {
- return blacklist_.begin();
- }
-
- EntryList::const_iterator entries_end() const {
- return blacklist_.end();
- }
-
- ProviderList::const_iterator providers_begin() const {
- return providers_.begin();
- }
-
- ProviderList::const_iterator providers_end() const {
- return providers_.end();
- }
-
- // Returns a pointer to a Match structure holding all matching entries.
- // If no matching Entry is found, returns null. Ownership belongs to the
- // caller.
- Match* FindMatch(const GURL&) const;
-
- static void RegisterUserPrefs(PrefService* user_prefs);
-
- // Helper to remove cookies from a header.
- static std::string StripCookies(const std::string&);
-
- private:
- // Converts a GURL into the string to match against.
- static std::string GetURLAsLookupString(const GURL& url);
-
- // Loads the list of entries for a given provider. Returns true on success.
- bool LoadEntryPreference(const ListValue& pref, const Provider* provider);
-
- // Loads patterns from preferences. Returns true on success.
- bool LoadPreferences();
-
- // Loads a provider and subsequently all of its entries. Returns true on
- // success. If an error occurs reading a provider or one of its entries,
- // the complete provider is dropped.
- bool LoadProviderPreference(const DictionaryValue& pref,
- const std::wstring& path);
-
- // Matches a pattern to a core URL which is host/path with all the other
- // optional parts (scheme, user, password, port) stripped away.
- static bool Matches(const std::string& pattern, const std::string& url);
-
- EntryList blacklist_;
- ProviderList providers_;
-
- // Preferences where blacklist entries are stored.
- PrefService* prefs_;
-
- FRIEND_TEST_ALL_PREFIXES(BlacklistTest, Generic);
- FRIEND_TEST_ALL_PREFIXES(BlacklistTest, PatternMatch);
-
- DISALLOW_COPY_AND_ASSIGN(Blacklist);
-};
-
-#endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_H_
diff --git a/chrome/browser/privacy_blacklist/blacklist_interceptor.cc b/chrome/browser/privacy_blacklist/blacklist_interceptor.cc
deleted file mode 100644
index f950d17..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_interceptor.cc
+++ /dev/null
@@ -1,136 +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_interceptor.h"
-
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/string_util.h"
-#include "base/values.h"
-#include "chrome/browser/privacy_blacklist/blacklist.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"
-#include "grit/browser_resources.h"
-#include "grit/generated_resources.h"
-
-namespace {
-
-class URLRequestBlacklistJob : public URLRequestSimpleJob {
- public:
- URLRequestBlacklistJob(URLRequest* request,
- const BlacklistRequestInfo& request_info)
- : URLRequestSimpleJob(request),
- request_info_(request_info) {
- }
-
- virtual bool GetData(std::string* mime_type,
- std::string* charset,
- std::string* data) const {
- if (ResourceType::IsFrame(request_info_.resource_type())) {
- *mime_type = "text/html";
- *charset = "utf-8";
- *data = GetHTMLResponse();
- } else {
- // TODO(phajdan.jr): For some resources (like script) we may want to
- // simulate an error instead or return other MIME type.
- *mime_type = "image/png";
- *data = GetImageResponse();
- }
- return true;
- }
-
- private:
- std::string GetHTMLResponse() const {
- return "HTTP/1.1 200 OK\r\n"
- "Content-Type: text/html;charset=utf-8\r\n"
- "Cache-Control: no-store\r\n\r\n" + GetHTML();
- }
-
- static std::string GetImageResponse() {
- return "HTTP/1.1 200 OK\r\n"
- "Content-Type: image/png\r\n"
- "Cache-Control: no-store\r\n\r\n" + GetImage();
- }
-
- static std::string GetImage() {
- return ResourceBundle::GetSharedInstance().
- GetRawDataResource(IDR_BLACKLIST_IMAGE).as_string();
- }
-
- std::string GetHTML() const {
- DictionaryValue strings;
- strings.SetString(L"title", l10n_util::GetString(IDS_BLACKLIST_TITLE));
- strings.SetString(L"message", l10n_util::GetString(IDS_BLACKLIST_MESSAGE));
-
- const Blacklist::Provider* provider = GetBestMatchingEntryProvider();
- strings.SetString(L"name", provider->name());
- strings.SetString(L"url", provider->url());
-
- const base::StringPiece html =
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_BLACKLIST_HTML);
- return jstemplate_builder::GetI18nTemplateHtml(html, &strings);
- }
-
- const Blacklist::Provider* GetBestMatchingEntryProvider() const {
- // If kBlockAll is specified, assign blame to such an entry.
- // Otherwise pick the first one.
- 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) {
- for (std::vector<const Blacklist::Entry*>::const_iterator i =
- match->entries().begin(); i != match->entries().end(); ++i) {
- if ((*i)->attributes() == Blacklist::kBlockAll) {
- entry = *i;
- break;
- }
- }
- } else {
- entry = match->entries().front();
- }
- return entry->provider();
- }
-
- const BlacklistRequestInfo& request_info_;
-
- DISALLOW_COPY_AND_ASSIGN(URLRequestBlacklistJob);
-};
-
-} // namespace
-
-BlacklistInterceptor::BlacklistInterceptor() {
- URLRequest::RegisterRequestInterceptor(this);
-}
-
-BlacklistInterceptor::~BlacklistInterceptor() {
- URLRequest::UnregisterRequestInterceptor(this);
-}
-
-URLRequestJob* BlacklistInterceptor::MaybeIntercept(URLRequest* request) {
- BlacklistRequestInfo* request_info =
- BlacklistRequestInfo::FromURLRequest(request);
- if (!request_info) {
- // Not all requests have privacy blacklist data, for example downloads.
- return NULL;
- }
-
- const Blacklist* blacklist = request_info->GetBlacklist();
- scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request->url()));
-
- if (!match.get()) {
- // Nothing is blacklisted for this request. Do not intercept.
- return NULL;
- }
-
- // TODO(phajdan.jr): Should we have some UI to notify about blocked referrer?
- if (match->attributes() & Blacklist::kDontSendReferrer)
- request->set_referrer(std::string());
-
- if (match->IsBlocked(request->url()))
- return new URLRequestBlacklistJob(request, *request_info);
-
- return NULL;
-}
diff --git a/chrome/browser/privacy_blacklist/blacklist_interceptor.h b/chrome/browser/privacy_blacklist/blacklist_interceptor.h
deleted file mode 100644
index 308ce9c..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_interceptor.h
+++ /dev/null
@@ -1,23 +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_INTERCEPTOR_H_
-#define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_INTERCEPTOR_H_
-
-#include "net/url_request/url_request.h"
-
-// Intercepts requests matched by a privacy blacklist.
-class BlacklistInterceptor : public URLRequest::Interceptor {
- public:
- BlacklistInterceptor();
- ~BlacklistInterceptor();
-
- // URLRequest::Interceptor:
- virtual URLRequestJob* MaybeIntercept(URLRequest* request);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(BlacklistInterceptor);
-};
-
-#endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_INTERCEPTOR_H_
diff --git a/chrome/browser/privacy_blacklist/blacklist_interceptor_unittest.cc b/chrome/browser/privacy_blacklist/blacklist_interceptor_unittest.cc
deleted file mode 100644
index 240870a..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_interceptor_unittest.cc
+++ /dev/null
@@ -1,73 +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 "app/l10n_util.h"
-#include "base/message_loop.h"
-#include "chrome/browser/privacy_blacklist/blacklist_interceptor.h"
-#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
-#include "grit/browser_resources.h"
-#include "grit/generated_resources.h"
-#include "net/base/io_buffer.h"
-#include "net/url_request/url_request.h"
-#include "net/url_request/url_request_status.h"
-#include "net/url_request/url_request_unittest.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-const char kDataUrl[] = "data:text/plain,Hello World!";
-const char kBlockedUrl[] = "http://example.com/annoying_ads/ad.jpg";
-
-class BlacklistInterceptorTest : public testing::Test {
- public:
- BlacklistInterceptorTest() : loop_(MessageLoop::TYPE_IO) {
- }
-
- protected:
- bool InterceptedTestRequest(const std::string& url,
- BlacklistRequestInfo* request_info) {
- TestDelegate delegate;
- TestURLRequest request(GURL(url), &delegate);
- request.SetUserData(&BlacklistRequestInfo::kURLRequestDataKey,
- request_info);
- request.Start();
- MessageLoop::current()->Run();
-
- std::string response(delegate.data_received());
- return (ContainsResourceString(response, IDS_BLACKLIST_TITLE) &&
- ContainsResourceString(response, IDS_BLACKLIST_MESSAGE));
- }
-
- BlacklistInterceptor interceptor_;
-
- private:
- bool ContainsResourceString(const std::string& text, int string_id) {
- return text.find(l10n_util::GetStringUTF8(string_id)) != std::string::npos;
- }
-
- MessageLoop loop_;
-};
-
-TEST_F(BlacklistInterceptorTest, Basic) {
- EXPECT_FALSE(InterceptedTestRequest(kDataUrl, NULL));
-}
-
-TEST_F(BlacklistInterceptorTest, Intercepted) {
- EXPECT_FALSE(InterceptedTestRequest(kDataUrl, NULL));
-
- scoped_refptr<Blacklist> blacklist = new 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.get());
- EXPECT_TRUE(InterceptedTestRequest(kBlockedUrl, request_info));
-}
-
-} // namespace
diff --git a/chrome/browser/privacy_blacklist/blacklist_perftest.cc b/chrome/browser/privacy_blacklist/blacklist_perftest.cc
deleted file mode 100644
index cccbad5..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_perftest.cc
+++ /dev/null
@@ -1,214 +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 <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/perftimer.h"
-#include "base/scoped_ptr.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-// Number of URLs to try for each test.
-const size_t kNumUrls = 10000;
-
-// Fixed random seed for srand(), so always the same random blacklist is
-// generated.
-const unsigned int kSeed = 0;
-
-// Number of entries for the benchmark blacklist. The blacklist will contain
-// five different kinds of patterns:
-// - host.name.tld/
-// - /some/path
-// - /some/path/script?
-// - host.name.tld/some/path
-// - host.name.tld/some/path/?script
-const size_t kNumHostEntries = 500;
-const size_t kNumPathEntries = 500;
-const size_t kNumScriptEntries = 500;
-const size_t kNumHostPathEntries = 250;
-const size_t kNumHostScriptEntries = 250;
-const size_t kNumPattern = kNumHostEntries + kNumPathEntries +
- kNumScriptEntries + kNumHostPathEntries +
- kNumHostScriptEntries;
-
-// Returns a random integer between 0 and |max| - 1.
-static size_t RandomIndex(size_t max) {
- DCHECK_GT(max, 0U);
-
- return static_cast<size_t>(static_cast<float>(max) *
- (rand() / (RAND_MAX + 1.0)));
-}
-
-// Generates a random alpha-numeric string of a given |length|.
-static std::string GetRandomString(size_t length) {
- // Alpha-numeric characters without the letter a. This is later used
- // in |GetNotMatchingURL| to generate disjoint patterns.
- static const char chars[] = "bcdefghijklmnopqrstuvwxyz0123456789";
- std::string result;
-
- for (size_t i = 0; i < length; ++i) {
- result += chars[RandomIndex(arraysize(chars) - 1)];
- }
-
- return result;
-}
-
-// Generates a URL that will match a given pattern. Assumes that the pattern
-// consists of at least a leading wildcard and a trailing wildcard. If invert
-// is true, the returned URL will NOT match the pattern or any other pattern
-// generated for the blacklist.
-static std::string GetURL(const std::string& pattern, bool invert) {
- DCHECK_GT(pattern.length(), 2U);
- DCHECK_EQ(pattern[0], '@');
- DCHECK_EQ(pattern[pattern.length() - 1], '@');
-
- std::string url("http://");
-
- // If this is a path pattern, prepend host.tld, otherwise just prepend host.
- if (pattern[1] == '/') {
- url += GetRandomString(8) + "." + GetRandomString(3);
- } else {
- url += GetRandomString(6) + ".";
- }
-
- // Add the constant part of the pattern.
- url += pattern.substr(1, pattern.length() - 2);
-
- // If this is a script pattern, append name1=value parameters, otherwise
- // append a /path/file.ext
- if (pattern[pattern.length() - 2] == '?') {
- url += GetRandomString(5) + "=" + GetRandomString(10);
- } else {
- url += GetRandomString(6) + "/" + GetRandomString(6) + "." +
- GetRandomString(3);
- }
-
- // If the URL is supposed to match no pattern, we introduce the letter 'a'
- // which is not used for generating patterns
- if (invert) {
- // Position of the host/path separating slash. Skipping the 7 characters
- // of "http://".
- size_t host_path_separator = 7 + url.find_first_of('/', 7);
-
- // If the pattern is starting with a /path, modify the first path element,
- // otherwise modify the hostname.
- if (pattern[1] == '/') {
- url[host_path_separator + 3] = 'a';
- } else {
- // Locate the domain name.
- url[url.substr(0, host_path_separator).find_last_of('.') - 2] = 'a';
- }
- }
-
- return url;
-}
-
-class BlacklistPerfTest : public testing::Test {
- public:
- BlacklistPerfTest() : blacklist_(new Blacklist()) {}
-
- protected:
- virtual void SetUp() {
- srand(kSeed);
-
- // Generate random benchmark blacklist.
- Blacklist::Provider* provider = new Blacklist::Provider("test",
- "http://test.com",
- L"test");
- blacklist_->AddProvider(provider);
-
- // Create host.tld/ patterns.
- for (size_t i = 0; i < kNumHostEntries; ++i) {
- std::string pattern = "@" + GetRandomString(8) + "." +
- GetRandomString(3) + "/@";
- blacklist_->AddEntry(new Blacklist::Entry(pattern, provider, false));
- }
-
- // Create /some/path/ patterns.
- for (size_t i = 0; i < kNumPathEntries; ++i) {
- std::string pattern = "@/" + GetRandomString(6) + "/" +
- GetRandomString(6) + "/@";
- blacklist_->AddEntry(new Blacklist::Entry(pattern, provider, false));
- }
-
- // Create /some/path/script? patterns.
- for (size_t i = 0; i < kNumScriptEntries; ++i) {
- std::string pattern = "@/" + GetRandomString(6) + "/" +
- GetRandomString(6) + "/" + GetRandomString(6) +
- "?@";
- blacklist_->AddEntry(new Blacklist::Entry(pattern, provider, false));
- }
-
- // Create host.tld/some/path patterns.
- for (size_t i = 0; i < kNumHostPathEntries; ++i) {
- std::string pattern = "@" + GetRandomString(8) + "." +
- GetRandomString(3) + "/" + GetRandomString(6) +
- "/" + GetRandomString(6) + "/@";
- blacklist_->AddEntry(new Blacklist::Entry(pattern, provider, false));
- }
-
- // Create host.tld/some/path/script? patterns.
- for (size_t i = 0; i < kNumHostScriptEntries; ++i) {
- std::string pattern = "@" + GetRandomString(8) + "." +
- GetRandomString(3) + "/" + GetRandomString(6) +
- "/" + GetRandomString(6) + "?@";
- blacklist_->AddEntry(new Blacklist::Entry(pattern, provider, false));
- }
-
- DCHECK_EQ(std::distance(blacklist_->entries_begin(),
- blacklist_->entries_end()), static_cast<ptrdiff_t>(kNumPattern));
- }
-
- // Randomly generated benchmark blacklist.
- scoped_refptr<Blacklist> blacklist_;
-};
-
-// Perf test for matching URLs which are contained in the blacklist.
-TEST_F(BlacklistPerfTest, Match) {
- // Pick random patterns and generate matching URLs
- std::vector<std::string> urls;
- for (size_t i = 0; i < kNumUrls; ++i) {
- const Blacklist::Entry* entry = (blacklist_->entries_begin() +
- RandomIndex(kNumPattern))->get();
- urls.push_back(GetURL(entry->pattern(), false));
- }
-
- // Measure performance for matching urls against the blacklist.
- PerfTimeLogger timer("blacklist_match");
-
- for (size_t i = 0; i < kNumUrls; ++i) {
- scoped_ptr<Blacklist::Match> match(blacklist_->FindMatch(GURL(urls[i])));
- ASSERT_TRUE(match.get());
- }
-
- timer.Done();
-}
-
-// Perf test for matching URLs which are NOT contained in the blacklist.
-TEST_F(BlacklistPerfTest, Mismatch) {
- // We still use randomly picked patterns for generating URLs, but the URLs
- // are made so that they do NOT match any generated pattern
- std::vector<std::string> urls;
- for (size_t i = 0; i < kNumUrls; ++i) {
- const Blacklist::Entry* entry = (blacklist_->entries_begin() +
- RandomIndex(kNumPattern))->get();
- urls.push_back(GetURL(entry->pattern(), true));
- }
-
- // Measure performance for matching urls against the blacklist.
- PerfTimeLogger timer("blacklist_mismatch");
-
- for (size_t i = 0; i < kNumUrls; ++i) {
- scoped_ptr<Blacklist::Match> match(blacklist_->FindMatch(GURL(urls[i])));
- ASSERT_FALSE(match.get());
- }
-
- timer.Done();
-}
-
-} // namespace
diff --git a/chrome/browser/privacy_blacklist/blacklist_request_info.cc b/chrome/browser/privacy_blacklist/blacklist_request_info.cc
deleted file mode 100644
index ff60513..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_request_info.cc
+++ /dev/null
@@ -1,27 +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_request_info.h"
-
-// static
-const void* const BlacklistRequestInfo::kURLRequestDataKey = 0;
-
-BlacklistRequestInfo::BlacklistRequestInfo(const GURL& url,
- ResourceType::Type resource_type,
- const Blacklist* blacklist)
- : url_(url),
- resource_type_(resource_type),
- blacklist_(blacklist) {
-}
-
-BlacklistRequestInfo::~BlacklistRequestInfo() {
-}
-
-// static
-BlacklistRequestInfo* BlacklistRequestInfo::FromURLRequest(
- const URLRequest* request) {
- URLRequest::UserData* user_data =
- request->GetUserData(&kURLRequestDataKey);
- return (user_data ? static_cast<BlacklistRequestInfo*>(user_data) : NULL);
-}
diff --git a/chrome/browser/privacy_blacklist/blacklist_request_info.h b/chrome/browser/privacy_blacklist/blacklist_request_info.h
deleted file mode 100644
index f662d41..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_request_info.h
+++ /dev/null
@@ -1,47 +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_REQUEST_INFO_H_
-#define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_REQUEST_INFO_H_
-
-#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "googleurl/src/gurl.h"
-#include "net/url_request/url_request.h"
-#include "webkit/glue/resource_type.h"
-
-class BlacklistManager;
-
-// Privacy blacklist-related information attached to each request.
-class BlacklistRequestInfo : public URLRequest::UserData {
- public:
- // Key used to access data attached to URLRequest objects.
- static const void* const kURLRequestDataKey;
-
- BlacklistRequestInfo(const GURL& url, ResourceType::Type resource_type,
- const Blacklist* blacklist);
- ~BlacklistRequestInfo();
-
- ResourceType::Type resource_type() const { return resource_type_; }
- const Blacklist* GetBlacklist() const {
- return blacklist_;
- }
-
- // Get the blacklist request info stored in |request|, or NULL if there is no
- // one. The object is owned by |request|.
- static BlacklistRequestInfo* FromURLRequest(const URLRequest* request);
-
- private:
- // URL of the request.
- const GURL url_;
-
- // Type of the requested resource (main frame, image, etc).
- const ResourceType::Type resource_type_;
-
- // Blacklist used for the request.
- const Blacklist* blacklist_;
-
- DISALLOW_COPY_AND_ASSIGN(BlacklistRequestInfo);
-};
-
-#endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_REQUEST_INFO_H_
diff --git a/chrome/browser/privacy_blacklist/blacklist_ui.cc b/chrome/browser/privacy_blacklist/blacklist_ui.cc
deleted file mode 100644
index 0c5537f..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_ui.cc
+++ /dev/null
@@ -1,26 +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_ui.h"
-
-#include "chrome/browser/chrome_thread.h"
-#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
-#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
-#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
-
-// static
-void BlacklistUI::OnNonvisualContentBlocked(const URLRequest* /*request*/) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
-
- // TODO
-
- /* This code will probably be useful when this function is implemented.
- BlacklistRequestInfo* request_info =
- BlacklistRequestInfo::FromURLRequest(request);
- const Blacklist* blacklist = request_info->GetBlacklist();
- scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request->url()));
- const ResourceDispatcherHostRequestInfo* info =
- ResourceDispatcherHost::InfoForRequest(request);
- */
-}
diff --git a/chrome/browser/privacy_blacklist/blacklist_ui.h b/chrome/browser/privacy_blacklist/blacklist_ui.h
deleted file mode 100644
index ce76ad8..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_ui.h
+++ /dev/null
@@ -1,18 +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_UI_H_
-#define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_UI_H_
-
-class URLRequest;
-
-// Set of routines to display blacklist-related UI.
-class BlacklistUI {
- public:
- // Called on IO thread when non-visual content is blocked by a privacy
- // blacklist.
- static void OnNonvisualContentBlocked(const URLRequest* request);
-};
-
-#endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_UI_H_
diff --git a/chrome/browser/privacy_blacklist/blacklist_unittest.cc b/chrome/browser/privacy_blacklist/blacklist_unittest.cc
deleted file mode 100644
index f010eef..0000000
--- a/chrome/browser/privacy_blacklist/blacklist_unittest.cc
+++ /dev/null
@@ -1,248 +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.h"
-
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/path_service.h"
-#include "base/string_util.h"
-#include "chrome/browser/browser_prefs.h"
-#include "chrome/browser/chrome_thread.h"
-#include "chrome/browser/pref_service.h"
-#include "chrome/browser/pref_value_store.h"
-#include "chrome/browser/profile.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/json_pref_store.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-class BlacklistTest : public testing::Test {
- protected:
- virtual void SetUp() {
- FilePath source_path;
- PathService::Get(chrome::DIR_TEST_DATA, &source_path);
- source_path = source_path.AppendASCII("profiles")
- .AppendASCII("blacklist_prefs").AppendASCII("Preferences");
-
- // Create a preference service that only contains user defined
- // preference values.
- prefs_.reset(new PrefService(new PrefValueStore(
- NULL, /* No managed preference values */
- new JsonPrefStore( /* user defined preference values */
- source_path,
- ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)),
- NULL /* No suggested preference values */)));
-
- Profile::RegisterUserPrefs(prefs_.get());
- browser::RegisterAllPrefs(prefs_.get(), prefs_.get());
- }
-
- scoped_ptr<PrefService> prefs_;
-};
-
-TEST_F(BlacklistTest, Generic) {
- scoped_refptr<Blacklist> blacklist = new Blacklist(prefs_.get());
- Blacklist::EntryList entries(blacklist->entries_begin(),
- blacklist->entries_end());
-
- ASSERT_EQ(7U, entries.size());
-
- // All entries include global attributes.
- // NOTE: Silly bitwise-or with zero to workaround a Mac compiler bug.
- EXPECT_EQ(Blacklist::kBlockUnsecure|0, entries[0]->attributes());
- EXPECT_FALSE(entries[0]->is_exception());
- EXPECT_EQ("@poor-security-site.com", entries[0]->pattern());
-
- // NOTE: Silly bitwise-or with zero to workaround a Mac compiler bug.
- EXPECT_EQ(Blacklist::kBlockCookies|0, entries[1]->attributes());
- EXPECT_FALSE(entries[1]->is_exception());
- EXPECT_EQ("@.ad-serving-place.com", entries[1]->pattern());
-
- EXPECT_EQ(Blacklist::kDontSendUserAgent|Blacklist::kDontSendReferrer,
- entries[2]->attributes());
- EXPECT_FALSE(entries[2]->is_exception());
- EXPECT_EQ("www.site.com/anonymous/folder/@", entries[2]->pattern());
-
- // NOTE: Silly bitwise-or with zero to workaround a Mac compiler bug.
- EXPECT_EQ(Blacklist::kBlockAll|0, entries[3]->attributes());
- EXPECT_FALSE(entries[3]->is_exception());
- EXPECT_EQ("www.site.com/bad/url", entries[3]->pattern());
-
- // NOTE: Silly bitwise-or with zero to workaround a Mac compiler bug.
- EXPECT_EQ(Blacklist::kBlockAll|0, entries[4]->attributes());
- EXPECT_FALSE(entries[4]->is_exception());
- EXPECT_EQ("@/script?@", entries[4]->pattern());
-
- // NOTE: Silly bitwise-or with zero to workaround a Mac compiler bug.
- EXPECT_EQ(Blacklist::kBlockAll|0, entries[5]->attributes());
- EXPECT_FALSE(entries[5]->is_exception());
- EXPECT_EQ("@?badparam@", entries[5]->pattern());
-
- // NOTE: Silly bitwise-or with zero to workaround a Mac compiler bug.
- EXPECT_EQ(Blacklist::kBlockAll|0, entries[6]->attributes());
- EXPECT_TRUE(entries[6]->is_exception());
- EXPECT_EQ("www.site.com/bad/url/good", entries[6]->pattern());
-
- Blacklist::ProviderList providers(blacklist->providers_begin(),
- blacklist->providers_end());
-
- ASSERT_EQ(1U, providers.size());
- EXPECT_EQ("Sample", providers[0]->name());
- EXPECT_EQ("http://www.example.com", providers[0]->url());
-
- // No match for chrome, about or empty URLs.
- EXPECT_FALSE(blacklist->FindMatch(GURL()));
- EXPECT_FALSE(blacklist->FindMatch(GURL("chrome://new-tab")));
- EXPECT_FALSE(blacklist->FindMatch(GURL("about:blank")));
-
- // Expected rule matches.
- Blacklist::Match* match =
- blacklist->FindMatch(GURL("http://www.site.com/bad/url"));
- EXPECT_TRUE(match);
- if (match) {
- EXPECT_EQ(Blacklist::kBlockAll|0, match->attributes());
- EXPECT_EQ(1U, match->entries().size());
- delete match;
- }
-
- match = blacklist->FindMatch(GURL("http://www.site.com/anonymous"));
- EXPECT_FALSE(match);
- if (match)
- delete match;
-
- match = blacklist->FindMatch(GURL("http://www.site.com/anonymous/folder"));
- EXPECT_FALSE(match);
- if (match)
- delete match;
-
- match = blacklist->FindMatch(
- GURL("http://www.site.com/anonymous/folder/subfolder"));
- EXPECT_TRUE(match);
- if (match) {
- EXPECT_EQ(Blacklist::kDontSendUserAgent|Blacklist::kDontSendReferrer,
- match->attributes());
- EXPECT_EQ(1U, match->entries().size());
- delete match;
- }
-
- // No matches for URLs without query string
- match = blacklist->FindMatch(GURL("http://badparam.com/"));
- EXPECT_FALSE(match);
- if (match)
- delete match;
-
- match = blacklist->FindMatch(GURL("http://script.bad.org/"));
- EXPECT_FALSE(match);
- if (match)
- delete match;
-
- // Expected rule matches.
- match = blacklist->FindMatch(GURL("http://host.com/script?q=x"));
- EXPECT_TRUE(match);
- if (match) {
- EXPECT_EQ(Blacklist::kBlockAll, match->attributes());
- EXPECT_EQ(1U, match->entries().size());
- delete match;
- }
-
- match = blacklist->FindMatch(GURL("http://host.com/img?badparam=x"));
- EXPECT_TRUE(match);
- if (match) {
- EXPECT_EQ(Blacklist::kBlockAll, match->attributes());
- EXPECT_EQ(1U, match->entries().size());
- delete match;
- }
-
- // Whitelisting tests.
- match = blacklist->FindMatch(GURL("http://www.site.com/bad/url/good"));
- EXPECT_TRUE(match);
- if (match) {
- EXPECT_EQ(0U, match->attributes());
- EXPECT_EQ(1U, match->entries().size());
- delete match;
- }
-
- // StripCookies Test. Note that "\r\n" line terminators are used
- // because the underlying net util uniformizes those when stripping
- // headers.
- std::string header1("Host: www.example.com\r\n");
- std::string header2("Upgrade: TLS/1.0, HTTP/1.1\r\n"
- "Connection: Upgrade\r\n");
- std::string header3("Date: Mon, 12 Mar 2001 19:20:33 GMT\r\n"
- "Expires: Mon, 12 Mar 2001 19:20:33 GMT\r\n"
- "Content-Type: text/html\r\n"
- "Set-Cookie: B=460soc0taq8c1&b=2; "
- "expires=Thu, 15 Apr 2010 20:00:00 GMT; path=/;\r\n");
- std::string header4("Date: Mon, 12 Mar 2001 19:20:33 GMT\r\n"
- "Expires: Mon, 12 Mar 2001 19:20:33 GMT\r\n"
- "Content-Type: text/html\r\n");
-
- EXPECT_TRUE(header1 == Blacklist::StripCookies(header1));
- EXPECT_TRUE(header2 == Blacklist::StripCookies(header2));
- EXPECT_TRUE(header4 == Blacklist::StripCookies(header3));
-
- // GetURLAsLookupString Test.
- std::string url_spec1("example.com/some/path");
- std::string url_spec2("example.com/script?param=1");
-
- EXPECT_TRUE(url_spec1 == Blacklist::GetURLAsLookupString(
- GURL("http://example.com/some/path")));
- EXPECT_TRUE(url_spec1 == Blacklist::GetURLAsLookupString(
- GURL("ftp://example.com/some/path")));
- EXPECT_TRUE(url_spec1 == Blacklist::GetURLAsLookupString(
- GURL("http://example.com:8080/some/path")));
- EXPECT_TRUE(url_spec1 == Blacklist::GetURLAsLookupString(
- GURL("http://user:login@example.com/some/path")));
- EXPECT_TRUE(url_spec2 == Blacklist::GetURLAsLookupString(
- GURL("http://example.com/script?param=1")));
-}
-
-TEST_F(BlacklistTest, PatternMatch) {
- // @ matches all but empty strings.
- EXPECT_TRUE(Blacklist::Matches("@", "foo.com"));
- EXPECT_TRUE(Blacklist::Matches("@", "path"));
- EXPECT_TRUE(Blacklist::Matches("@", "foo.com/path"));
- EXPECT_TRUE(Blacklist::Matches("@", "x"));
- EXPECT_FALSE(Blacklist::Matches("@", ""));
- EXPECT_FALSE(Blacklist::Matches("@", std::string()));
-
- // Prefix match.
- EXPECT_TRUE(Blacklist::Matches("prefix@", "prefix.com"));
- EXPECT_TRUE(Blacklist::Matches("prefix@", "prefix.com/path"));
- EXPECT_TRUE(Blacklist::Matches("prefix@", "prefix/path"));
- EXPECT_TRUE(Blacklist::Matches("prefix@", "prefix/prefix"));
- EXPECT_FALSE(Blacklist::Matches("prefix@", "prefix"));
- EXPECT_FALSE(Blacklist::Matches("prefix@", "Xprefix"));
- EXPECT_FALSE(Blacklist::Matches("prefix@", "Y.Xprefix"));
- EXPECT_FALSE(Blacklist::Matches("prefix@", "Y/Xprefix"));
-
- // Postfix match.
- EXPECT_TRUE(Blacklist::Matches("@postfix", "something.postfix"));
- EXPECT_TRUE(Blacklist::Matches("@postfix", "something/postfix"));
- EXPECT_TRUE(Blacklist::Matches("@postfix", "foo.com/something/postfix"));
- EXPECT_FALSE(Blacklist::Matches("@postfix", "postfix"));
- EXPECT_FALSE(Blacklist::Matches("@postfix", "postfixZ"));
- EXPECT_FALSE(Blacklist::Matches("@postfix", "postfixZ.Y"));
-
- // Infix matches.
- EXPECT_TRUE(Blacklist::Matches("@evil@", "www.evil.com"));
- EXPECT_TRUE(Blacklist::Matches("@evil@", "www.evil.com/whatever"));
- EXPECT_TRUE(Blacklist::Matches("@evil@", "www.whatever.com/evilpath"));
- EXPECT_TRUE(Blacklist::Matches("@evil@", "www.evil.whatever.com"));
- EXPECT_FALSE(Blacklist::Matches("@evil@", "evil"));
- EXPECT_FALSE(Blacklist::Matches("@evil@", "evil/"));
- EXPECT_FALSE(Blacklist::Matches("@evil@", "/evil"));
-
- // Outfix matches.
- EXPECT_TRUE(Blacklist::Matches("really@bad", "really/bad"));
- EXPECT_TRUE(Blacklist::Matches("really@bad", "really.com/bad"));
- EXPECT_TRUE(Blacklist::Matches("really@bad", "really.com/path/bad"));
- EXPECT_TRUE(Blacklist::Matches("really@bad", "really.evil.com/path/bad"));
- EXPECT_FALSE(Blacklist::Matches("really@bad", "really.bad.com"));
- EXPECT_FALSE(Blacklist::Matches("really@bad", "reallybad"));
- EXPECT_FALSE(Blacklist::Matches("really@bad", ".reallybad"));
- EXPECT_FALSE(Blacklist::Matches("really@bad", "reallybad."));
- EXPECT_FALSE(Blacklist::Matches("really@bad", "really.bad."));
- EXPECT_FALSE(Blacklist::Matches("really@bad", ".really.bad"));
-}
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index e9b76d9..6bd2104 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -47,7 +47,6 @@
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/password_manager/password_store_default.h"
#include "chrome/browser/pref_value_store.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
@@ -546,10 +545,6 @@ class OffTheRecordProfileImpl : public Profile,
return profile_->GetGeolocationPermissionContext();
}
- virtual Blacklist* GetPrivacyBlacklist() {
- return profile_->GetPrivacyBlacklist();
- }
-
virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() {
return profile_->GetUserStyleSheetWatcher();
}
@@ -1254,15 +1249,6 @@ GeolocationPermissionContext* ProfileImpl::GetGeolocationPermissionContext() {
return geolocation_permission_context_.get();
}
-Blacklist* ProfileImpl::GetPrivacyBlacklist() {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnablePrivacyBlacklists))
- return NULL;
- if (!privacy_blacklist_.get())
- privacy_blacklist_ = new Blacklist(GetPrefs());
- return privacy_blacklist_.get();
-}
-
UserStyleSheetWatcher* ProfileImpl::GetUserStyleSheetWatcher() {
if (!user_style_sheet_watcher_.get()) {
user_style_sheet_watcher_ = new UserStyleSheetWatcher(GetPath());
diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h
index f493dac..77fc45f 100644
--- a/chrome/browser/profile.h
+++ b/chrome/browser/profile.h
@@ -37,7 +37,6 @@ class DatabaseTracker;
class AutocompleteClassifier;
class BackgroundContentsService;
-class Blacklist;
class BookmarkModel;
class BrowserThemeProvider;
class ChromeURLRequestContextGetter;
@@ -332,9 +331,6 @@ class Profile {
// Returns the geolocation permission context for this profile.
virtual GeolocationPermissionContext* GetGeolocationPermissionContext() = 0;
- // Returns the Privacy Blacklist for this profile.
- virtual Blacklist* GetPrivacyBlacklist() = 0;
-
// Returns the user style sheet watcher.
virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() = 0;
@@ -525,7 +521,6 @@ class ProfileImpl : public Profile,
virtual HostZoomMap* GetHostZoomMap();
virtual GeolocationContentSettingsMap* GetGeolocationContentSettingsMap();
virtual GeolocationPermissionContext* GetGeolocationPermissionContext();
- virtual Blacklist* GetPrivacyBlacklist();
virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher();
virtual FindBarState* GetFindBarState();
virtual SessionService* GetSessionService();
@@ -623,7 +618,6 @@ class ProfileImpl : public Profile,
geolocation_content_settings_map_;
scoped_refptr<GeolocationPermissionContext>
geolocation_permission_context_;
- scoped_refptr<Blacklist> privacy_blacklist_;
scoped_refptr<UserStyleSheetWatcher> user_style_sheet_watcher_;
scoped_ptr<FindBarState> find_bar_state_;
scoped_refptr<DownloadManager> download_manager_;
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index 24d493f..998ad96d 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -28,8 +28,6 @@
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/net/url_request_tracking.h"
#include "chrome/browser/plugin_service.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "chrome/browser/privacy_blacklist/blacklist_request_info.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/async_resource_handler.h"
#include "chrome/browser/renderer_host/buffered_resource_handler.h"
@@ -481,14 +479,6 @@ void ResourceDispatcherHost::BeginRequest(
request, context ? context->appcache_service() : NULL, child_id,
request_data.appcache_host_id, request_data.resource_type);
- // Associate Privacy Blacklist information with the request.
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnablePrivacyBlacklists)) {
- request->SetUserData(&BlacklistRequestInfo::kURLRequestDataKey,
- new BlacklistRequestInfo(request_data.url, request_data.resource_type,
- context ? context->GetPrivacyBlacklist() : NULL));
- }
-
BeginRequestInternal(request);
}
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h
index 2ff2cce..e932642 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.h
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.h
@@ -23,7 +23,6 @@
#include "base/process.h"
#include "base/timer.h"
#include "chrome/common/child_process_info.h"
-#include "chrome/browser/privacy_blacklist/blacklist_interceptor.h"
#include "chrome/browser/renderer_host/resource_queue.h"
#include "ipc/ipc_message.h"
#include "net/url_request/url_request.h"
@@ -435,9 +434,6 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
// We own the save file manager.
scoped_refptr<SaveFileManager> save_file_manager_;
- // Handles requests blocked by privacy blacklists.
- BlacklistInterceptor blacklist_interceptor_;
-
scoped_refptr<UserScriptListener> user_script_listener_;
scoped_refptr<SafeBrowsingService> safe_browsing_;
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index c78b935..6b56ab1 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -39,8 +39,6 @@
#include "chrome/browser/pref_service.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/printer_query.h"
-#include "chrome/browser/privacy_blacklist/blacklist.h"
-#include "chrome/browser/privacy_blacklist/blacklist_ui.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/audio_renderer_host.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
@@ -159,15 +157,6 @@ void RenderParamsFromPrintSettings(const printing::PrintSettings& settings,
#endif
}
-Blacklist::Match* GetPrivacyBlacklistMatchForURL(
- const GURL& url, ChromeURLRequestContext* context) {
- const Blacklist* blacklist = context->GetPrivacyBlacklist();
- // TODO(phajdan.jr): DCHECK(blacklist_manager) when blacklists are stable.
- if (!blacklist)
- return NULL;
- return blacklist->FindMatch(url);
-}
-
class SetCookieCompletion : public net::CompletionCallback {
public:
SetCookieCompletion(int render_process_id,
@@ -394,10 +383,6 @@ ResourceMessageFilter::~ResourceMessageFilter() {
// Called on the IPC thread:
void ResourceMessageFilter::OnFilterAdded(IPC::Channel* channel) {
channel_ = channel;
-
- // Add the observers to intercept.
- registrar_.Add(this, NotificationType::BLACKLIST_NONVISUAL_RESOURCE_BLOCKED,
- NotificationService::AllSources());
}
// Called on the IPC thread:
@@ -676,11 +661,6 @@ void ResourceMessageFilter::OnSetCookie(const IPC::Message& message,
const std::string& cookie) {
ChromeURLRequestContext* context = GetRequestContextForURL(url);
- scoped_ptr<Blacklist::Match> match(
- GetPrivacyBlacklistMatchForURL(url, context));
- if (match.get() && (match->attributes() & Blacklist::kBlockCookies))
- return;
-
SetCookieCompletion* callback =
new SetCookieCompletion(id(), message.routing_id(), url, cookie, context);
@@ -1314,15 +1294,6 @@ void ResourceMessageFilter::OnUpdateSpellingPanelWithMisspelledWord(
SpellCheckerPlatform::UpdateSpellingPanelWithMisspelledWord(word);
}
-void ResourceMessageFilter::Observe(NotificationType type,
- const NotificationSource &source,
- const NotificationDetails &details) {
- if (type == NotificationType::BLACKLIST_NONVISUAL_RESOURCE_BLOCKED) {
- BlacklistUI::OnNonvisualContentBlocked(
- Details<const URLRequest>(details).ptr());
- }
-}
-
void ResourceMessageFilter::OnDnsPrefetch(
const std::vector<std::string>& hostnames) {
chrome_browser_net::DnsPrefetchList(hostnames);
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 384f412..7b73450 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -25,7 +25,6 @@
#include "chrome/browser/net/resolve_proxy_msg_helper.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/common/nacl_types.h"
-#include "chrome/common/notification_registrar.h"
#include "chrome/common/window_container_type.h"
#include "gfx/native_widget_types.h"
#include "gfx/rect.h"
@@ -77,7 +76,6 @@ struct ViewHostMsg_DidPrintPage_Params;
class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
public ResourceDispatcherHost::Receiver,
- public NotificationObserver,
public ResolveProxyMsgHelper::Delegate {
public:
// Create the filter.
@@ -112,11 +110,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
return next_route_id_callback_.get();
}
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
// Returns either the extension URLRequestContext or regular URLRequestContext
// depending on whether |url| is an extension URL.
// Only call on the IO thread.
@@ -371,8 +364,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
// thread.
static Clipboard* GetClipboard();
- NotificationRegistrar registrar_;
-
// The channel associated with the renderer connection. This pointer is not
// owned by this class.
IPC::Channel* channel_;
diff --git a/chrome/browser/resources/privacy_blacklist_block.html b/chrome/browser/resources/privacy_blacklist_block.html
deleted file mode 100644
index 3836d79..0000000
--- a/chrome/browser/resources/privacy_blacklist_block.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<!DOCTYPE html>
-<html id="template_root" i18n-values="dir:textdirection">
-<head>
-<title i18n-content="title"></title>
-<style>
-body {
- font-family:Helvetica,Arial,sans-serif;
- background-color:#FFCC00;
- margin:0px;
-}
-.background {
- position:absolute;
- width:100%;
- height:100%;
-}
-.cell {
- padding:20px;
-}
-.box {
- width:80%;
- background-color:white;
- color:black;
- font-size:10pt;
- line-height:16pt;
- text-align:left;
- padding:10px;
- position:relative;
-}
-</style>
-</head>
-<body>
-<table width="100%" cellspacing="0" cellpadding="0">
- <td class="cell" valign="middle" align="center">
- <div class="box">
- <div class="icon"><img src="phishing_icon.png" alt="Blocked Element Icon"/></div>
- <p i18n-content="message"></p>
- <ul style="list-style-type: none">
- <li><a i18n-values="href: url" i18n-content="name" target="_blank"></a></li>
- </ul>
- </div>
- </td>
-</table>
-</body>
-</html>
diff --git a/chrome/browser/resources/privacy_blacklist_block.png b/chrome/browser/resources/privacy_blacklist_block.png
deleted file mode 100644
index b23e76b..0000000
--- a/chrome/browser/resources/privacy_blacklist_block.png
+++ /dev/null
Binary files differ
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 16f8d95..2679aa3 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1935,14 +1935,6 @@
'browser/printing/printer_query.h',
'browser/printing/cloud_print/cloud_print_proxy_service.cc',
'browser/printing/cloud_print/cloud_print_proxy_service.h',
- 'browser/privacy_blacklist/blacklist.h',
- 'browser/privacy_blacklist/blacklist.cc',
- 'browser/privacy_blacklist/blacklist_interceptor.h',
- 'browser/privacy_blacklist/blacklist_interceptor.cc',
- 'browser/privacy_blacklist/blacklist_request_info.h',
- 'browser/privacy_blacklist/blacklist_request_info.cc',
- 'browser/privacy_blacklist/blacklist_ui.h',
- 'browser/privacy_blacklist/blacklist_ui.cc',
'browser/process_info_snapshot_mac.cc',
'browser/process_info_snapshot.h',
'browser/process_singleton.h',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index b2174d3..ea2e142 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -905,8 +905,6 @@
'browser/preferences_mock_mac.h',
'browser/printing/print_dialog_cloud_unittest.cc',
'browser/printing/print_job_unittest.cc',
- 'browser/privacy_blacklist/blacklist_interceptor_unittest.cc',
- 'browser/privacy_blacklist/blacklist_unittest.cc',
'browser/process_info_snapshot_mac_unittest.cc',
'browser/profile_manager_unittest.cc',
'browser/renderer_host/audio_renderer_host_unittest.cc',
@@ -2123,7 +2121,6 @@
'../webkit/support/webkit_support.gyp:glue',
],
'sources': [
- 'browser/privacy_blacklist/blacklist_perftest.cc',
'browser/safe_browsing/filter_false_positive_perftest.cc',
'browser/visitedlink_perftest.cc',
'common/json_value_serializer_perftest.cc',
diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc
index 4d2e442a..47f0d52 100644
--- a/chrome/common/chrome_constants.cc
+++ b/chrome/common/chrome_constants.cc
@@ -99,7 +99,6 @@ const FilePath::CharType kTopSitesFilename[] = FPL("Top Sites");
const wchar_t kUserDataDirname[] = L"User Data";
const FilePath::CharType kUserScriptsDirname[] = FPL("User Scripts");
const FilePath::CharType kWebDataFilename[] = FPL("Web Data");
-const FilePath::CharType kPrivacyBlacklistFileName[] = FPL("Privacy Blacklist");
const FilePath::CharType kBookmarksFileName[] = FPL("Bookmarks");
const FilePath::CharType kHistoryBookmarksFileName[] =
FPL("Bookmarks From History");
diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h
index 2923928..a1efdbf 100644
--- a/chrome/common/chrome_constants.h
+++ b/chrome/common/chrome_constants.h
@@ -58,7 +58,6 @@ extern const wchar_t kUserDataDirname[];
extern const FilePath::CharType kUserScriptsDirname[];
extern const FilePath::CharType kWebDataFilename[];
extern const FilePath::CharType kBookmarksFileName[];
-extern const FilePath::CharType kPrivacyBlacklistFileName[];
extern const FilePath::CharType kHistoryBookmarksFileName[];
extern const FilePath::CharType kCustomDictionaryFileName[];
extern const FilePath::CharType kLoginDataFileName[];
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index dfbe77e..46f7c64 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -345,9 +345,6 @@ const char kEnablePreparsedJsCaching[] = "enable-preparsed-js-caching";
// Enable print preview (work in progress).
const char kEnablePrintPreview[] = "enable-print-preview";
-// Enable Privacy Blacklists.
-const char kEnablePrivacyBlacklists[] = "enable-privacy-blacklists";
-
// Enables StatsTable, logging statistics to a global named shared memory table.
const char kEnableStatsTable[] = "enable-stats-table";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index afb798a..6616048 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -113,7 +113,6 @@ extern const char kEnableNativeWebWorkers[];
extern const char kEnablePreparsedJsCaching[];
extern const char kEnablePreconnect[];
extern const char kEnablePrintPreview[];
-extern const char kEnablePrivacyBlacklists[];
extern const char kEnableStatsTable[];
extern const char kEnableSync[];
extern const char kEnableSyncAutofill[];
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index 3c96a1a..935d13d 100644
--- a/chrome/common/notification_type.h
+++ b/chrome/common/notification_type.h
@@ -874,13 +874,6 @@ class NotificationType {
// with the new visibility.
EXTENSION_APP_TOOLBAR_VISIBILITY_CHANGED,
- // Privacy Blacklist -------------------------------------------------------
-
- // Sent on the IO thread when a non-visual resource (like a cookie)
- // is blocked by a privacy blacklist. The details are a const URLRequest,
- // and the source is a const ChromeURLRequestContext.
- BLACKLIST_NONVISUAL_RESOURCE_BLOCKED,
-
// Debugging ---------------------------------------------------------------
// TODO(mpcomplete): Sent to diagnose a bug. Remove when fixed.
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index a7407a9..36fe1b5 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -472,9 +472,6 @@ const wchar_t kAutoFillPositiveUploadRate[] = L"autofill.positive_upload_rate";
// Double that indicates negative (for not matched forms) upload rate.
const wchar_t kAutoFillNegativeUploadRate[] = L"autofill.negative_upload_rate";
-// Dictionary that maps providers to lists of filter rules.
-const wchar_t kPrivacyFilterRules[] = L"profile.privacy_filter_rules";
-
// Boolean that is true when the tabstrip is to be laid out vertically down the
// side of the browser window.
const wchar_t kUseVerticalTabs[] = L"tabs.use_vertical_tabs";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 1241af3..a582cec 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -180,7 +180,6 @@ extern const wchar_t kAutoFillDialogPlacement[];
extern const wchar_t kAutoFillPositiveUploadRate[];
extern const wchar_t kAutoFillNegativeUploadRate[];
-extern const wchar_t kPrivacyFilterRules[];
extern const wchar_t kUseVerticalTabs[];
extern const wchar_t kEnableTranslate[];
extern const wchar_t kPinnedTabs[];
diff --git a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/blacklist.pbl b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/blacklist.pbl
deleted file mode 100644
index b9dc8d2..0000000
--- a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/blacklist.pbl
+++ /dev/null
@@ -1,12 +0,0 @@
-[Chromium::PrivacyBlacklist]
-|Name: AnnoyingAds
-|URL: http://www.ads.tv
-
-# Block Ads by servers
-annoying.ads.tv/@ => kBlockAll
-
-# Block Ads by name
-@/annoying/120x600.jpg => kBlockAll
-
-# Block Ads by path
-@/annoying_ads/@ => kBlockAll
diff --git a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json
index 5f32ed9..7362c99 100644
--- a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json
+++ b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json
@@ -27,6 +27,5 @@
"matches": ["http://*.news.com/*"],
"js": ["js_files/script3.js"]
}
- ],
- "privacy_blacklists": ["blacklist.pbl"]
+ ]
}
diff --git a/chrome/test/data/profiles/blacklist_prefs/Preferences b/chrome/test/data/profiles/blacklist_prefs/Preferences
deleted file mode 100644
index e63e8c3..0000000
--- a/chrome/test/data/profiles/blacklist_prefs/Preferences
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "profile": {
- "privacy_filter_rules": {
- "provider1": {
- "name": "Sample",
- "url": "http://www.example.com",
- "entries": [
- {
- "pattern": "@poor-security-site.com",
- "attributes": 16,
- "exception": false
- }, {
- "pattern": "@.ad-serving-place.com",
- "attributes": 2,
- "exception": false
- }, {
- "pattern": "www.site.com/anonymous/folder/@",
- "attributes": 12,
- "exception": false
- }, {
- "pattern": "www.site.com/bad/url",
- "attributes": 1,
- "exception": false
- }, {
- "pattern": "@/script?@",
- "attributes": 1,
- "exception": false
- }, {
- "pattern": "@?badparam@",
- "attributes": 1,
- "exception": false
- }, {
- "pattern": "www.site.com/bad/url/good",
- "attributes": 1,
- "exception": true
- }
- ]
- }
- }
- }
-}
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index b2b572b..fda2f57 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -198,7 +198,6 @@ class TestingProfile : public Profile {
virtual URLRequestContextGetter* GetRequestContextForExtensions();
virtual net::SSLConfigService* GetSSLConfigService() { return NULL; }
- virtual Blacklist* GetPrivacyBlacklist() { return NULL; }
virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() { return NULL; }
virtual FindBarState* GetFindBarState() {
if (!find_bar_state_.get())
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index 36b42b3..51a6066 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -112,20 +112,6 @@ class URLRequestContext
referrer_charset_ = charset;
}
- // Called before adding cookies to requests. Returns true if cookie can
- // be added to the request. The cookie might still be modified though.
- virtual bool InterceptRequestCookies(const URLRequest* request,
- const std::string& cookies) const {
- return true;
- }
-
- // Called before adding cookies from respones to the cookie monster. Returns
- // true if the cookie can be added. The cookie might still be modified though.
- virtual bool InterceptResponseCookie(const URLRequest* request,
- const std::string& cookie) const {
- return true;
- }
-
protected:
friend class base::RefCountedThreadSafe<URLRequestContext>;
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 7041b8d..4f44f2e3 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -448,8 +448,7 @@ void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) {
std::string cookies =
request_->context()->cookie_store()->GetCookiesWithOptions(
request_->url(), options);
- if (request_->context()->InterceptRequestCookies(request_, cookies) &&
- !cookies.empty()) {
+ if (!cookies.empty()) {
request_info_.extra_headers.SetHeader(
net::HttpRequestHeaders::kCookie, cookies);
}
@@ -785,10 +784,8 @@ void URLRequestHttpJob::FetchResponseCookies(
std::string value;
void* iter = NULL;
- while (response_info->headers->EnumerateHeader(&iter, name, &value)) {
- if (request_->context()->InterceptResponseCookie(request_, value))
- cookies->push_back(value);
- }
+ while (response_info->headers->EnumerateHeader(&iter, name, &value))
+ cookies->push_back(value);
}
class HTTPSProberDelegate : public net::HTTPSProberDelegate {