OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/navigation_entry_impl.h" | 5 #include "content/browser/frame_host/navigation_entry_impl.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "components/url_formatter/url_formatter.h" |
12 #include "content/common/navigation_params.h" | 13 #include "content/common/navigation_params.h" |
13 #include "content/public/common/content_constants.h" | 14 #include "content/public/common/content_constants.h" |
14 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
15 #include "net/base/net_util.h" | |
16 #include "ui/gfx/text_elider.h" | 16 #include "ui/gfx/text_elider.h" |
17 | 17 |
18 // Use this to get a new unique ID for a NavigationEntry during construction. | 18 // Use this to get a new unique ID for a NavigationEntry during construction. |
19 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). | 19 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). |
20 static int GetUniqueIDInConstructor() { | 20 static int GetUniqueIDInConstructor() { |
21 static int unique_id_counter = 0; | 21 static int unique_id_counter = 0; |
22 return ++unique_id_counter; | 22 return ++unique_id_counter; |
23 } | 23 } |
24 | 24 |
25 namespace content { | 25 namespace content { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 return title_; | 215 return title_; |
216 | 216 |
217 // More complicated cases will use the URLs as the title. This result we will | 217 // More complicated cases will use the URLs as the title. This result we will |
218 // cache since it's more complicated to compute. | 218 // cache since it's more complicated to compute. |
219 if (!cached_display_title_.empty()) | 219 if (!cached_display_title_.empty()) |
220 return cached_display_title_; | 220 return cached_display_title_; |
221 | 221 |
222 // Use the virtual URL first if any, and fall back on using the real URL. | 222 // Use the virtual URL first if any, and fall back on using the real URL. |
223 base::string16 title; | 223 base::string16 title; |
224 if (!virtual_url_.is_empty()) { | 224 if (!virtual_url_.is_empty()) { |
225 title = net::FormatUrl(virtual_url_, languages); | 225 title = url_formatter::FormatUrl(virtual_url_, languages); |
226 } else if (!GetURL().is_empty()) { | 226 } else if (!GetURL().is_empty()) { |
227 title = net::FormatUrl(GetURL(), languages); | 227 title = url_formatter::FormatUrl(GetURL(), languages); |
228 } | 228 } |
229 | 229 |
230 // For file:// URLs use the filename as the title, not the full path. | 230 // For file:// URLs use the filename as the title, not the full path. |
231 if (GetURL().SchemeIsFile()) { | 231 if (GetURL().SchemeIsFile()) { |
232 // It is necessary to ignore the reference and query parameters or else | 232 // It is necessary to ignore the reference and query parameters or else |
233 // looking for slashes might accidentally return one of those values. See | 233 // looking for slashes might accidentally return one of those values. See |
234 // https://crbug.com/503003. | 234 // https://crbug.com/503003. |
235 base::string16::size_type refpos = title.find('#'); | 235 base::string16::size_type refpos = title.find('#'); |
236 base::string16::size_type querypos = title.find('?'); | 236 base::string16::size_type querypos = title.find('?'); |
237 base::string16::size_type lastpos; | 237 base::string16::size_type lastpos; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 return node; | 601 return node; |
602 } | 602 } |
603 // Enqueue any children and keep looking. | 603 // Enqueue any children and keep looking. |
604 for (auto& child : node->children) | 604 for (auto& child : node->children) |
605 work_queue.push(child); | 605 work_queue.push(child); |
606 } | 606 } |
607 return nullptr; | 607 return nullptr; |
608 } | 608 } |
609 | 609 |
610 } // namespace content | 610 } // namespace content |
OLD | NEW |