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

Side by Side Diff: components/url_formatter/elide_url.h

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased, most Android targets locally built successfully Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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_formatter { 21 namespace url_formatter {
22 22
23 // ElideUrl and Elide host require 23 // ElideUrl and Elide host require
24 // gfx::GetStringWidthF which is not implemented in Android 24 // gfx::GetStringWidthF which is not implemented in Android
25 #if !defined(OS_ANDROID) 25 #if !defined(OS_ANDROID)
26 // This function takes a GURL object and elides it. It returns a string 26 // 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. 27 // 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 28 // 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 29 // than the |available_pixel_width|. For |available_pixel_width| == 0, a
30 // formatted, but un-elided, string is returned. |languages| is a comma 30 // formatted, but un-elided, string is returned. |languages| is a comma
Peter Kasting 2016/04/05 02:42:33 This comment needs updating.
jungshik at Google 2016/04/05 18:56:19 oops. Thanks. Done
31 // separated list of ISO 639 language codes and is used to determine what 31 // separated list of ISO 639 language codes and is used to determine what
32 // characters are understood by a user. It should come from 32 // characters are understood by a user. It should come from
33 // |prefs::kAcceptLanguages|. 33 // |prefs::kAcceptLanguages|.
34 // 34 //
35 // Note: in RTL locales, if the URL returned by this function is going to be 35 // Note: in RTL locales, if the URL returned by this function is going to be
36 // displayed in the UI, then it is likely that the string needs to be marked 36 // displayed in the UI, then it is likely that the string needs to be marked
37 // as an LTR string (using base::i18n::WrapStringWithLTRFormatting()) so that it 37 // as an LTR string (using base::i18n::WrapStringWithLTRFormatting()) so that it
38 // is displayed properly in an RTL context. Please refer to 38 // is displayed properly in an RTL context. Please refer to
39 // http://crbug.com/6487 for more information. 39 // http://crbug.com/6487 for more information.
40 base::string16 ElideUrl(const GURL& url, 40 base::string16 ElideUrl(const GURL& url,
41 const gfx::FontList& font_list, 41 const gfx::FontList& font_list,
42 float available_pixel_width, 42 float available_pixel_width);
43 const std::string& languages);
44 43
45 // This function takes a GURL object and elides the host to fit within 44 // This function takes a GURL object and elides the host to fit within
46 // the given width. The function will never elide past the TLD+1 point, 45 // the given width. The function will never elide past the TLD+1 point,
47 // but after that, will leading-elide the domain name to fit the width. 46 // but after that, will leading-elide the domain name to fit the width.
48 // Example: http://sub.domain.com ---> "...domain.com", or "...b.domain.com" 47 // Example: http://sub.domain.com ---> "...domain.com", or "...b.domain.com"
49 // depending on the width. 48 // depending on the width.
50 base::string16 ElideHost(const GURL& host_url, 49 base::string16 ElideHost(const GURL& host_url,
51 const gfx::FontList& font_list, 50 const gfx::FontList& font_list,
52 float available_pixel_width); 51 float available_pixel_width);
53 #endif // !defined(OS_ANDROID) 52 #endif // !defined(OS_ANDROID)
54 53
55 // This is a convenience function for formatting a URL in a concise and 54 // This is a convenience function for formatting a URL in a concise and
56 // human-friendly way, to help users make security-related decisions (or in 55 // human-friendly way, to help users make security-related decisions (or in
57 // other circumstances when people need to distinguish sites, origins, or 56 // other circumstances when people need to distinguish sites, origins, or
58 // otherwise-simplified URLs from each other). 57 // otherwise-simplified URLs from each other).
59 // 58 //
60 // Internationalized domain names (IDN) may be presented in Unicode if 59 // Internationalized domain names (IDN) may be presented in Unicode if
61 // |languages| accepts the Unicode representation (see 60 // they're regarded safe. See |url_formatter::FormatUrl| for more details on
62 // |url_formatter::FormatUrl| for more details on the algorithm). 61 // the algorithm).
63 // 62 //
64 // - Omits the path for standard schemes, excepting file and filesystem. 63 // - Omits the path for standard schemes, excepting file and filesystem.
65 // - Omits the port if it is the default for the scheme. 64 // - Omits the port if it is the default for the scheme.
66 // 65 //
67 // Do not use this for URLs which will be parsed or sent to other applications. 66 // Do not use this for URLs which will be parsed or sent to other applications.
68 // 67 //
69 // Generally, set prefer this function to 68 // Generally, set prefer this function to
70 // |FormatUrlForSecurityDisplayOmitScheme| unless there is plenty of indication 69 // |FormatUrlForSecurityDisplayOmitScheme| unless there is plenty of indication
71 // as to whether the origin is secure elsewhere in the UX. For example, in 70 // as to whether the origin is secure elsewhere in the UX. For example, in
72 // Chrome's Origin Info Bubble, there are icons and strings indicating origin 71 // Chrome's Origin Info Bubble, there are icons and strings indicating origin
73 // (non-)security. But in the HTTP Basic Auth prompt (for example), the scheme 72 // (non-)security. But in the HTTP Basic Auth prompt (for example), the scheme
74 // may be the only indicator. 73 // may be the only indicator.
75 base::string16 FormatUrlForSecurityDisplay(const GURL& origin, 74 base::string16 FormatUrlForSecurityDisplay(const GURL& origin);
76 const std::string& languages);
77 75
78 // Just like |FormatUrlForSecurityDisplay|, but also: 76 // Just like |FormatUrlForSecurityDisplay|, but also:
79 // 77 //
80 // - Omits the scheme if SchemeIsHTTPOrHTTPS(). 78 // - Omits the scheme if SchemeIsHTTPOrHTTPS().
81 base::string16 FormatUrlForSecurityDisplayOmitScheme( 79 base::string16 FormatUrlForSecurityDisplayOmitScheme(const GURL& origin);
82 const GURL& origin,
83 const std::string& languages);
84 80
85 } // namespace url_formatter 81 } // namespace url_formatter
86 82
87 #endif // COMPONENTS_URL_FORMATTER_ELIDE_URL_H_ 83 #endif // COMPONENTS_URL_FORMATTER_ELIDE_URL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698