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

Unified Diff: ios/web/navigation/navigation_item_impl.mm

Issue 2722983003: Reland Tab History and BrowserViewController CRWSessionEntry removal. (Closed)
Patch Set: TODO, early return Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/navigation/navigation_item_impl.h ('k') | ios/web/public/test/url_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/navigation/navigation_item_impl.mm
diff --git a/ios/web/navigation/navigation_item_impl.mm b/ios/web/navigation/navigation_item_impl.mm
index 31f357566080a0b3b5613312130691500edc34bc..3153ed18ba356af336c41ef9ed36e1e317087395 100644
--- a/ios/web/navigation/navigation_item_impl.mm
+++ b/ios/web/navigation/navigation_item_impl.mm
@@ -154,23 +154,8 @@ static int GetUniqueIDInConstructor() {
if (!cached_display_title_.empty())
return cached_display_title_;
- // Use the virtual URL first if any, and fall back on using the real URL.
- base::string16 title;
- if (!virtual_url_.is_empty()) {
- title = url_formatter::FormatUrl(virtual_url_);
- } else if (!url_.is_empty()) {
- title = url_formatter::FormatUrl(url_);
- }
-
- // For file:// URLs use the filename as the title, not the full path.
- if (url_.SchemeIsFile()) {
- base::string16::size_type slashpos = title.rfind('/');
- if (slashpos != base::string16::npos)
- title = title.substr(slashpos + 1);
- }
-
- const size_t kMaxTitleChars = 4 * 1024;
- gfx::ElideString(title, kMaxTitleChars, &cached_display_title_);
+ cached_display_title_ =
+ NavigationItemImpl::GetDisplayTitleForURL(GetVirtualURL());
return cached_display_title_;
}
@@ -310,4 +295,23 @@ static int GetUniqueIDInConstructor() {
SetNavigationInitiationType(web::NavigationInitiationType::NONE);
}
+// static
+base::string16 NavigationItemImpl::GetDisplayTitleForURL(const GURL& url) {
+ if (url.is_empty())
+ return base::string16();
+
+ base::string16 title = url_formatter::FormatUrl(url);
+
+ // For file:// URLs use the filename as the title, not the full path.
+ if (url.SchemeIsFile()) {
+ base::string16::size_type slashpos = title.rfind('/');
+ if (slashpos != base::string16::npos)
+ title = title.substr(slashpos + 1);
+ }
+
+ const size_t kMaxTitleChars = 4 * 1024;
+ gfx::ElideString(title, kMaxTitleChars, &title);
+ return title;
+}
+
} // namespace web
« no previous file with comments | « ios/web/navigation/navigation_item_impl.h ('k') | ios/web/public/test/url_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698