Add url::Component::is_empty()

Then use it to avoid the double-negative !value.is_nonempty(), which
makes the code read much more clearly.

Change-Id: Ibd34ea23dbcb59c396c2b2c03367da12b6f2bc82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4024465
Reviewed-by: Daniel Cheng <[email protected]>
Owners-Override: Daniel Cheng <[email protected]>
Commit-Queue: Tom Sepez <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1071331}
diff --git a/net/base/proxy_string_util.cc b/net/base/proxy_string_util.cc
index 81328620..a8e7671 100644
--- a/net/base/proxy_string_util.cc
+++ b/net/base/proxy_string_util.cc
@@ -68,7 +68,7 @@
                       &username_component, &password_component,
                       &hostname_component, &port_component);
   if (username_component.is_valid() || password_component.is_valid() ||
-      !hostname_component.is_nonempty()) {
+      hostname_component.is_empty()) {
     return ProxyServer();
   }
 
@@ -78,7 +78,7 @@
   // Reject inputs like "foo:". /url parsing and canonicalization code generally
   // allows it and treats it the same as a URL without a specified port, but
   // Chrome has traditionally disallowed it in proxy specifications.
-  if (port_component.is_valid() && !port_component.is_nonempty())
+  if (port_component.is_valid() && port_component.is_empty())
     return ProxyServer();
   base::StringPiece port =
       port_component.is_nonempty()