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

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..72dd55d43dc4357bc3b644bcf59b0655afd71df1 100644
--- a/components/url_formatter/url_formatter.h
+++ b/components/url_formatter/url_formatter.h
@@ -137,11 +137,20 @@ 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. |text| is an arbitrary string and not necessarily a valid host.
+// Even if |text| is a valid host, this method may return an invalid host.
Peter Kasting 2017/06/17 02:46:55 I think these two sentences use "valid" in a way t
tommycli 2017/06/19 23:03:08 Done.
+// This is useful for finding search engine keywords inside user input.
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