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

Side by Side Diff: ui/base/text/text_elider.cc

Issue 7811006: Add full support for filesystem URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better content_settings_pattern.cc changes. Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/base/text/text_elider.h" 5 #include "ui/base/text/text_elider.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 const gfx::Font& font, 156 const gfx::Font& font,
157 int available_pixel_width, 157 int available_pixel_width,
158 const std::string& languages) { 158 const std::string& languages) {
159 // Get a formatted string and corresponding parsing of the url. 159 // Get a formatted string and corresponding parsing of the url.
160 url_parse::Parsed parsed; 160 url_parse::Parsed parsed;
161 string16 url_string = net::FormatUrl(url, languages, net::kFormatUrlOmitAll, 161 string16 url_string = net::FormatUrl(url, languages, net::kFormatUrlOmitAll,
162 net::UnescapeRule::SPACES, &parsed, NULL, NULL); 162 net::UnescapeRule::SPACES, &parsed, NULL, NULL);
163 if (available_pixel_width <= 0) 163 if (available_pixel_width <= 0)
164 return url_string; 164 return url_string;
165 165
166 // If non-standard or not file type, return plain eliding. 166 // If non-standard, return plain eliding.
167 if (!(url.SchemeIsFile() || url.IsStandard())) 167 if (!url.IsStandard())
168 return ElideText(url_string, font, available_pixel_width, ui::ELIDE_AT_END); 168 return ElideText(url_string, font, available_pixel_width, ui::ELIDE_AT_END);
169 169
170 // Now start eliding url_string to fit within available pixel width. 170 // Now start eliding url_string to fit within available pixel width.
171 // Fist pass - check to see whether entire url_string fits. 171 // Fist pass - check to see whether entire url_string fits.
172 int pixel_width_url_string = font.GetStringWidth(url_string); 172 int pixel_width_url_string = font.GetStringWidth(url_string);
173 if (available_pixel_width >= pixel_width_url_string) 173 if (available_pixel_width >= pixel_width_url_string)
174 return url_string; 174 return url_string;
175 175
176 // Get the path substring, including query and reference. 176 // Get the path substring, including query and reference.
177 size_t path_start_index = parsed.path.begin; 177 size_t path_start_index = parsed.path.begin;
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 index = char_iterator.getIndex(); 1049 index = char_iterator.getIndex();
1050 } else { 1050 } else {
1051 // String has leading whitespace, return the elide string. 1051 // String has leading whitespace, return the elide string.
1052 return kElideString; 1052 return kElideString;
1053 } 1053 }
1054 } 1054 }
1055 return string.substr(0, index) + kElideString; 1055 return string.substr(0, index) + kElideString;
1056 } 1056 }
1057 1057
1058 } // namespace ui 1058 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698