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> |
| 11 | 11 |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 | 14 |
| 15 class GURL; | 15 class GURL; |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 class FontList; | 18 class FontList; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace url { | |
| 22 class Origin; | |
| 23 } | |
| 24 | |
| 21 namespace url_formatter { | 25 namespace url_formatter { |
| 22 | 26 |
| 23 // ElideUrl and Elide host require | 27 // ElideUrl and Elide host require |
| 24 // gfx::GetStringWidthF which is not implemented in Android | 28 // gfx::GetStringWidthF which is not implemented in Android |
| 25 #if !defined(OS_ANDROID) | 29 #if !defined(OS_ANDROID) |
| 26 // This function takes a GURL object and elides it. It returns a string | 30 // This function takes a GURL object and elides it. It returns a string |
| 27 // which composed of parts from subdomain, domain, path, filename and query. | 31 // which composed of parts from subdomain, domain, path, filename and query. |
| 28 // A "..." is added automatically at the end if the elided string is bigger | 32 // A "..." is added automatically at the end if the elided string is bigger |
| 29 // than the |available_pixel_width|. For |available_pixel_width| == 0, a | 33 // than the |available_pixel_width|. For |available_pixel_width| == 0, a |
| 30 // formatted, but un-elided, string is returned. | 34 // formatted, but un-elided, string is returned. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 // | 75 // |
| 72 // Generally, prefer SchemeDisplay::SHOW to omitting the scheme unless there is | 76 // Generally, prefer SchemeDisplay::SHOW to omitting the scheme unless there is |
| 73 // plenty of indication as to whether the origin is secure elsewhere in the UX. | 77 // plenty of indication as to whether the origin is secure elsewhere in the UX. |
| 74 // For example, in Chrome's Origin Info Bubble, there are icons and strings | 78 // For example, in Chrome's Origin Info Bubble, there are icons and strings |
| 75 // indicating origin (non-)security. But in the HTTP Basic Auth prompt (for | 79 // indicating origin (non-)security. But in the HTTP Basic Auth prompt (for |
| 76 // example), the scheme may be the only indicator. | 80 // example), the scheme may be the only indicator. |
| 77 base::string16 FormatUrlForSecurityDisplay( | 81 base::string16 FormatUrlForSecurityDisplay( |
| 78 const GURL& origin, | 82 const GURL& origin, |
| 79 const SchemeDisplay scheme_display = SchemeDisplay::SHOW); | 83 const SchemeDisplay scheme_display = SchemeDisplay::SHOW); |
| 80 | 84 |
| 85 base::string16 FormatUrlForSecurityDisplay( | |
|
palmer
2016/05/09 19:40:48
Naming it |FormatOriginForSecurityDisplay| might b
juncai
2016/05/10 02:16:58
Done.
| |
| 86 const url::Origin& origin, | |
| 87 const SchemeDisplay scheme_display = SchemeDisplay::SHOW); | |
| 88 | |
| 81 } // namespace url_formatter | 89 } // namespace url_formatter |
| 82 | 90 |
| 83 #endif // COMPONENTS_URL_FORMATTER_ELIDE_URL_H_ | 91 #endif // COMPONENTS_URL_FORMATTER_ELIDE_URL_H_ |
| OLD | NEW |