| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 return title_; | 195 return title_; |
| 196 | 196 |
| 197 // More complicated cases will use the URLs as the title. This result we will | 197 // More complicated cases will use the URLs as the title. This result we will |
| 198 // cache since it's more complicated to compute. | 198 // cache since it's more complicated to compute. |
| 199 if (!cached_display_title_.empty()) | 199 if (!cached_display_title_.empty()) |
| 200 return cached_display_title_; | 200 return cached_display_title_; |
| 201 | 201 |
| 202 // Use the virtual URL first if any, and fall back on using the real URL. | 202 // Use the virtual URL first if any, and fall back on using the real URL. |
| 203 base::string16 title; | 203 base::string16 title; |
| 204 if (!virtual_url_.is_empty()) { | 204 if (!virtual_url_.is_empty()) { |
| 205 title = net::FormatUrl(virtual_url_, languages); | 205 title = url_formatter::FormatUrl(virtual_url_, languages); |
| 206 } else if (!GetURL().is_empty()) { | 206 } else if (!GetURL().is_empty()) { |
| 207 title = net::FormatUrl(GetURL(), languages); | 207 title = url_formatter::FormatUrl(GetURL(), languages); |
| 208 } | 208 } |
| 209 | 209 |
| 210 // For file:// URLs use the filename as the title, not the full path. | 210 // For file:// URLs use the filename as the title, not the full path. |
| 211 if (GetURL().SchemeIsFile()) { | 211 if (GetURL().SchemeIsFile()) { |
| 212 base::string16::size_type slashpos = title.rfind('/'); | 212 base::string16::size_type slashpos = title.rfind('/'); |
| 213 if (slashpos != base::string16::npos) | 213 if (slashpos != base::string16::npos) |
| 214 title = title.substr(slashpos + 1); | 214 title = title.substr(slashpos + 1); |
| 215 } | 215 } |
| 216 | 216 |
| 217 gfx::ElideString(title, kMaxTitleChars, &cached_display_title_); | 217 gfx::ElideString(title, kMaxTitleChars, &cached_display_title_); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 return node; | 551 return node; |
| 552 } | 552 } |
| 553 // Enqueue any children and keep looking. | 553 // Enqueue any children and keep looking. |
| 554 for (auto& child : node->children) | 554 for (auto& child : node->children) |
| 555 work_queue.push(child); | 555 work_queue.push(child); |
| 556 } | 556 } |
| 557 return nullptr; | 557 return nullptr; |
| 558 } | 558 } |
| 559 | 559 |
| 560 } // namespace content | 560 } // namespace content |
| OLD | NEW |