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 COMPONENTS_URL_FORMATTER_ELIDE_URL_H_ | 7 #ifndef COMPONENTS_URL_FORMATTER_ELIDE_URL_H_ |
| 8 #define COMPONENTS_URL_FORMATTER_ELIDE_URL_H_ | 8 #define COMPONENTS_URL_FORMATTER_ELIDE_URL_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 // This function takes a GURL object and elides the host to fit within | 41 // This function takes a GURL object and elides the host to fit within |
| 42 // the given width. The function will never elide past the TLD+1 point, | 42 // the given width. The function will never elide past the TLD+1 point, |
| 43 // but after that, will leading-elide the domain name to fit the width. | 43 // but after that, will leading-elide the domain name to fit the width. |
| 44 // Example: http://sub.domain.com ---> "...domain.com", or "...b.domain.com" | 44 // Example: http://sub.domain.com ---> "...domain.com", or "...b.domain.com" |
| 45 // depending on the width. | 45 // depending on the width. |
| 46 base::string16 ElideHost(const GURL& host_url, | 46 base::string16 ElideHost(const GURL& host_url, |
| 47 const gfx::FontList& font_list, | 47 const gfx::FontList& font_list, |
| 48 float available_pixel_width); | 48 float available_pixel_width); |
| 49 #endif // !defined(OS_ANDROID) | 49 #endif // !defined(OS_ANDROID) |
| 50 | 50 |
| 51 enum class SchemeDisplay { | |
| 52 SHOW, | |
| 53 OMIT_WEB, | |
| 54 OMIT_CRYPTOGRAPHIC, | |
|
felt
2016/04/18 01:16:26
nit: The meanings of these names are not obvious t
| |
| 55 }; | |
| 56 | |
| 51 // This is a convenience function for formatting a URL in a concise and | 57 // This is a convenience function for formatting a URL in a concise and |
| 52 // human-friendly way, to help users make security-related decisions (or in | 58 // human-friendly way, to help users make security-related decisions (or in |
| 53 // other circumstances when people need to distinguish sites, origins, or | 59 // other circumstances when people need to distinguish sites, origins, or |
| 54 // otherwise-simplified URLs from each other). | 60 // otherwise-simplified URLs from each other). |
| 55 // | 61 // |
| 56 // Internationalized domain names (IDN) may be presented in Unicode if | 62 // Internationalized domain names (IDN) may be presented in Unicode if |
| 57 // they're regarded safe. See |url_formatter::FormatUrl| for more details on | 63 // they're regarded safe. See |url_formatter::FormatUrl| for more details on |
| 58 // the algorithm). | 64 // the algorithm). |
| 59 // | 65 // |
| 60 // - Omits the path for standard schemes, excepting file and filesystem. | 66 // - Omits the path for standard schemes, excepting file and filesystem. |
| 61 // - Omits the port if it is the default for the scheme. | 67 // - Omits the port if it is the default for the scheme. |
| 62 // | 68 // |
| 63 // Do not use this for URLs which will be parsed or sent to other applications. | 69 // Do not use this for URLs which will be parsed or sent to other applications. |
| 64 // | 70 // |
| 65 // Generally, set prefer this function to | 71 // Generally, prefer SchemeDisplay::SHOW to omitting the scheme unless there is |
| 66 // |FormatUrlForSecurityDisplayOmitScheme| unless there is plenty of indication | 72 // plenty of indication as to whether the origin is secure elsewhere in the UX. |
| 67 // as to whether the origin is secure elsewhere in the UX. For example, in | 73 // For example, in Chrome's Origin Info Bubble, there are icons and strings |
| 68 // Chrome's Origin Info Bubble, there are icons and strings indicating origin | 74 // indicating origin (non-)security. But in the HTTP Basic Auth prompt (for |
| 69 // (non-)security. But in the HTTP Basic Auth prompt (for example), the scheme | 75 // example), the scheme may be the only indicator. |
| 70 // may be the only indicator. | 76 base::string16 FormatUrlForSecurityDisplay( |
| 71 base::string16 FormatUrlForSecurityDisplay(const GURL& origin); | 77 const GURL& origin, |
| 72 | 78 const SchemeDisplay scheme_display = SchemeDisplay::SHOW); |
| 73 // Just like |FormatUrlForSecurityDisplay|, but also: | |
| 74 // | |
| 75 // - Omits the scheme if SchemeIsHTTPOrHTTPS(). | |
| 76 base::string16 FormatUrlForSecurityDisplayOmitScheme(const GURL& origin); | |
| 77 | 79 |
| 78 } // namespace url_formatter | 80 } // namespace url_formatter |
| 79 | 81 |
| 80 #endif // COMPONENTS_URL_FORMATTER_ELIDE_URL_H_ | 82 #endif // COMPONENTS_URL_FORMATTER_ELIDE_URL_H_ |
| OLD | NEW |