| Index: components/autofill/content/browser/content_autofill_driver_factory.cc
|
| diff --git a/components/autofill/content/browser/content_autofill_driver_factory.cc b/components/autofill/content/browser/content_autofill_driver_factory.cc
|
| index 32465df8fa498a67799d01335e68350f1d6cad54..70422d422df7deb66426137b3c1503576d616c2e 100644
|
| --- a/components/autofill/content/browser/content_autofill_driver_factory.cc
|
| +++ b/components/autofill/content/browser/content_autofill_driver_factory.cc
|
| @@ -4,8 +4,10 @@
|
|
|
| #include "components/autofill/content/browser/content_autofill_driver_factory.h"
|
|
|
| +#include <utility>
|
| #include <vector>
|
|
|
| +#include "base/bind.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/stl_util.h"
|
| #include "components/autofill/content/browser/content_autofill_driver.h"
|
| @@ -13,12 +15,26 @@
|
| #include "components/autofill/core/browser/autofill_manager.h"
|
| #include "components/autofill/core/browser/form_structure.h"
|
| #include "components/autofill/core/common/autofill_switches.h"
|
| +#include "content/public/browser/navigation_details.h"
|
| #include "content/public/browser/navigation_handle.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/web_contents.h"
|
|
|
| namespace autofill {
|
|
|
| +namespace {
|
| +
|
| +std::unique_ptr<AutofillDriver> CreateDriver(
|
| + content::RenderFrameHost* host,
|
| + AutofillClient* client,
|
| + const std::string& app_locale,
|
| + AutofillManager::AutofillDownloadManagerState enable_download_manager) {
|
| + return base::MakeUnique<ContentAutofillDriver>(host, client, app_locale,
|
| + enable_download_manager);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| const char ContentAutofillDriverFactory::
|
| kContentAutofillDriverFactoryWebContentsUserDataKey[] =
|
| "web_contents_autofill_driver_factory";
|
| @@ -35,7 +51,8 @@ void ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
|
| return;
|
|
|
| auto new_factory = base::WrapUnique(new ContentAutofillDriverFactory(
|
| - contents, client, app_locale, enable_download_manager));
|
| + contents, client, app_locale, enable_download_manager,
|
| + base::Bind(CreateDriver)));
|
| const std::vector<content::RenderFrameHost*> frames =
|
| contents->GetAllFrames();
|
| for (content::RenderFrameHost* frame : frames) {
|
| @@ -73,7 +90,8 @@ void ContentAutofillDriverFactory::BindAutofillDriver(
|
| if (!factory)
|
| return;
|
|
|
| - ContentAutofillDriver* driver = factory->DriverForFrame(render_frame_host);
|
| + ContentAutofillDriver* driver = static_cast<ContentAutofillDriver*>(
|
| + factory->DriverForFrame(render_frame_host));
|
| if (driver)
|
| driver->BindRequest(std::move(request));
|
| }
|
| @@ -82,13 +100,15 @@ ContentAutofillDriverFactory::ContentAutofillDriverFactory(
|
| content::WebContents* web_contents,
|
| AutofillClient* client,
|
| const std::string& app_locale,
|
| - AutofillManager::AutofillDownloadManagerState enable_download_manager)
|
| + AutofillManager::AutofillDownloadManagerState enable_download_manager,
|
| + DriverCreator driver_creator)
|
| : content::WebContentsObserver(web_contents),
|
| client_(client),
|
| app_locale_(app_locale),
|
| - enable_download_manager_(enable_download_manager) {}
|
| + enable_download_manager_(enable_download_manager),
|
| + driver_creator_(std::move(driver_creator)) {}
|
|
|
| -ContentAutofillDriver* ContentAutofillDriverFactory::DriverForFrame(
|
| +AutofillDriver* ContentAutofillDriverFactory::DriverForFrame(
|
| content::RenderFrameHost* render_frame_host) {
|
| auto mapping = frame_driver_map_.find(render_frame_host);
|
| return mapping == frame_driver_map_.end() ? nullptr : mapping->second.get();
|
| @@ -100,7 +120,7 @@ void ContentAutofillDriverFactory::RenderFrameCreated(
|
| frame_driver_map_.insert(std::make_pair(render_frame_host, nullptr));
|
| // This is called twice for the main frame.
|
| if (insertion_result.second) { // This was the first time.
|
| - insertion_result.first->second = base::MakeUnique<ContentAutofillDriver>(
|
| + insertion_result.first->second = driver_creator_.Run(
|
| render_frame_host, client_, app_locale_, enable_download_manager_);
|
| }
|
| }
|
| @@ -114,7 +134,8 @@ void ContentAutofillDriverFactory::DidNavigateAnyFrame(
|
| content::RenderFrameHost* render_frame_host,
|
| const content::LoadCommittedDetails& details,
|
| const content::FrameNavigateParams& params) {
|
| - frame_driver_map_[render_frame_host]->DidNavigateFrame(details, params);
|
| + if (details.is_navigation_to_different_page())
|
| + frame_driver_map_[render_frame_host]->NavigatedToDifferentPage();
|
| }
|
|
|
| void ContentAutofillDriverFactory::DidFinishNavigation(
|
|
|