OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file defines utility functions for eliding URLs. | 5 // This file defines utility functions for eliding URLs. |
6 | 6 |
7 #ifndef CHROME_BROWSER_UI_ELIDE_URL_H_ | 7 #ifndef CHROME_BROWSER_UI_ELIDE_URL_H_ |
8 #define CHROME_BROWSER_UI_ELIDE_URL_H_ | 8 #define CHROME_BROWSER_UI_ELIDE_URL_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 27 matching lines...) Expand all Loading... | |
38 | 38 |
39 // This function takes a GURL object and elides the host to fit within | 39 // This function takes a GURL object and elides the host to fit within |
40 // the given width. The function will never elide past the TLD+1 point, | 40 // the given width. The function will never elide past the TLD+1 point, |
41 // but after that, will leading-elide the domain name to fit the width. | 41 // but after that, will leading-elide the domain name to fit the width. |
42 // Example: http://sub.domain.com ---> "...domain.com", or "...b.domain.com" | 42 // Example: http://sub.domain.com ---> "...domain.com", or "...b.domain.com" |
43 // depending on the width. | 43 // depending on the width. |
44 base::string16 ElideHost(const GURL& host_url, | 44 base::string16 ElideHost(const GURL& host_url, |
45 const gfx::FontList& font_list, | 45 const gfx::FontList& font_list, |
46 float available_pixel_width); | 46 float available_pixel_width); |
47 | 47 |
48 // This is a convenience function for formatting a URL as an origin in a concise | |
49 // and human-friendly way. Use this instead of |net::FormatUrl| when the reader | |
50 // needs only to understand the origin (rather than the entire URL). | |
51 // | |
52 // - Omits the path for standard schemes, excepting file and filesystem. | |
53 // - Omits the port if it is the default for the scheme. | |
54 // | |
55 // Do not use this for URLs which will be parsed or sent to other applications. | |
56 // Callers should only set |omit_scheme| to true when it is safe to do so: in | |
57 // contexts where the origin is known to be secure or is always secure by | |
58 // necessity. (For example when GURL::SchemeIsCryptographic() or | |
59 // content::IsOriginSecure() return true. | |
Ryan Sleevi
2015/05/29 18:28:31
Mostly a question for the enamel people - but shou
palmer
2015/05/29 20:40:10
OK, I'm convinced this policy should be internal t
| |
60 base::string16 FormatOriginForDisplay(const GURL& origin, | |
61 const std::string& languages, | |
62 bool omit_scheme); | |
63 | |
48 #endif // CHROME_BROWSER_UI_ELIDE_URL_H_ | 64 #endif // CHROME_BROWSER_UI_ELIDE_URL_H_ |
OLD | NEW |