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

Unified Diff: chrome/browser/supervised_user/supervised_user_url_filter.cc

Issue 335833003: Rename "managed (mode|user)" to "supervised user" (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments (+ a few other cleanups) Created 6 years, 6 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
Index: chrome/browser/supervised_user/supervised_user_url_filter.cc
diff --git a/chrome/browser/managed_mode/managed_mode_url_filter.cc b/chrome/browser/supervised_user/supervised_user_url_filter.cc
similarity index 81%
rename from chrome/browser/managed_mode/managed_mode_url_filter.cc
rename to chrome/browser/supervised_user/supervised_user_url_filter.cc
index efd9645d32f34d5c3a193a0d6ef7cf63590f885a..ca285e2c44d8e3b0967ed12d7d2cfc6505bdfa7d 100644
--- a/chrome/browser/managed_mode/managed_mode_url_filter.cc
+++ b/chrome/browser/supervised_user/supervised_user_url_filter.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "base/containers/hash_tables.h"
#include "base/files/file_path.h"
@@ -28,11 +28,11 @@ using policy::URLBlacklist;
using url_matcher::URLMatcher;
using url_matcher::URLMatcherConditionSet;
-struct ManagedModeURLFilter::Contents {
+struct SupervisedUserURLFilter::Contents {
URLMatcher url_matcher;
std::map<URLMatcherConditionSet::ID, int> matcher_site_map;
base::hash_multimap<std::string, int> hash_site_map;
- std::vector<ManagedModeSiteList::Site> sites;
+ std::vector<SupervisedUserSiteList::Site> sites;
};
namespace {
@@ -50,7 +50,7 @@ const char* kFilteredSchemes[] = {
// This class encapsulates all the state that is required during construction of
-// a new ManagedModeURLFilter::Contents.
+// a new SupervisedUserURLFilter::Contents.
class FilterBuilder {
public:
FilterBuilder();
@@ -63,20 +63,20 @@ class FilterBuilder {
void AddHostnameHash(const std::string& hash, int site_id);
// Adds all the sites in |site_list|, with URL patterns and hostname hashes.
- void AddSiteList(ManagedModeSiteList* site_list);
+ void AddSiteList(SupervisedUserSiteList* site_list);
- // Finalizes construction of the ManagedModeURLFilter::Contents and returns
+ // Finalizes construction of the SupervisedUserURLFilter::Contents and returns
// them. This method should be called before this object is destroyed.
- scoped_ptr<ManagedModeURLFilter::Contents> Build();
+ scoped_ptr<SupervisedUserURLFilter::Contents> Build();
private:
- scoped_ptr<ManagedModeURLFilter::Contents> contents_;
+ scoped_ptr<SupervisedUserURLFilter::Contents> contents_;
URLMatcherConditionSet::Vector all_conditions_;
URLMatcherConditionSet::ID matcher_id_;
};
FilterBuilder::FilterBuilder()
- : contents_(new ManagedModeURLFilter::Contents()),
+ : contents_(new SupervisedUserURLFilter::Contents()),
matcher_id_(0) {}
FilterBuilder::~FilterBuilder() {
@@ -114,13 +114,13 @@ void FilterBuilder::AddHostnameHash(const std::string& hash, int site_id) {
site_id));
}
-void FilterBuilder::AddSiteList(ManagedModeSiteList* site_list) {
- std::vector<ManagedModeSiteList::Site> sites;
+void FilterBuilder::AddSiteList(SupervisedUserSiteList* site_list) {
+ std::vector<SupervisedUserSiteList::Site> sites;
site_list->GetSites(&sites);
int site_id = contents_->sites.size();
- for (std::vector<ManagedModeSiteList::Site>::const_iterator it =
+ for (std::vector<SupervisedUserSiteList::Site>::const_iterator it =
sites.begin(); it != sites.end(); ++it) {
- const ManagedModeSiteList::Site& site = *it;
+ const SupervisedUserSiteList::Site& site = *it;
contents_->sites.push_back(site);
for (std::vector<std::string>::const_iterator pattern_it =
@@ -139,13 +139,13 @@ void FilterBuilder::AddSiteList(ManagedModeSiteList* site_list) {
}
}
-scoped_ptr<ManagedModeURLFilter::Contents> FilterBuilder::Build() {
+scoped_ptr<SupervisedUserURLFilter::Contents> FilterBuilder::Build() {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
contents_->url_matcher.AddConditionSets(all_conditions_);
return contents_.Pass();
}
-scoped_ptr<ManagedModeURLFilter::Contents> CreateWhitelistFromPatterns(
+scoped_ptr<SupervisedUserURLFilter::Contents> CreateWhitelistFromPatterns(
const std::vector<std::string>& patterns) {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
@@ -159,12 +159,13 @@ scoped_ptr<ManagedModeURLFilter::Contents> CreateWhitelistFromPatterns(
return builder.Build();
}
-scoped_ptr<ManagedModeURLFilter::Contents> LoadWhitelistsOnBlockingPoolThread(
- ScopedVector<ManagedModeSiteList> site_lists) {
+scoped_ptr<SupervisedUserURLFilter::Contents>
+LoadWhitelistsOnBlockingPoolThread(
+ ScopedVector<SupervisedUserSiteList> site_lists) {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
FilterBuilder builder;
- for (ScopedVector<ManagedModeSiteList>::iterator it = site_lists.begin();
+ for (ScopedVector<SupervisedUserSiteList>::iterator it = site_lists.begin();
it != site_lists.end(); ++it) {
builder.AddSiteList(*it);
}
@@ -174,7 +175,7 @@ scoped_ptr<ManagedModeURLFilter::Contents> LoadWhitelistsOnBlockingPoolThread(
} // namespace
-ManagedModeURLFilter::ManagedModeURLFilter()
+SupervisedUserURLFilter::SupervisedUserURLFilter()
: default_behavior_(ALLOW),
contents_(new Contents()) {
// Detach from the current thread so we can be constructed on a different
@@ -182,20 +183,20 @@ ManagedModeURLFilter::ManagedModeURLFilter()
DetachFromThread();
}
-ManagedModeURLFilter::~ManagedModeURLFilter() {
+SupervisedUserURLFilter::~SupervisedUserURLFilter() {
DCHECK(CalledOnValidThread());
}
// static
-ManagedModeURLFilter::FilteringBehavior
-ManagedModeURLFilter::BehaviorFromInt(int behavior_value) {
+SupervisedUserURLFilter::FilteringBehavior
+SupervisedUserURLFilter::BehaviorFromInt(int behavior_value) {
DCHECK_GE(behavior_value, ALLOW);
DCHECK_LE(behavior_value, BLOCK);
return static_cast<FilteringBehavior>(behavior_value);
}
// static
-GURL ManagedModeURLFilter::Normalize(const GURL& url) {
+GURL SupervisedUserURLFilter::Normalize(const GURL& url) {
GURL normalized_url = url;
GURL::Replacements replacements;
// Strip username, password, query, and ref.
@@ -207,7 +208,7 @@ GURL ManagedModeURLFilter::Normalize(const GURL& url) {
}
// static
-bool ManagedModeURLFilter::HasFilteredScheme(const GURL& url) {
+bool SupervisedUserURLFilter::HasFilteredScheme(const GURL& url) {
for (size_t i = 0; i < arraysize(kFilteredSchemes); ++i) {
if (url.scheme() == kFilteredSchemes[i])
return true;
@@ -221,8 +222,8 @@ std::string GetHostnameHash(const GURL& url) {
}
// static
-bool ManagedModeURLFilter::HostMatchesPattern(const std::string& host,
- const std::string& pattern) {
+bool SupervisedUserURLFilter::HostMatchesPattern(const std::string& host,
+ const std::string& pattern) {
std::string trimmed_pattern = pattern;
std::string trimmed_host = host;
if (EndsWith(pattern, ".*", true)) {
@@ -258,8 +259,8 @@ bool ManagedModeURLFilter::HostMatchesPattern(const std::string& host,
return trimmed_host == trimmed_pattern;
}
-ManagedModeURLFilter::FilteringBehavior
-ManagedModeURLFilter::GetFilteringBehaviorForURL(const GURL& url) const {
+SupervisedUserURLFilter::FilteringBehavior
+SupervisedUserURLFilter::GetFilteringBehaviorForURL(const GURL& url) const {
DCHECK(CalledOnValidThread());
// URLs with a non-standard scheme (e.g. chrome://) are always allowed.
@@ -305,9 +306,9 @@ ManagedModeURLFilter::GetFilteringBehaviorForURL(const GURL& url) const {
return default_behavior_;
}
-void ManagedModeURLFilter::GetSites(
+void SupervisedUserURLFilter::GetSites(
const GURL& url,
- std::vector<ManagedModeSiteList::Site*>* sites) const {
+ std::vector<SupervisedUserSiteList::Site*>* sites) const {
std::set<URLMatcherConditionSet::ID> matching_ids =
contents_->url_matcher.MatchURL(url);
for (std::set<URLMatcherConditionSet::ID>::const_iterator it =
@@ -331,14 +332,14 @@ void ManagedModeURLFilter::GetSites(
}
}
-void ManagedModeURLFilter::SetDefaultFilteringBehavior(
+void SupervisedUserURLFilter::SetDefaultFilteringBehavior(
FilteringBehavior behavior) {
DCHECK(CalledOnValidThread());
default_behavior_ = behavior;
}
-void ManagedModeURLFilter::LoadWhitelists(
- ScopedVector<ManagedModeSiteList> site_lists) {
+void SupervisedUserURLFilter::LoadWhitelists(
+ ScopedVector<SupervisedUserSiteList> site_lists) {
DCHECK(CalledOnValidThread());
base::PostTaskAndReplyWithResult(
@@ -346,10 +347,10 @@ void ManagedModeURLFilter::LoadWhitelists(
FROM_HERE,
base::Bind(&LoadWhitelistsOnBlockingPoolThread,
base::Passed(&site_lists)),
- base::Bind(&ManagedModeURLFilter::SetContents, this));
+ base::Bind(&SupervisedUserURLFilter::SetContents, this));
}
-void ManagedModeURLFilter::SetFromPatterns(
+void SupervisedUserURLFilter::SetFromPatterns(
const std::vector<std::string>& patterns) {
DCHECK(CalledOnValidThread());
@@ -357,10 +358,10 @@ void ManagedModeURLFilter::SetFromPatterns(
BrowserThread::GetBlockingPool(),
FROM_HERE,
base::Bind(&CreateWhitelistFromPatterns, patterns),
- base::Bind(&ManagedModeURLFilter::SetContents, this));
+ base::Bind(&SupervisedUserURLFilter::SetContents, this));
}
-void ManagedModeURLFilter::SetManualHosts(
+void SupervisedUserURLFilter::SetManualHosts(
const std::map<std::string, bool>* host_map) {
DCHECK(CalledOnValidThread());
host_map_ = *host_map;
@@ -368,7 +369,7 @@ void ManagedModeURLFilter::SetManualHosts(
host_map->size(), 1, 1000, 50);
}
-void ManagedModeURLFilter::SetManualURLs(
+void SupervisedUserURLFilter::SetManualURLs(
const std::map<GURL, bool>* url_map) {
DCHECK(CalledOnValidThread());
url_map_ = *url_map;
@@ -376,15 +377,15 @@ void ManagedModeURLFilter::SetManualURLs(
url_map->size(), 1, 1000, 50);
}
-void ManagedModeURLFilter::AddObserver(Observer* observer) {
+void SupervisedUserURLFilter::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
-void ManagedModeURLFilter::RemoveObserver(Observer* observer) {
+void SupervisedUserURLFilter::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
-void ManagedModeURLFilter::SetContents(scoped_ptr<Contents> contents) {
+void SupervisedUserURLFilter::SetContents(scoped_ptr<Contents> contents) {
DCHECK(CalledOnValidThread());
contents_ = contents.Pass();
FOR_EACH_OBSERVER(Observer, observers_, OnSiteListUpdated());

Powered by Google App Engine
This is Rietveld 408576698