OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 // reload the page to stop blocking. | 1239 // reload the page to stop blocking. |
1240 suppress_javascript_messages_ = false; | 1240 suppress_javascript_messages_ = false; |
1241 | 1241 |
1242 // Update history. Note that this needs to happen after the entry is complete, | 1242 // Update history. Note that this needs to happen after the entry is complete, |
1243 // which WillNavigate[Main,Sub]Frame will do before this function is called. | 1243 // which WillNavigate[Main,Sub]Frame will do before this function is called. |
1244 if (params.should_update_history) { | 1244 if (params.should_update_history) { |
1245 // Most of the time, the displayURL matches the loaded URL, but for about: | 1245 // Most of the time, the displayURL matches the loaded URL, but for about: |
1246 // URLs, we use a data: URL as the real value. We actually want to save | 1246 // URLs, we use a data: URL as the real value. We actually want to save |
1247 // the about: URL to the history db and keep the data: URL hidden. This is | 1247 // the about: URL to the history db and keep the data: URL hidden. This is |
1248 // what the TabContents' URL getter does. | 1248 // what the TabContents' URL getter does. |
1249 UpdateHistoryForNavigation(GetURL(), params); | 1249 UpdateHistoryForNavigation(GetURL(), details, params); |
1250 } | 1250 } |
1251 | 1251 |
1252 // Notify the password manager of the navigation or form submit. | 1252 // Notify the password manager of the navigation or form submit. |
1253 // TODO(brettw) bug 1343111: Password manager stuff in here needs to be | 1253 // TODO(brettw) bug 1343111: Password manager stuff in here needs to be |
1254 // cleaned up and covered by tests. | 1254 // cleaned up and covered by tests. |
1255 if (params.password_form.origin.is_valid()) | 1255 if (params.password_form.origin.is_valid()) |
1256 GetPasswordManager()->ProvisionallySavePassword(params.password_form); | 1256 GetPasswordManager()->ProvisionallySavePassword(params.password_form); |
1257 } | 1257 } |
1258 | 1258 |
1259 void TabContents::MaybeCloseChildWindows(const GURL& previous_url, | 1259 void TabContents::MaybeCloseChildWindows(const GURL& previous_url, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 // the max. | 1311 // the max. |
1312 if (curr_max_page_id < 0) | 1312 if (curr_max_page_id < 0) |
1313 curr_max_page_id = 0; | 1313 curr_max_page_id = 0; |
1314 rvh->ReservePageIDRange(max_restored_page_id - curr_max_page_id); | 1314 rvh->ReservePageIDRange(max_restored_page_id - curr_max_page_id); |
1315 } | 1315 } |
1316 } | 1316 } |
1317 } | 1317 } |
1318 | 1318 |
1319 void TabContents::UpdateHistoryForNavigation( | 1319 void TabContents::UpdateHistoryForNavigation( |
1320 const GURL& display_url, | 1320 const GURL& display_url, |
| 1321 const NavigationController::LoadCommittedDetails& details, |
1321 const ViewHostMsg_FrameNavigate_Params& params) { | 1322 const ViewHostMsg_FrameNavigate_Params& params) { |
1322 if (profile()->IsOffTheRecord()) | 1323 if (profile()->IsOffTheRecord()) |
1323 return; | 1324 return; |
1324 | 1325 |
1325 // Add to history service. | 1326 // Add to history service. |
1326 HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); | 1327 HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); |
1327 if (hs) { | 1328 if (hs) { |
1328 if (PageTransition::IsMainFrame(params.transition) && | 1329 if (PageTransition::IsMainFrame(params.transition) && |
1329 display_url != params.url) { | 1330 display_url != params.url) { |
1330 // Hack on the "display" URL so that it will appear in history. For some | 1331 // Hack on the "display" URL so that it will appear in history. For some |
1331 // types of URLs, we will display a magic URL that is different from where | 1332 // types of URLs, we will display a magic URL that is different from where |
1332 // the page is actually navigated. We want the user to see in history | 1333 // the page is actually navigated. We want the user to see in history |
1333 // what they saw in the URL bar, so we add the display URL as a redirect. | 1334 // what they saw in the URL bar, so we add the display URL as a redirect. |
1334 // This only applies to the main frame, as the display URL doesn't apply | 1335 // This only applies to the main frame, as the display URL doesn't apply |
1335 // to sub-frames. | 1336 // to sub-frames. |
1336 std::vector<GURL> redirects = params.redirects; | 1337 std::vector<GURL> redirects = params.redirects; |
1337 if (!redirects.empty()) | 1338 if (!redirects.empty()) |
1338 redirects.back() = display_url; | 1339 redirects.back() = display_url; |
1339 hs->AddPage(display_url, this, params.page_id, params.referrer, | 1340 hs->AddPage(display_url, this, params.page_id, params.referrer, |
1340 params.transition, redirects); | 1341 params.transition, redirects, details.did_replace_entry); |
1341 } else { | 1342 } else { |
1342 hs->AddPage(params.url, this, params.page_id, params.referrer, | 1343 hs->AddPage(params.url, this, params.page_id, params.referrer, |
1343 params.transition, params.redirects); | 1344 params.transition, params.redirects, |
| 1345 details.did_replace_entry); |
1344 } | 1346 } |
1345 } | 1347 } |
1346 } | 1348 } |
1347 | 1349 |
1348 bool TabContents::UpdateTitleForEntry(NavigationEntry* entry, | 1350 bool TabContents::UpdateTitleForEntry(NavigationEntry* entry, |
1349 const std::wstring& title) { | 1351 const std::wstring& title) { |
1350 // For file URLs without a title, use the pathname instead. In the case of a | 1352 // For file URLs without a title, use the pathname instead. In the case of a |
1351 // synthesized title, we don't want the update to count toward the "one set | 1353 // synthesized title, we don't want the update to count toward the "one set |
1352 // per page of the title to history." | 1354 // per page of the title to history." |
1353 std::wstring final_title; | 1355 std::wstring final_title; |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2341 NavigationController::LoadCommittedDetails& committed_details = | 2343 NavigationController::LoadCommittedDetails& committed_details = |
2342 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); | 2344 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); |
2343 ExpireInfoBars(committed_details); | 2345 ExpireInfoBars(committed_details); |
2344 break; | 2346 break; |
2345 } | 2347 } |
2346 | 2348 |
2347 default: | 2349 default: |
2348 NOTREACHED(); | 2350 NOTREACHED(); |
2349 } | 2351 } |
2350 } | 2352 } |
OLD | NEW |