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

Unified Diff: url/gurl.cc

Issue 1049533002: Add IsOriginSecure and GURL::SchemeUsesTLS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Be even more precise in comments. Created 5 years, 9 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
« url/gurl.h ('K') | « url/gurl.h ('k') | url/gurl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/gurl.cc
diff --git a/url/gurl.cc b/url/gurl.cc
index 46ca408da9c9c55f1e919365dab03db5038aedff..a826a779a15def7728a6bf3eb3ebbf3020047d00 100644
--- a/url/gurl.cc
+++ b/url/gurl.cc
@@ -458,6 +458,29 @@ bool GURL::HostIsIPAddress() const {
return host_info.IsIPAddress();
}
+bool GURL::HostIsLocal() const {
+ if (!is_valid_ || spec_.empty())
+ return false;
+
+ if (HostNoBrackets() == "localhost")
+ return true;
+
+ url::RawCanonOutputT<char, 128> ignored;
+ url::CanonHostInfo host_info;
+ url::CanonicalizeIPAddress(spec_.c_str(), parsed_.host, &ignored, &host_info);
+
+ static const unsigned char v4_localhost = 0x7F;
+ if (host_info.family == url::CanonHostInfo::IPV4)
+ return host_info.address[0] == v4_localhost;
+
+ static const unsigned char v6_localhost[] =
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
+ if (host_info.family == url::CanonHostInfo::IPV6)
+ return memcmp(host_info.address, v6_localhost, sizeof(v6_localhost)) == 0;
+
+ return false;
+}
+
#ifdef WIN32
const GURL& GURL::EmptyGURL() {
« url/gurl.h ('K') | « url/gurl.h ('k') | url/gurl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698