| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "app/text_elider.h" | 7 #include "app/text_elider.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 url.SchemeIsFile())) { | 116 url.SchemeIsFile())) { |
| 117 url_subdomain.clear(); | 117 url_subdomain.clear(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // If this is a file type, the path is now defined as everything after ":". | 120 // If this is a file type, the path is now defined as everything after ":". |
| 121 // For example, "C:/aa/aa/bb", the path is "/aa/bb/cc". Interesting, the | 121 // For example, "C:/aa/aa/bb", the path is "/aa/bb/cc". Interesting, the |
| 122 // domain is now C: - this is a nice hack for eliding to work pleasantly. | 122 // domain is now C: - this is a nice hack for eliding to work pleasantly. |
| 123 if (url.SchemeIsFile()) { | 123 if (url.SchemeIsFile()) { |
| 124 // Split the path string using ":" | 124 // Split the path string using ":" |
| 125 std::vector<std::wstring> file_path_split; | 125 std::vector<std::wstring> file_path_split; |
| 126 SplitString(url_path, L':', &file_path_split); | 126 base::SplitString(url_path, L':', &file_path_split); |
| 127 if (file_path_split.size() > 1) { // File is of type "file:///C:/.." | 127 if (file_path_split.size() > 1) { // File is of type "file:///C:/.." |
| 128 url_host.clear(); | 128 url_host.clear(); |
| 129 url_domain.clear(); | 129 url_domain.clear(); |
| 130 url_subdomain.clear(); | 130 url_subdomain.clear(); |
| 131 | 131 |
| 132 url_host = url_domain = file_path_split.at(0).substr(1) + L":"; | 132 url_host = url_domain = file_path_split.at(0).substr(1) + L":"; |
| 133 url_path_query_etc = url_path = file_path_split.at(1); | 133 url_path_query_etc = url_path = file_path_split.at(1); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 157 if (available_pixel_width >= (pixel_width_url_subdomain + | 157 if (available_pixel_width >= (pixel_width_url_subdomain + |
| 158 pixel_width_url_domain + pixel_width_url_path - | 158 pixel_width_url_domain + pixel_width_url_path - |
| 159 font.GetStringWidth(url_query))) { | 159 font.GetStringWidth(url_query))) { |
| 160 return ElideText(url_subdomain + url_domain + url_path_query_etc, font, | 160 return ElideText(url_subdomain + url_domain + url_path_query_etc, font, |
| 161 available_pixel_width, false); | 161 available_pixel_width, false); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Parse url_path using '/'. | 165 // Parse url_path using '/'. |
| 166 std::vector<std::wstring> url_path_elements; | 166 std::vector<std::wstring> url_path_elements; |
| 167 SplitString(url_path, L'/', &url_path_elements); | 167 base::SplitString(url_path, L'/', &url_path_elements); |
| 168 | 168 |
| 169 // Get filename - note that for a path ending with / | 169 // Get filename - note that for a path ending with / |
| 170 // such as www.google.com/intl/ads/, the file name is ads/. | 170 // such as www.google.com/intl/ads/, the file name is ads/. |
| 171 int url_path_number_of_elements = static_cast<int> (url_path_elements. | 171 int url_path_number_of_elements = static_cast<int> (url_path_elements. |
| 172 size()); | 172 size()); |
| 173 std::wstring url_filename; | 173 std::wstring url_filename; |
| 174 if ((url_path_elements.at(url_path_number_of_elements - 1)).length() > 0) { | 174 if ((url_path_elements.at(url_path_number_of_elements - 1)).length() > 0) { |
| 175 url_filename = *(url_path_elements.end()-1); | 175 url_filename = *(url_path_elements.end()-1); |
| 176 } else if (url_path_number_of_elements > 1) { // Path ends with a '/'. | 176 } else if (url_path_number_of_elements > 1) { // Path ends with a '/'. |
| 177 url_filename = url_path_elements.at(url_path_number_of_elements - 2) + | 177 url_filename = url_path_elements.at(url_path_number_of_elements - 2) + |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 string16 SortedDisplayURL::AfterHost() const { | 445 string16 SortedDisplayURL::AfterHost() const { |
| 446 size_t slash_index = display_url_.find(sort_host_, prefix_end_); | 446 size_t slash_index = display_url_.find(sort_host_, prefix_end_); |
| 447 if (slash_index == string16::npos) { | 447 if (slash_index == string16::npos) { |
| 448 NOTREACHED(); | 448 NOTREACHED(); |
| 449 return string16(); | 449 return string16(); |
| 450 } | 450 } |
| 451 return display_url_.substr(slash_index + sort_host_.length()); | 451 return display_url_.substr(slash_index + sort_host_.length()); |
| 452 } | 452 } |
| 453 | 453 |
| 454 } // namespace gfx | 454 } // namespace gfx |
| OLD | NEW |