Rename IsLocalhost(host) to HostStringIsLocalhost(host); add IsLocalhost(GURL)

Several call sites incorrectly used GURL::host or GURL::host_piece as an
argument to net::IsLocalhost. This function only expects IPv6 addresses
without brackets. Since the vast majority of the callers start off with
a GURL, change net::IsLocalhost(StringPiece) to net::IsLocalhost(GURL).

For callers that do not have a GURL, and only a host name (e.g. Blink code),
net::HostStringIsLocalhost is added (which behaves like the old net::IsLocalhost).

BUG=797778
TEST=Start Chrome with --allow-insecure-localhost, visit https://[::1]/
     and confirm that the site loads without intersitial.

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ibb1cbf3f061ea2070d5e479ac4119a813a7e98a7
Reviewed-on: https://chromium-review.googlesource.com/844777
Commit-Queue: Rob Wu <[email protected]>
Reviewed-by: Eric Roman <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Cr-Commit-Position: refs/heads/master@{#529180}
diff --git a/extensions/browser/extension_throttle_manager.cc b/extensions/browser/extension_throttle_manager.cc
index e6a7728f..8c954e3d 100644
--- a/extensions/browser/extension_throttle_manager.cc
+++ b/extensions/browser/extension_throttle_manager.cc
@@ -102,10 +102,10 @@
     // We only disable back-off throttling on an entry that we have
     // just constructed.  This is to allow unit tests to explicitly override
     // the entry for localhost URLs.
-    std::string host = url.host();
-    if (net::IsLocalhost(host)) {
-      if (!logged_for_localhost_disabled_ && net::IsLocalhost(host)) {
+    if (net::IsLocalhost(url)) {
+      if (!logged_for_localhost_disabled_) {
         logged_for_localhost_disabled_ = true;
+        std::string host = url.host();
         net_log_.AddEvent(net::NetLogEventType::THROTTLING_DISABLED_FOR_HOST,
                           net::NetLog::StringCallback("host", &host));
       }