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

Unified Diff: chrome/browser/policy/url_blacklist_manager.cc

Issue 7941008: Cosmetic cleanups in chrome/browser/policy/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload was broken? Created 9 years, 3 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/policy/url_blacklist_manager.h ('k') | chrome/browser/policy/user_policy_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/url_blacklist_manager.cc
diff --git a/chrome/browser/policy/url_blacklist_manager.cc b/chrome/browser/policy/url_blacklist_manager.cc
index c68b7744a343bfcabb92466f287afdd6c654bd45..8cc32c7d3f718378e890f7becf7d22957332728f 100644
--- a/chrome/browser/policy/url_blacklist_manager.cc
+++ b/chrome/browser/policy/url_blacklist_manager.cc
@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "base/stl_util.h"
#include "base/string_number_conversions.h"
-#include "base/string_util.h"
#include "base/values.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -86,60 +85,6 @@ URLBlacklist::~URLBlacklist() {
STLDeleteValues(&host_filters_);
}
-void URLBlacklist::AddFilter(const std::string& filter, bool block) {
- std::string scheme;
- std::string host;
- uint16 port;
- std::string path;
- SchemeFlag flag;
- bool match_subdomains = true;
-
- if (!FilterToComponents(filter, &scheme, &host, &port, &path)) {
- LOG(WARNING) << "Invalid filter, ignoring: " << filter;
- return;
- }
-
- if (!SchemeToFlag(scheme, &flag)) {
- LOG(WARNING) << "Unsupported scheme in filter, ignoring filter: " << filter;
- return;
- }
-
- // Special syntax to disable subdomain matching.
- if (!host.empty() && host[0] == '.') {
- host.erase(0, 1);
- match_subdomains = false;
- }
-
- // Try to find an existing PathFilter with the same path prefix, port and
- // match_subdomains value.
- PathFilterList* list;
- HostFilterTable::iterator host_filter = host_filters_.find(host);
- if (host_filter == host_filters_.end()) {
- list = new PathFilterList;
- host_filters_[host] = list;
- } else {
- list = host_filter->second;
- }
- PathFilterList::iterator it;
- for (it = list->begin(); it != list->end(); ++it) {
- if (it->port == port && it->match_subdomains == match_subdomains &&
- it->path_prefix == path)
- break;
- }
- PathFilter* path_filter;
- if (it == list->end()) {
- list->push_back(PathFilter(path, port, match_subdomains));
- path_filter = &list->back();
- } else {
- path_filter = &(*it);
- }
-
- if (block)
- path_filter->blocked_schemes |= flag;
- else
- path_filter->allowed_schemes |= flag;
-}
-
void URLBlacklist::Block(const std::string& filter) {
AddFilter(filter, true);
}
@@ -295,6 +240,60 @@ bool URLBlacklist::FilterToComponents(const std::string& filter,
return true;
}
+void URLBlacklist::AddFilter(const std::string& filter, bool block) {
+ std::string scheme;
+ std::string host;
+ uint16 port;
+ std::string path;
+ SchemeFlag flag;
+ bool match_subdomains = true;
+
+ if (!FilterToComponents(filter, &scheme, &host, &port, &path)) {
+ LOG(WARNING) << "Invalid filter, ignoring: " << filter;
+ return;
+ }
+
+ if (!SchemeToFlag(scheme, &flag)) {
+ LOG(WARNING) << "Unsupported scheme in filter, ignoring filter: " << filter;
+ return;
+ }
+
+ // Special syntax to disable subdomain matching.
+ if (!host.empty() && host[0] == '.') {
+ host.erase(0, 1);
+ match_subdomains = false;
+ }
+
+ // Try to find an existing PathFilter with the same path prefix, port and
+ // match_subdomains value.
+ PathFilterList* list;
+ HostFilterTable::iterator host_filter = host_filters_.find(host);
+ if (host_filter == host_filters_.end()) {
+ list = new PathFilterList;
+ host_filters_[host] = list;
+ } else {
+ list = host_filter->second;
+ }
+ PathFilterList::iterator it;
+ for (it = list->begin(); it != list->end(); ++it) {
+ if (it->port == port && it->match_subdomains == match_subdomains &&
+ it->path_prefix == path)
+ break;
+ }
+ PathFilter* path_filter;
+ if (it == list->end()) {
+ list->push_back(PathFilter(path, port, match_subdomains));
+ path_filter = &list->back();
+ } else {
+ path_filter = &(*it);
+ }
+
+ if (block)
+ path_filter->blocked_schemes |= flag;
+ else
+ path_filter->allowed_schemes |= flag;
+}
+
URLBlacklistManager::URLBlacklistManager(PrefService* pref_service)
: ALLOW_THIS_IN_INITIALIZER_LIST(ui_method_factory_(this)),
pref_service_(pref_service),
« no previous file with comments | « chrome/browser/policy/url_blacklist_manager.h ('k') | chrome/browser/policy/user_policy_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698