| 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 427 |
| 428 PluginInstaller* TabContents::GetPluginInstaller() { | 428 PluginInstaller* TabContents::GetPluginInstaller() { |
| 429 if (plugin_installer_.get() == NULL) | 429 if (plugin_installer_.get() == NULL) |
| 430 plugin_installer_.reset(new PluginInstaller(this)); | 430 plugin_installer_.reset(new PluginInstaller(this)); |
| 431 return plugin_installer_.get(); | 431 return plugin_installer_.get(); |
| 432 } | 432 } |
| 433 | 433 |
| 434 const GURL& TabContents::GetURL() const { | 434 const GURL& TabContents::GetURL() const { |
| 435 // We may not have a navigation entry yet | 435 // We may not have a navigation entry yet |
| 436 NavigationEntry* entry = controller_.GetActiveEntry(); | 436 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 437 return entry ? entry->display_url() : GURL::EmptyGURL(); | 437 return entry ? entry->virtual_url() : GURL::EmptyGURL(); |
| 438 } | 438 } |
| 439 | 439 |
| 440 const string16& TabContents::GetTitle() const { | 440 const string16& TabContents::GetTitle() const { |
| 441 // Transient entries take precedence. They are used for interstitial pages | 441 // Transient entries take precedence. They are used for interstitial pages |
| 442 // that are shown on top of existing pages. | 442 // that are shown on top of existing pages. |
| 443 NavigationEntry* entry = controller_.GetTransientEntry(); | 443 NavigationEntry* entry = controller_.GetTransientEntry(); |
| 444 if (entry) | 444 if (entry) |
| 445 return entry->GetTitleForDisplay(&controller_); | 445 return entry->GetTitleForDisplay(&controller_); |
| 446 | 446 |
| 447 DOMUI* our_dom_ui = render_manager_.pending_dom_ui() ? | 447 DOMUI* our_dom_ui = render_manager_.pending_dom_ui() ? |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 // need to reserve enough IDs to make all restored page IDs less than | 1346 // need to reserve enough IDs to make all restored page IDs less than |
| 1347 // the max. | 1347 // the max. |
| 1348 if (curr_max_page_id < 0) | 1348 if (curr_max_page_id < 0) |
| 1349 curr_max_page_id = 0; | 1349 curr_max_page_id = 0; |
| 1350 rvh->ReservePageIDRange(max_restored_page_id - curr_max_page_id); | 1350 rvh->ReservePageIDRange(max_restored_page_id - curr_max_page_id); |
| 1351 } | 1351 } |
| 1352 } | 1352 } |
| 1353 } | 1353 } |
| 1354 | 1354 |
| 1355 void TabContents::UpdateHistoryForNavigation( | 1355 void TabContents::UpdateHistoryForNavigation( |
| 1356 const GURL& display_url, | 1356 const GURL& virtual_url, |
| 1357 const NavigationController::LoadCommittedDetails& details, | 1357 const NavigationController::LoadCommittedDetails& details, |
| 1358 const ViewHostMsg_FrameNavigate_Params& params) { | 1358 const ViewHostMsg_FrameNavigate_Params& params) { |
| 1359 if (profile()->IsOffTheRecord()) | 1359 if (profile()->IsOffTheRecord()) |
| 1360 return; | 1360 return; |
| 1361 | 1361 |
| 1362 // Add to history service. | 1362 // Add to history service. |
| 1363 HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); | 1363 HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); |
| 1364 if (hs) { | 1364 if (hs) { |
| 1365 if (PageTransition::IsMainFrame(params.transition) && | 1365 if (PageTransition::IsMainFrame(params.transition) && |
| 1366 display_url != params.url) { | 1366 virtual_url != params.url) { |
| 1367 // Hack on the "display" URL so that it will appear in history. For some | 1367 // Hack on the "virtual" URL so that it will appear in history. For some |
| 1368 // types of URLs, we will display a magic URL that is different from where | 1368 // types of URLs, we will display a magic URL that is different from where |
| 1369 // the page is actually navigated. We want the user to see in history | 1369 // the page is actually navigated. We want the user to see in history |
| 1370 // what they saw in the URL bar, so we add the display URL as a redirect. | 1370 // what they saw in the URL bar, so we add the virtual URL as a redirect. |
| 1371 // This only applies to the main frame, as the display URL doesn't apply | 1371 // This only applies to the main frame, as the virtual URL doesn't apply |
| 1372 // to sub-frames. | 1372 // to sub-frames. |
| 1373 std::vector<GURL> redirects = params.redirects; | 1373 std::vector<GURL> redirects = params.redirects; |
| 1374 if (!redirects.empty()) | 1374 if (!redirects.empty()) |
| 1375 redirects.back() = display_url; | 1375 redirects.back() = virtual_url; |
| 1376 hs->AddPage(display_url, this, params.page_id, params.referrer, | 1376 hs->AddPage(virtual_url, this, params.page_id, params.referrer, |
| 1377 params.transition, redirects, details.did_replace_entry); | 1377 params.transition, redirects, details.did_replace_entry); |
| 1378 } else { | 1378 } else { |
| 1379 hs->AddPage(params.url, this, params.page_id, params.referrer, | 1379 hs->AddPage(params.url, this, params.page_id, params.referrer, |
| 1380 params.transition, params.redirects, | 1380 params.transition, params.redirects, |
| 1381 details.did_replace_entry); | 1381 details.did_replace_entry); |
| 1382 } | 1382 } |
| 1383 } | 1383 } |
| 1384 } | 1384 } |
| 1385 | 1385 |
| 1386 bool TabContents::UpdateTitleForEntry(NavigationEntry* entry, | 1386 bool TabContents::UpdateTitleForEntry(NavigationEntry* entry, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1401 if (final_title == UTF16ToWideHack(entry->title())) | 1401 if (final_title == UTF16ToWideHack(entry->title())) |
| 1402 return false; // Nothing changed, don't bother. | 1402 return false; // Nothing changed, don't bother. |
| 1403 | 1403 |
| 1404 entry->set_title(WideToUTF16Hack(final_title)); | 1404 entry->set_title(WideToUTF16Hack(final_title)); |
| 1405 | 1405 |
| 1406 // Update the history system for this page. | 1406 // Update the history system for this page. |
| 1407 if (!profile()->IsOffTheRecord() && !received_page_title_) { | 1407 if (!profile()->IsOffTheRecord() && !received_page_title_) { |
| 1408 HistoryService* hs = | 1408 HistoryService* hs = |
| 1409 profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); | 1409 profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); |
| 1410 if (hs) | 1410 if (hs) |
| 1411 hs->SetPageTitle(entry->display_url(), final_title); | 1411 hs->SetPageTitle(entry->virtual_url(), final_title); |
| 1412 | 1412 |
| 1413 // Don't allow the title to be saved again for explicitly set ones. | 1413 // Don't allow the title to be saved again for explicitly set ones. |
| 1414 received_page_title_ = explicit_set; | 1414 received_page_title_ = explicit_set; |
| 1415 } | 1415 } |
| 1416 | 1416 |
| 1417 // Lastly, set the title for the view. | 1417 // Lastly, set the title for the view. |
| 1418 view_->SetPageTitle(final_title); | 1418 view_->SetPageTitle(final_title); |
| 1419 | 1419 |
| 1420 return true; | 1420 return true; |
| 1421 } | 1421 } |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 // An entry may not exist for a stop when loading an initial blank page or | 1993 // An entry may not exist for a stop when loading an initial blank page or |
| 1994 // if an iframe injected by script into a blank page finishes loading. | 1994 // if an iframe injected by script into a blank page finishes loading. |
| 1995 if (entry) { | 1995 if (entry) { |
| 1996 scoped_ptr<base::ProcessMetrics> metrics( | 1996 scoped_ptr<base::ProcessMetrics> metrics( |
| 1997 base::ProcessMetrics::CreateProcessMetrics( | 1997 base::ProcessMetrics::CreateProcessMetrics( |
| 1998 process()->process().handle())); | 1998 process()->process().handle())); |
| 1999 | 1999 |
| 2000 base::TimeDelta elapsed = base::TimeTicks::Now() - current_load_start_; | 2000 base::TimeDelta elapsed = base::TimeTicks::Now() - current_load_start_; |
| 2001 | 2001 |
| 2002 details.reset(new LoadNotificationDetails( | 2002 details.reset(new LoadNotificationDetails( |
| 2003 entry->display_url(), | 2003 entry->virtual_url(), |
| 2004 entry->transition_type(), | 2004 entry->transition_type(), |
| 2005 elapsed, | 2005 elapsed, |
| 2006 &controller_, | 2006 &controller_, |
| 2007 controller_.GetCurrentEntryIndex())); | 2007 controller_.GetCurrentEntryIndex())); |
| 2008 } | 2008 } |
| 2009 | 2009 |
| 2010 // Tell PasswordManager we've finished a page load, which serves as a | 2010 // Tell PasswordManager we've finished a page load, which serves as a |
| 2011 // green light to save pending passwords and reset itself. | 2011 // green light to save pending passwords and reset itself. |
| 2012 GetPasswordManager()->DidStopLoading(); | 2012 GetPasswordManager()->DidStopLoading(); |
| 2013 | 2013 |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2407 NavigationController::LoadCommittedDetails& committed_details = | 2407 NavigationController::LoadCommittedDetails& committed_details = |
| 2408 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); | 2408 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); |
| 2409 ExpireInfoBars(committed_details); | 2409 ExpireInfoBars(committed_details); |
| 2410 break; | 2410 break; |
| 2411 } | 2411 } |
| 2412 | 2412 |
| 2413 default: | 2413 default: |
| 2414 NOTREACHED(); | 2414 NOTREACHED(); |
| 2415 } | 2415 } |
| 2416 } | 2416 } |
| OLD | NEW |