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

Side by Side Diff: app/gfx/text_elider.cc

Issue 56053: URL's not properly unescaping when displayed (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/bookmarks/bookmark_table_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "app/gfx/font.h" 5 #include "app/gfx/font.h"
6 #include "app/gfx/text_elider.h" 6 #include "app/gfx/text_elider.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 15 matching lines...) Expand all
26 // kerning/ligatures/etc. issues potentially wrong by assuming that the width of 26 // kerning/ligatures/etc. issues potentially wrong by assuming that the width of
27 // a rendered string is always the sum of the widths of its substrings. Also I 27 // a rendered string is always the sum of the widths of its substrings. Also I
28 // suspect it could be made simpler. 28 // suspect it could be made simpler.
29 std::wstring ElideUrl(const GURL& url, 29 std::wstring ElideUrl(const GURL& url,
30 const gfx::Font& font, 30 const gfx::Font& font,
31 int available_pixel_width, 31 int available_pixel_width,
32 const std::wstring& languages) { 32 const std::wstring& languages) {
33 // Get a formatted string and corresponding parsing of the url. 33 // Get a formatted string and corresponding parsing of the url.
34 url_parse::Parsed parsed; 34 url_parse::Parsed parsed;
35 std::wstring url_string = 35 std::wstring url_string =
36 net::FormatUrl(url, languages, true, true, &parsed, NULL); 36 net::FormatUrl(url, languages, true, UnescapeRule::SPACES, &parsed, NULL);
37 if (available_pixel_width <= 0) 37 if (available_pixel_width <= 0)
38 return url_string; 38 return url_string;
39 39
40 // If non-standard or not file type, return plain eliding. 40 // If non-standard or not file type, return plain eliding.
41 if (!(url.SchemeIsFile() || url.IsStandard())) 41 if (!(url.SchemeIsFile() || url.IsStandard()))
42 return ElideText(url_string, font, available_pixel_width); 42 return ElideText(url_string, font, available_pixel_width);
43 43
44 // Now start eliding url_string to fit within available pixel width. 44 // Now start eliding url_string to fit within available pixel width.
45 // Fist pass - check to see whether entire url_string fits. 45 // Fist pass - check to see whether entire url_string fits.
46 int pixel_width_url_string = font.GetStringWidth(url_string); 46 int pixel_width_url_string = font.GetStringWidth(url_string);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 322 }
323 323
324 SortedDisplayURL::SortedDisplayURL(const GURL& url, 324 SortedDisplayURL::SortedDisplayURL(const GURL& url,
325 const std::wstring& languages) { 325 const std::wstring& languages) {
326 std::wstring host; 326 std::wstring host;
327 net::AppendFormattedHost(url, languages, &host, NULL); 327 net::AppendFormattedHost(url, languages, &host, NULL);
328 sort_host_ = WideToUTF16Hack(host); 328 sort_host_ = WideToUTF16Hack(host);
329 string16 host_minus_www = WideToUTF16Hack(net::StripWWW(host)); 329 string16 host_minus_www = WideToUTF16Hack(net::StripWWW(host));
330 url_parse::Parsed parsed; 330 url_parse::Parsed parsed;
331 display_url_ = WideToUTF16Hack(net::FormatUrl(url, languages, 331 display_url_ = WideToUTF16Hack(net::FormatUrl(url, languages,
332 true, true, &parsed, &prefix_end_)); 332 true, UnescapeRule::SPACES, &parsed, &prefix_end_));
333 if (sort_host_.length() > host_minus_www.length()) { 333 if (sort_host_.length() > host_minus_www.length()) {
334 prefix_end_ += sort_host_.length() - host_minus_www.length(); 334 prefix_end_ += sort_host_.length() - host_minus_www.length();
335 sort_host_.swap(host_minus_www); 335 sort_host_.swap(host_minus_www);
336 } 336 }
337 } 337 }
338 338
339 int SortedDisplayURL::Compare(const SortedDisplayURL& other, 339 int SortedDisplayURL::Compare(const SortedDisplayURL& other,
340 Collator* collator) const { 340 Collator* collator) const {
341 // Compare on hosts first. The host won't contain 'www.'. 341 // Compare on hosts first. The host won't contain 'www.'.
342 UErrorCode compare_status = U_ZERO_ERROR; 342 UErrorCode compare_status = U_ZERO_ERROR;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 string16 SortedDisplayURL::AfterHost() const { 380 string16 SortedDisplayURL::AfterHost() const {
381 size_t slash_index = display_url_.find(sort_host_, prefix_end_); 381 size_t slash_index = display_url_.find(sort_host_, prefix_end_);
382 if (slash_index == string16::npos) { 382 if (slash_index == string16::npos) {
383 NOTREACHED(); 383 NOTREACHED();
384 return string16(); 384 return string16();
385 } 385 }
386 return display_url_.substr(slash_index + sort_host_.length()); 386 return display_url_.substr(slash_index + sort_host_.length());
387 } 387 }
388 388
389 } // namespace gfx. 389 } // namespace gfx.
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/bookmarks/bookmark_table_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698