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

Unified Diff: net/base/net_util.h

Issue 532523002: Create net::FormatOriginForDisplay helper function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another newline EOF fix... Created 6 years, 4 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
« no previous file with comments | « no previous file | net/base/net_util_icu.cc » ('j') | net/base/net_util_icu.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | net/base/net_util_icu.cc » ('j') | net/base/net_util_icu.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698