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

Unified Diff: components/url_formatter/url_formatter.h

Issue 2939423003: URL Formatter: Add StripSubdomain method that preserves eTLD + 1. (Closed)
Patch Set: fix Created 3 years, 6 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
Index: components/url_formatter/url_formatter.h
diff --git a/components/url_formatter/url_formatter.h b/components/url_formatter/url_formatter.h
index 90f2bbf9b73128e35a080382b35fe91d08db3d09..f29e97ce29a0564fad6430134d05d971351072af 100644
--- a/components/url_formatter/url_formatter.h
+++ b/components/url_formatter/url_formatter.h
@@ -137,11 +137,19 @@ void AppendFormattedHost(const GURL& url, base::string16* output);
base::string16 IDNToUnicode(base::StringPiece host);
// If |text| starts with "www." it is removed, otherwise |text| is returned
-// unmodified.
+// unmodified. Both |text| and the returned value are arbitrary strings and
+// are not guaranteed to be navigable hostnames.
base::string16 StripWWW(const base::string16& text);
-// Runs |url|'s host through StripWWW(). |url| must be valid.
-base::string16 StripWWWFromHost(const GURL& url);
+// Returns the host of |url| with subdomains specified by |subdomains|
+// removed. |url| must be valid. If the |url| host is already an eTLD+1,
+// the host is returned unmodified.
+typedef uint32_t StripSubdomainType;
+typedef uint32_t StripSubdomainTypes;
+constexpr StripSubdomainType kStripWWW = 1 << 0;
+constexpr StripSubdomainType kStripM = 1 << 1;
+base::StringPiece StripSubdomains(const GURL& url,
+ StripSubdomainTypes subdomains);
} // namespace url_formatter

Powered by Google App Engine
This is Rietveld 408576698