From 65576114324ca935e49e868c6d1f4a5e7b86a13f Mon Sep 17 00:00:00 2001 From: estade Date: Fri, 19 Dec 2014 17:18:49 -0800 Subject: [PATCH] Revert changes meant to paper over a crash. The real fix is here: https://codereview.chromium.org/818643002/ This revert will allow us to verify that fix, and catch similar bugs in the future. BUG=438951 Review URL: https://codereview.chromium.org/815243002 Cr-Commit-Position: refs/heads/master@{#309317} --- .../browser/content_autofill_driver_factory.cc | 22 +++++----------------- .../browser/content_autofill_driver_factory.h | 3 ++- .../content_password_manager_driver_factory.cc | 17 ++--------------- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/components/autofill/content/browser/content_autofill_driver_factory.cc b/components/autofill/content/browser/content_autofill_driver_factory.cc index a2cb788e6ed3..d19bd5745656 100644 --- a/components/autofill/content/browser/content_autofill_driver_factory.cc +++ b/components/autofill/content/browser/content_autofill_driver_factory.cc @@ -72,16 +72,12 @@ ContentAutofillDriver* ContentAutofillDriverFactory::DriverForFrame( bool ContentAutofillDriverFactory::OnMessageReceived( const IPC::Message& message, content::RenderFrameHost* render_frame_host) { - auto mapping = frame_driver_map_.find(render_frame_host); - if (mapping == frame_driver_map_.end()) - return false; - - return mapping->second->HandleMessage(message); + return frame_driver_map_[render_frame_host]->HandleMessage(message); } void ContentAutofillDriverFactory::RenderFrameCreated( content::RenderFrameHost* render_frame_host) { - // The driver for the main frame has already been created. + // RenderFrameCreated is called more than once for the main frame. if (!frame_driver_map_[render_frame_host]) CreateDriverForFrame(render_frame_host); } @@ -92,19 +88,11 @@ void ContentAutofillDriverFactory::RenderFrameDeleted( frame_driver_map_.erase(render_frame_host); } -void ContentAutofillDriverFactory::DidNavigateMainFrame( +void ContentAutofillDriverFactory::DidNavigateAnyFrame( + content::RenderFrameHost* rfh, const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) { - // This shouldn't happen, but is causing a lot of crashes. - // See http://crbug.com/438951 - auto mapping = frame_driver_map_.find(web_contents()->GetMainFrame()); - if (mapping == frame_driver_map_.end() || mapping->second == nullptr) { - LOG(ERROR) << "Could not find ContentAutofillDriver for main frame"; - return; - } - - frame_driver_map_[web_contents()->GetMainFrame()]->DidNavigateFrame(details, - params); + frame_driver_map_[rfh]->DidNavigateFrame(details, params); } void ContentAutofillDriverFactory::NavigationEntryCommitted( diff --git a/components/autofill/content/browser/content_autofill_driver_factory.h b/components/autofill/content/browser/content_autofill_driver_factory.h index 84c3b5dee9ad..c0b1aa1bc5f7 100644 --- a/components/autofill/content/browser/content_autofill_driver_factory.h +++ b/components/autofill/content/browser/content_autofill_driver_factory.h @@ -49,7 +49,8 @@ class ContentAutofillDriverFactory : public content::WebContentsObserver, content::RenderFrameHost* render_frame_host) override; void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; - void DidNavigateMainFrame( + void DidNavigateAnyFrame( + content::RenderFrameHost* render_frame_host, const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) override; void NavigationEntryCommitted( diff --git a/components/password_manager/content/browser/content_password_manager_driver_factory.cc b/components/password_manager/content/browser/content_password_manager_driver_factory.cc index a7208c2ece04..f48b584d22a1 100644 --- a/components/password_manager/content/browser/content_password_manager_driver_factory.cc +++ b/components/password_manager/content/browser/content_password_manager_driver_factory.cc @@ -81,7 +81,7 @@ ContentPasswordManagerDriverFactory::GetDriverForFrame( void ContentPasswordManagerDriverFactory::RenderFrameCreated( content::RenderFrameHost* render_frame_host) { - // The driver for the main frame will have already been created. + // This is called twice for the main frame. if (!frame_driver_map_[render_frame_host]) CreateDriverForFrame(render_frame_host); } @@ -95,26 +95,13 @@ void ContentPasswordManagerDriverFactory::RenderFrameDeleted( bool ContentPasswordManagerDriverFactory::OnMessageReceived( const IPC::Message& message, content::RenderFrameHost* render_frame_host) { - auto mapping = frame_driver_map_.find(render_frame_host); - if (mapping == frame_driver_map_.end()) - return false; - - return mapping->second->HandleMessage(message); + return frame_driver_map_[render_frame_host]->HandleMessage(message); } void ContentPasswordManagerDriverFactory::DidNavigateAnyFrame( content::RenderFrameHost* render_frame_host, const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) { - // This shouldn't happen, but is causing a lot of crashes. - // See http://crbug.com/438951 - auto mapping = frame_driver_map_.find(render_frame_host); - if (mapping == frame_driver_map_.end() || mapping->second == nullptr) { - LOG(ERROR) << "Could not find ContentPasswordManagerDriver for frame " << - render_frame_host; - return; - } - frame_driver_map_[render_frame_host]->DidNavigateFrame(details, params); } -- 2.11.4.GIT