diff options
author | idanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-23 18:02:23 +0000 |
---|---|---|
committer | idanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-23 18:02:23 +0000 |
commit | eaadd905fd0d3e3e0496f229a5aaa3e3982002a4 (patch) | |
tree | 7174b1009f01eb2ee982c1d834c4d052ff916904 /chrome/browser/privacy_blacklist/blacklist.cc | |
parent | c86d472e35440254cf860f40c40aaaf45992bfdc (diff) | |
download | chromium_src-eaadd905fd0d3e3e0496f229a5aaa3e3982002a4.zip chromium_src-eaadd905fd0d3e3e0496f229a5aaa3e3982002a4.tar.gz chromium_src-eaadd905fd0d3e3e0496f229a5aaa3e3982002a4.tar.bz2 |
Privacy Blacklist SketelonAdded code hooks to serve as place holders for the implementationof the privacy blacklist. The --privacy-blacklist option was addedwhich will eventually is used to activate the code.This is work-in-progress code which effectively makes a couple morepointer-checks when the --privacy-blacklist is not specified. Whenit is specified, some of the blacklist code is executed but theblacklist is always empty and therefore has no impact on browsing.
BUG=none
TEST=Blacklist*
Review URL: http://codereview.chromium.org/119313
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19033 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/privacy_blacklist/blacklist.cc')
-rw-r--r-- | chrome/browser/privacy_blacklist/blacklist.cc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/chrome/browser/privacy_blacklist/blacklist.cc b/chrome/browser/privacy_blacklist/blacklist.cc new file mode 100644 index 0000000..8b575a8 --- /dev/null +++ b/chrome/browser/privacy_blacklist/blacklist.cc @@ -0,0 +1,72 @@ +// 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 <string> + +namespace { + +bool matches(std::string pattern, std::string url) { + return url.find(pattern) != std::string::npos; +} + +} + +// Value is not important, here just that the object has an address. +const void* const Blacklist::kRequestDataKey = 0; + +bool Blacklist::Entry::MatchType(const std::string& type) const { + return std::find(types_->begin(), types_->end(), type) != types_->end(); +} + +bool Blacklist::Entry::IsBlocked(const GURL& url) const { + return (attributes_ & kBlockAll) || + ((attributes_ & kBlockUnsecure) && !url.SchemeIsSecure()); +} + +Blacklist::Entry::Entry(const std::string& pattern, unsigned int attributes) + : pattern_(pattern), attributes_(attributes) {} + +void Blacklist::Entry::AddType(const std::string& type) { + types_->push_back(type); +} + +Blacklist::Blacklist(const FilePath& file) { + // TODO(idanan): Do something here. +} + +Blacklist::~Blacklist() { + for (std::vector<Entry*>::iterator i = blacklist_.begin(); + i != blacklist_.end(); ++i) + delete *i; +} + +// Returns a pointer to the Blacklist-owned entry which matches the given +// URL. If no matching Entry is found, returns null. +const Blacklist::Entry* Blacklist::findMatch(const GURL& url) const { + for (std::vector<Entry*>::const_iterator i = blacklist_.begin(); + i != blacklist_.end(); ++i) + if (matches((*i)->pattern(), url.spec())) + return *i; + return 0; +} + +std::string Blacklist::StripCookies(const std::string& header) { + // TODO(idanan): Implement this. + return header; +} + +std::string Blacklist::StripCookieExpiry(const std::string& cookie) { + std::string::size_type start = cookie.find("; expires="); + if (start != std::string::npos) { + std::string::size_type finish = cookie.find(";", start+1); + std::string session_cookie(cookie, 0, start); + if (finish != std::string::npos) + session_cookie.append(cookie.substr(finish)); + return session_cookie; + } + return cookie; +} |