Chromium Code Reviews| 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 // | |
|
msw
2015/05/29 00:18:51
nit: remove this blank comment line; the next para
palmer
2015/05/29 17:52:13
Done.
| |
| 57 // Callers should only set |omit_scheme| to true when it is safe to do so: in | |
| 58 // contexts where the origin is known to be secure or is always secure by | |
| 59 // necessity. As examples: | |
|
msw
2015/05/29 00:18:51
nit: "For example when GURL::SchemeIsCryptographic
palmer
2015/05/29 17:52:13
Done.
| |
| 60 // | |
| 61 // display = FormatOriginForDisplay(url, ..., url.SchemeIsCryptographic()); | |
| 62 // | |
| 63 // display = FormatOriginForDisplay(url, ..., IsOriginSecure(url)); | |
| 64 base::string16 FormatOriginForDisplay(const GURL& origin, | |
| 65 const std::string& languages, | |
| 66 bool omit_scheme); | |
|
msw
2015/05/29 00:18:51
Do we need an |omit_scheme| argument already? Why
palmer
2015/05/29 17:52:13
1. Flexibility. Callers may have different needs.
| |
| 67 | |
| 48 #endif // CHROME_BROWSER_UI_ELIDE_URL_H_ | 68 #endif // CHROME_BROWSER_UI_ELIDE_URL_H_ |
| OLD | NEW |