diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-14 15:42:43 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-14 15:42:43 +0000 |
commit | e9ba44740c88677d8b566583f7041d1dd33b6a9d (patch) | |
tree | 0d85125a089ba6c36136a22651d196a9ba86ec8f /chrome/browser/ssl_blocking_page.cc | |
parent | b5ef2ca48635ddf96698a11676a4625aff6ef734 (diff) | |
download | chromium_src-e9ba44740c88677d8b566583f7041d1dd33b6a9d.zip chromium_src-e9ba44740c88677d8b566583f7041d1dd33b6a9d.tar.gz chromium_src-e9ba44740c88677d8b566583f7041d1dd33b6a9d.tar.bz2 |
This is almost a complete rewrite of DidNavigate and the associated NavigationController logic. The approach is that the NavigationController should be responsible for the logic and memory management of navigation. Previously, half the logic and memory management lived in WebContents which made it very hard to figure out what was going on.
I split out the various navigation types into separate functions, which then copy and update any existing NavigationEntry as necessary. Previously, WebContents would make a new one which would be manually populated with random fields (I think some were forgotten, too), and then the NavigationController may or may not commit it.
Review URL: http://codereview.chromium.org/479
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2201 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ssl_blocking_page.cc')
-rw-r--r-- | chrome/browser/ssl_blocking_page.cc | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/chrome/browser/ssl_blocking_page.cc b/chrome/browser/ssl_blocking_page.cc index 699c9e2..ba90efe 100644 --- a/chrome/browser/ssl_blocking_page.cc +++ b/chrome/browser/ssl_blocking_page.cc @@ -51,7 +51,7 @@ SSLBlockingPage::SSLBlockingPage(SSLManager::CertError* error, // Since WebContents::InterstitialPageGone won't be called, we need // to clear the last NavigationEntry manually. - tab_->controller()->RemoveLastEntry(); + tab_->controller()->RemoveLastEntryForInterstitial(); } (*tab_to_blocking_page_)[tab_] = this; @@ -132,31 +132,31 @@ void SSLBlockingPage::Show() { int cert_id = CertStore::GetSharedInstance()->StoreCert( ssl_info.cert, tab->render_view_host()->process()->host_id()); - NavigationEntry* nav_entry = new NavigationEntry(TAB_CONTENTS_WEB); if (tab_->controller()->GetPendingEntryIndex() == -1) { - // New navigation. - // We set the page ID to max page id so to ensure the controller considers - // this dummy entry a new one. Because we'll remove the entry when the - // interstitial is going away, it will not conflict with any future - // navigations. + // For new navigations, we just create a new navigation entry. + NavigationEntry new_entry(TAB_CONTENTS_WEB); + new_entry.set_url(error_->request_url()); + tab_->controller()->AddDummyEntryForInterstitial(new_entry); created_nav_entry_ = true; - nav_entry->set_page_id(tab_->GetMaxPageID() + 1); - nav_entry->set_url(error_->request_url()); } else { - // Make sure to update the current entry ssl state to reflect the error. - *nav_entry = *(tab_->controller()->GetPendingEntry()); + // When there is a pending entry index, that means we're doing a + // back/forward navigation. Clone that entry instead. + tab_->controller()->AddDummyEntryForInterstitial( + *tab_->controller()->GetPendingEntry()); } - nav_entry->set_page_type(NavigationEntry::INTERSTITIAL_PAGE); - nav_entry->ssl().set_security_style(SECURITY_STYLE_AUTHENTICATION_BROKEN); - nav_entry->ssl().set_cert_id(cert_id); - nav_entry->ssl().set_cert_status(ssl_info.cert_status); - nav_entry->ssl().set_security_bits(ssl_info.security_bits); - // The controller will own the entry. - - // The default details is "new navigation", and that's OK with us. - NavigationController::LoadCommittedDetails details; - tab_->controller()->DidNavigateToEntry(nav_entry, &details); + NavigationEntry* entry = tab_->controller()->GetActiveEntry(); + entry->set_page_type(NavigationEntry::INTERSTITIAL_PAGE); + + entry->ssl().set_security_style(SECURITY_STYLE_AUTHENTICATION_BROKEN); + entry->ssl().set_cert_id(cert_id); + entry->ssl().set_cert_status(ssl_info.cert_status); + entry->ssl().set_security_bits(ssl_info.security_bits); + NotificationService::current()->Notify( + NOTIFY_SSL_STATE_CHANGED, + Source<NavigationController>(tab_->controller()), + NotificationService::NoDetails()); + tab->ShowInterstitialPage(html_text, NULL); } @@ -176,7 +176,7 @@ void SSLBlockingPage::Observe(NotificationType type, // as their navigation history is not saved. if (remove_last_entry_ && browser && !browser->tabstrip_model()->closing_all()) { - tab_->controller()->RemoveLastEntry(); + tab_->controller()->RemoveLastEntryForInterstitial(); } delete this; break; @@ -220,7 +220,7 @@ void SSLBlockingPage::DontProceed() { // We are navigating, remove the current entry before we mess with it. remove_last_entry_ = false; - tab_->controller()->RemoveLastEntry(); + tab_->controller()->RemoveLastEntryForInterstitial(); NavigationEntry* entry = tab_->controller()->GetActiveEntry(); if (!entry) { |