diff options
author | mkwst <mkwst@chromium.org> | 2015-07-24 22:18:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-25 05:19:39 +0000 |
commit | d8335d98a4c056ab97c5cdff1e95a7fa2c7dfc10 (patch) | |
tree | cb4965114068af0ec9095fa015b34d0caaca9289 /url/scheme_host_port.cc | |
parent | c8b870d08efb3ffc6c2bedcec36462ece2326017 (diff) | |
download | chromium_src-d8335d98a4c056ab97c5cdff1e95a7fa2c7dfc10.zip chromium_src-d8335d98a4c056ab97c5cdff1e95a7fa2c7dfc10.tar.gz chromium_src-d8335d98a4c056ab97c5cdff1e95a7fa2c7dfc10.tar.bz2 |
Teach IPC about 'url::Origin'.
We'll need to pass Origin objects back and forth between the renderer
and browser processes. This patch teaches IPC about the object in order
to make that possible.
BUG=512731
Review URL: https://codereview.chromium.org/1251063002
Cr-Commit-Position: refs/heads/master@{#340399}
Diffstat (limited to 'url/scheme_host_port.cc')
-rw-r--r-- | url/scheme_host_port.cc | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/url/scheme_host_port.cc b/url/scheme_host_port.cc index cb2d5cc..c2fe830 100644 --- a/url/scheme_host_port.cc +++ b/url/scheme_host_port.cc @@ -25,10 +25,6 @@ SchemeHostPort::SchemeHostPort(base::StringPiece scheme, : scheme_(scheme.data(), scheme.length()), host_(host.data(), host.length()), port_(port) { -#if DCHECK_IS_ON() - DCHECK(url::IsStandard(scheme.data(), - url::Component(0, static_cast<int>(scheme.length())))); - // Try to canonicalize the host (copy/pasted from net/base. :( ). const url::Component raw_host_component(0, static_cast<int>(host.length())); std::string canon_host; @@ -46,11 +42,28 @@ SchemeHostPort::SchemeHostPort(base::StringPiece scheme, // Empty host, or canonicalization failed. canon_host.clear(); } - DCHECK_EQ(host, canon_host); - DCHECK(scheme == kFileScheme ? port == 0 : port != 0); - DCHECK(!host.empty() || port == 0); -#endif + // Return an invalid SchemeHostPort object if any of the following conditions + // hold: + // + // 1. The provided scheme is non-standard, 'blob:', or 'filesystem:'. + // 2. The provided host is non-canonical. + // 3. The scheme is 'file' and the port is non-zero. + // 4. The scheme is not 'file', and the port is zero or the host is empty. + bool isUnsupportedScheme = + !url::IsStandard(scheme.data(), + url::Component(0, static_cast<int>(scheme.length()))) || + scheme == kFileSystemScheme || scheme == kBlobScheme; + bool isNoncanonicalHost = host != canon_host; + bool isFileSchemeWithPort = scheme == kFileScheme && port != 0; + bool isNonFileSchemeWithoutPortOrHost = + scheme != kFileScheme && (port == 0 || host.empty()); + if (isUnsupportedScheme || isNoncanonicalHost || isFileSchemeWithPort || + isNonFileSchemeWithoutPortOrHost) { + scheme_.clear(); + host_.clear(); + port_ = 0; + } } SchemeHostPort::SchemeHostPort(const GURL& url) : port_(0) { |