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

Side by Side Diff: content/browser/tab_contents/navigation_entry.cc

Issue 6591127: fix display of filenames in file:/// URLs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: whitespace Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/tab_contents/navigation_entry.h" 5 #include "content/browser/tab_contents/navigation_entry.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 if (!cached_display_title_.empty()) 87 if (!cached_display_title_.empty())
88 return cached_display_title_; 88 return cached_display_title_;
89 89
90 // Use the virtual URL first if any, and fall back on using the real URL. 90 // Use the virtual URL first if any, and fall back on using the real URL.
91 string16 title; 91 string16 title;
92 if (!virtual_url_.is_empty()) { 92 if (!virtual_url_.is_empty()) {
93 title = net::FormatUrl(virtual_url_, languages); 93 title = net::FormatUrl(virtual_url_, languages);
94 } else if (!url_.is_empty()) { 94 } else if (!url_.is_empty()) {
95 title = net::FormatUrl(url_, languages); 95 title = net::FormatUrl(url_, languages);
96 } 96 }
97
98 // For file:// URLs use the filename as the title, not the full path.
99 if (url_.SchemeIsFile()) {
100 string16::size_type slashpos = title.rfind('/');
101 if (slashpos != string16::npos)
102 title = title.substr(slashpos + 1);
103 }
104
97 ui::ElideString(title, chrome::kMaxTitleChars, &cached_display_title_); 105 ui::ElideString(title, chrome::kMaxTitleChars, &cached_display_title_);
98 return cached_display_title_; 106 return cached_display_title_;
99 } 107 }
100 108
101 bool NavigationEntry::IsViewSourceMode() const { 109 bool NavigationEntry::IsViewSourceMode() const {
102 return virtual_url_.SchemeIs(chrome::kViewSourceScheme); 110 return virtual_url_.SchemeIs(chrome::kViewSourceScheme);
103 } 111 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/navigation_controller.cc ('k') | content/browser/tab_contents/navigation_entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698