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

Unified Diff: chrome/browser/managed_mode/managed_mode_url_filter.cc

Issue 11299035: Support manual (white|black)list, previewing and allowing after interstitial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor changes Created 7 years, 11 months 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
« no previous file with comments | « chrome/browser/managed_mode/managed_mode_url_filter.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/managed_mode/managed_mode_url_filter.cc
diff --git a/chrome/browser/managed_mode/managed_mode_url_filter.cc b/chrome/browser/managed_mode/managed_mode_url_filter.cc
index a77e180d4b47ca9797b226bc147ddb66d0d9f0b6..321eebe65b14b863aba5ebe3c8e848dfcc705f58 100644
--- a/chrome/browser/managed_mode/managed_mode_url_filter.cc
+++ b/chrome/browser/managed_mode/managed_mode_url_filter.cc
@@ -159,7 +159,13 @@ scoped_ptr<ManagedModeURLFilter::Contents> LoadWhitelistsOnBlockingPoolThread(
ManagedModeURLFilter::ManagedModeURLFilter()
: ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
default_behavior_(ALLOW),
- contents_(new Contents()) {
+ contents_(new Contents()),
+ url_manual_list_allow_(new policy::URLBlacklist()),
+ url_manual_list_block_(new policy::URLBlacklist()) {
+ // Set empty manual lists in the begining.
+ scoped_ptr<base::ListValue> whitelist(new base::ListValue());
+ scoped_ptr<base::ListValue> blacklist(new base::ListValue());
+ SetManualLists(whitelist.Pass(), blacklist.Pass());
// Detach from the current thread so we can be constructed on a different
// thread than the one where we're used.
DetachFromThread();
@@ -191,6 +197,14 @@ ManagedModeURLFilter::GetFilteringBehaviorForURL(const GURL& url) const {
return ALLOW;
#endif
+ // TODO(sergiu): Find a less confusing way to do this. Options include
+ // renaming the functions in policy::URLBlacklist or adding a function that
+ // checks if the URL is allowed instead of blocked.
+ if (!url_manual_list_allow_->IsURLBlocked(url))
+ return ALLOW;
+ if (url_manual_list_block_->IsURLBlocked(url))
+ return BLOCK;
+
// Check the list of URL patterns.
std::set<URLMatcherConditionSet::ID> matching_ids =
contents_->url_matcher.MatchURL(url);
@@ -266,6 +280,46 @@ void ManagedModeURLFilter::SetFromPatterns(
weak_ptr_factory_.GetWeakPtr(), continuation));
}
+void ManagedModeURLFilter::SetManualLists(scoped_ptr<ListValue> whitelist,
+ scoped_ptr<ListValue> blacklist){
+ DCHECK(CalledOnValidThread());
+ url_manual_list_block_.reset(new policy::URLBlacklist);
+ url_manual_list_allow_.reset(new policy::URLBlacklist);
+ url_manual_list_block_->Block(blacklist.get());
+ ListValue all_sites;
+ all_sites.Append(new base::StringValue("*"));
+ url_manual_list_allow_->Allow(whitelist.get());
+ url_manual_list_allow_->Block(&all_sites);
+
+ // Debug
+ DVLOG(1) << "Loaded whitelist: ";
+ for (ListValue::iterator it = whitelist->begin();
+ it != whitelist->end(); ++it){
+ std::string item;
+ (*it)->GetAsString(&item);
+ DVLOG(1) << item;
+ }
+ DVLOG(1) << "Loaded blacklist: ";
+ for (ListValue::iterator it = blacklist->begin();
+ it != blacklist->end(); ++it){
+ std::string item;
+ (*it)->GetAsString(&item);
+ DVLOG(1) << item;
+ }
+}
+
+void ManagedModeURLFilter::AddURLPatternToManualList(
+ const bool is_whitelist,
+ const std::string& url) {
+ DCHECK(CalledOnValidThread());
+ ListValue list;
+ list.AppendString(url);
+ if (is_whitelist)
+ url_manual_list_allow_->Allow(&list);
+ else
+ url_manual_list_block_->Block(&list);
+}
+
void ManagedModeURLFilter::SetContents(const base::Closure& continuation,
scoped_ptr<Contents> contents) {
DCHECK(CalledOnValidThread());
« no previous file with comments | « chrome/browser/managed_mode/managed_mode_url_filter.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698