| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |