| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 implements utility functions for eliding and formatting UI text. | 5 // This file implements utility functions for eliding and formatting UI text. |
| 6 // | 6 // |
| 7 // Note that several of the functions declared in text_elider.h are implemented | 7 // Note that several of the functions declared in text_elider.h are implemented |
| 8 // in this file using helper classes in an unnamed namespace. | 8 // in this file using helper classes in an unnamed namespace. |
| 9 | 9 |
| 10 #include "ui/base/text/text_elider.h" | 10 #include "ui/base/text/text_elider.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 const string16 url_minus_query = | 245 const string16 url_minus_query = |
| 246 url_string.substr(0, path_start_index + path_len); | 246 url_string.substr(0, path_start_index + path_len); |
| 247 if (available_pixel_width >= font.GetStringWidth(url_minus_query)) | 247 if (available_pixel_width >= font.GetStringWidth(url_minus_query)) |
| 248 return ElideText(url_string, font, available_pixel_width, ELIDE_AT_END); | 248 return ElideText(url_string, font, available_pixel_width, ELIDE_AT_END); |
| 249 | 249 |
| 250 // Get Host. | 250 // Get Host. |
| 251 string16 url_host = UTF8ToUTF16(url.host()); | 251 string16 url_host = UTF8ToUTF16(url.host()); |
| 252 | 252 |
| 253 // Get domain and registry information from the URL. | 253 // Get domain and registry information from the URL. |
| 254 string16 url_domain = UTF8ToUTF16( | 254 string16 url_domain = UTF8ToUTF16( |
| 255 net::RegistryControlledDomainService::GetDomainAndRegistry(url)); | 255 net::registry_controlled_domains::GetDomainAndRegistry( |
| 256 url, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES)); |
| 256 if (url_domain.empty()) | 257 if (url_domain.empty()) |
| 257 url_domain = url_host; | 258 url_domain = url_host; |
| 258 | 259 |
| 259 // Add port if required. | 260 // Add port if required. |
| 260 if (!url.port().empty()) { | 261 if (!url.port().empty()) { |
| 261 url_host += UTF8ToUTF16(":" + url.port()); | 262 url_host += UTF8ToUTF16(":" + url.port()); |
| 262 url_domain += UTF8ToUTF16(":" + url.port()); | 263 url_domain += UTF8ToUTF16(":" + url.port()); |
| 263 } | 264 } |
| 264 | 265 |
| 265 // Get sub domain. | 266 // Get sub domain. |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 index = char_iterator.getIndex(); | 1123 index = char_iterator.getIndex(); |
| 1123 } else { | 1124 } else { |
| 1124 // String has leading whitespace, return the elide string. | 1125 // String has leading whitespace, return the elide string. |
| 1125 return kElideString; | 1126 return kElideString; |
| 1126 } | 1127 } |
| 1127 } | 1128 } |
| 1128 return string.substr(0, index) + kElideString; | 1129 return string.substr(0, index) + kElideString; |
| 1129 } | 1130 } |
| 1130 | 1131 |
| 1131 } // namespace ui | 1132 } // namespace ui |
| OLD | NEW |