Chromium Code Reviews| Index: net/base/net_util.h |
| diff --git a/net/base/net_util.h b/net/base/net_util.h |
| index c74dfd2ea48486b08e16be9fdb700b9d99f06bd0..5a3ce7aacf4b3cff78c85aab2c6b2e109574a56a 100644 |
| --- a/net/base/net_util.h |
| +++ b/net/base/net_util.h |
| @@ -74,6 +74,14 @@ NET_EXPORT extern const FormatUrlType kFormatUrlOmitTrailingSlashOnBareHostname; |
| // Convenience for omitting all unecessary types. |
| NET_EXPORT extern const FormatUrlType kFormatUrlOmitAll; |
| +// Remove the scheme. The caller should only specify kFormatUrlOmitScheme |
| +// after verifying that it is secure to do so. Not part of kFormatUrlOmitAll. |
| +NET_EXPORT extern const FormatUrlType kFormatUrlOmitScheme; |
| + |
| +// Remove the port. The caller should only specify kFormatUrlOmitPort |
| +// after verifying that it is secure to do so. Not part of kFormatUrlOmitAll. |
|
Ryan Sleevi
2014/09/02 19:26:17
This is... vaguely worded.
When is it ever secure
|
| +NET_EXPORT extern const FormatUrlType kFormatUrlOmitPort; |
| + |
| // Returns the number of explicitly allowed ports; for testing. |
| NET_EXPORT_PRIVATE extern size_t GetCountOfExplicitlyAllowedPorts(); |
| @@ -338,6 +346,17 @@ inline base::string16 FormatUrl(const GURL& url, const std::string& languages) { |
| NULL, NULL, NULL); |
| } |
| +// This is a convenience function for formatting a URL as an origin for display |
| +// in security UI: infobars, permission strings, etc. Use this instead of |
|
Ryan Sleevi
2014/09/02 19:26:17
So, to re-iterate the layering, //net has no idea
felt
2014/09/15 05:42:30
Here are some files that should be refactored to c
felt
2014/09/15 22:47:55
Sleevi: what about putting this on gurl.h?
|
| +// FormatUrl() for strings in a security UI context. Do not use this for URLs |
| +// which will be parsed or sent to other applications. |
| +// - The path is dropped for standard schemes, excepting file and filesystem. |
| +// - Standard ports are removed for http and https. |
| +// - By default, the scheme is only displayed for non-secure origins. This can |
|
Michael van Ouwerkerk
2014/09/02 13:10:47
Why is https omitted by default? Haven't we been t
|
| +// be overridden with |always_show_scheme|. |
| +NET_EXPORT base::string16 FormatOriginForDisplay( |
| + const GURL& origin, const std::string& languages, bool always_show_scheme); |
| + |
| // Returns whether FormatUrl() would strip a trailing slash from |url|, given a |
| // format flag including kFormatUrlOmitTrailingSlashOnBareHostname. |
| NET_EXPORT bool CanStripTrailingSlash(const GURL& url); |