Commit 61afb0b9 authored by Shimi Zhang's avatar Shimi Zhang Committed by Commit Bot

Migrate ProxyBypassRules to SchemeHostPortMatcher in TrustedSourcesManager

The usage of ProxyBypassRules in TrustedSourcesManager isn't
appropriate, since ProxyBypassRules was only designed to be used for
proxy rules. It implicitly allows rules such as <-loopback> and <local>,
which TrustedSourcesManager may not want.

With the newly introduced SchemHostPortMatcher, which implements the
most ProxyBypassRules has but more general, we can replace the usage of
ProxyPypassRules with it for TrustedSourcesManager.

Bug: 1030092
Change-Id: Ia0742d589fdbc083e8bbecbd64aacca573b8be91
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036368Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Shimi Zhang <ctzsm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738649}
parent 1aa6261d
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
TrustedSourcesManager::TrustedSourcesManager() { TrustedSourcesManager::TrustedSourcesManager() {
base::CommandLine* command_line(base::CommandLine::ForCurrentProcess()); base::CommandLine* command_line(base::CommandLine::ForCurrentProcess());
DCHECK(command_line); DCHECK(command_line);
rules_.ParseFromString( matcher_ = net::SchemeHostPortMatcher::FromRawString(
command_line->GetSwitchValueASCII(switches::kTrustedDownloadSources)); command_line->GetSwitchValueASCII(switches::kTrustedDownloadSources));
} }
TrustedSourcesManager::~TrustedSourcesManager() = default; TrustedSourcesManager::~TrustedSourcesManager() = default;
bool TrustedSourcesManager::IsFromTrustedSource(const GURL& url) const { bool TrustedSourcesManager::IsFromTrustedSource(const GURL& url) const {
return rules_.Matches(url); return matcher_.Includes(url);
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "net/proxy_resolution/proxy_bypass_rules.h" #include "net/base/scheme_host_port_matcher.h"
class GURL; class GURL;
...@@ -41,9 +41,7 @@ class TrustedSourcesManager { ...@@ -41,9 +41,7 @@ class TrustedSourcesManager {
TrustedSourcesManager(); TrustedSourcesManager();
private: private:
// We are using ProxyBypassRules because they have the functionality that we net::SchemeHostPortMatcher matcher_;
// want, but we are not using it for proxy bypass.
net::ProxyBypassRules rules_;
DISALLOW_COPY_AND_ASSIGN(TrustedSourcesManager); DISALLOW_COPY_AND_ASSIGN(TrustedSourcesManager);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment