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

Side by Side Diff: content/browser/tab_contents/navigation_controller.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
« no previous file with comments | « no previous file | content/browser/tab_contents/navigation_entry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/tab_contents/navigation_controller.h" 5 #include "content/browser/tab_contents/navigation_controller.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 NULL, // The site instance for tabs is sent on navigation 236 NULL, // The site instance for tabs is sent on navigation
237 // (TabContents::GetSiteInstance). 237 // (TabContents::GetSiteInstance).
238 -1, 238 -1,
239 loaded_url, 239 loaded_url,
240 referrer, 240 referrer,
241 string16(), 241 string16(),
242 transition); 242 transition);
243 entry->set_virtual_url(url); 243 entry->set_virtual_url(url);
244 entry->set_user_typed_url(url); 244 entry->set_user_typed_url(url);
245 entry->set_update_virtual_url_with_url(reverse_on_redirect); 245 entry->set_update_virtual_url_with_url(reverse_on_redirect);
246 if (url.SchemeIsFile()) {
247 // Use the filename as the title, not the full path.
248 // We need to call FormatUrl() to perform URL de-escaping;
249 // it's a bit ugly to grab the filename out of the resulting string.
250 std::string languages =
251 profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
252 std::wstring formatted = UTF16ToWideHack(net::FormatUrl(url, languages));
253 std::wstring filename =
254 FilePath::FromWStringHack(formatted).BaseName().ToWStringHack();
255 entry->set_title(WideToUTF16Hack(filename));
256 }
257 return entry; 246 return entry;
258 } 247 }
259 248
260 NavigationEntry* NavigationController::GetEntryWithPageID( 249 NavigationEntry* NavigationController::GetEntryWithPageID(
261 SiteInstance* instance, int32 page_id) const { 250 SiteInstance* instance, int32 page_id) const {
262 int index = GetEntryIndexWithPageID(instance, page_id); 251 int index = GetEntryIndexWithPageID(instance, page_id);
263 return (index != -1) ? entries_[index].get() : NULL; 252 return (index != -1) ? entries_[index].get() : NULL;
264 } 253 }
265 254
266 void NavigationController::LoadEntry(NavigationEntry* entry) { 255 void NavigationController::LoadEntry(NavigationEntry* entry) {
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 size_t insert_index = 0; 1185 size_t insert_index = 0;
1197 for (int i = 0; i < max_index; i++) { 1186 for (int i = 0; i < max_index; i++) {
1198 // When cloning a tab, copy all entries except interstitial pages 1187 // When cloning a tab, copy all entries except interstitial pages
1199 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) { 1188 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) {
1200 entries_.insert(entries_.begin() + insert_index++, 1189 entries_.insert(entries_.begin() + insert_index++,
1201 linked_ptr<NavigationEntry>( 1190 linked_ptr<NavigationEntry>(
1202 new NavigationEntry(*source.entries_[i]))); 1191 new NavigationEntry(*source.entries_[i])));
1203 } 1192 }
1204 } 1193 }
1205 } 1194 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/tab_contents/navigation_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698