diff options
author | estade <estade@chromium.org> | 2014-12-02 14:44:11 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-02 22:44:55 +0000 |
commit | b1bc9bd012abbbb06eac639cda41dffd07b20ef4 (patch) | |
tree | 1ddb5101b9a8b51c8ad02e620cbb4e3bbdc1639d /chrome/browser/autofill | |
parent | a6298e4afedbf2cd461755ea6f45b0ad648d38cc (diff) | |
download | chromium_src-b1bc9bd012abbbb06eac639cda41dffd07b20ef4.zip chromium_src-b1bc9bd012abbbb06eac639cda41dffd07b20ef4.tar.gz chromium_src-b1bc9bd012abbbb06eac639cda41dffd07b20ef4.tar.bz2 |
Refactor Autofill for out of process iframes (OOPIF).
- AutofillAgent is a RenderFrameObserver instead of a RenderViewObserver
- legacy RenderViewObserver code is temporarily split off into LegacyAutofillAgent
- ContentAutofillDriver is one per render frame host, instead of one per WebContents
- ContentAutofillDriverFactory is one per WebContents and spawns ContentAutofillDrivers for each frame
- ContentAutofillClient remains one per WebContents. Thus there are many drivers to each client. The PasswordManager is now owned by the client so it remains one per WebContents.
Similar changes are made to the parallel password manager classes.
Blink side is here: https://codereview.chromium.org/707723002/
- WebAutofillClient is a property of WebLocalFrame instead of WebView
BUG=425756, 400186
Review URL: https://codereview.chromium.org/707173004
Cr-Commit-Position: refs/heads/master@{#306479}
Diffstat (limited to 'chrome/browser/autofill')
4 files changed, 26 insertions, 18 deletions
diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc index eb385e9..1eb2d13 100644 --- a/chrome/browser/autofill/autofill_browsertest.cc +++ b/chrome/browser/autofill/autofill_browsertest.cc @@ -26,6 +26,7 @@ #include "chrome/test/base/test_switches.h" #include "chrome/test/base/ui_test_utils.h" #include "components/autofill/content/browser/content_autofill_driver.h" +#include "components/autofill/content/browser/content_autofill_driver_factory.h" #include "components/autofill/core/browser/autofill_profile.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/credit_card.h" @@ -123,8 +124,10 @@ class AutofillTest : public InProcessBrowserTest { // Make sure to close any showing popups prior to tearing down the UI. content::WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); - AutofillManager* autofill_manager = ContentAutofillDriver::FromWebContents( - web_contents)->autofill_manager(); + AutofillManager* autofill_manager = + ContentAutofillDriverFactory::FromWebContents(web_contents) + ->DriverForFrame(web_contents->GetMainFrame()) + ->autofill_manager(); autofill_manager->client()->HideAutofillPopup(); } diff --git a/chrome/browser/autofill/autofill_interactive_uitest.cc b/chrome/browser/autofill/autofill_interactive_uitest.cc index c871a26..379b449 100644 --- a/chrome/browser/autofill/autofill_interactive_uitest.cc +++ b/chrome/browser/autofill/autofill_interactive_uitest.cc @@ -30,6 +30,7 @@ #include "chrome/test/base/test_switches.h" #include "chrome/test/base/ui_test_utils.h" #include "components/autofill/content/browser/content_autofill_driver.h" +#include "components/autofill/content/browser/content_autofill_driver_factory.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/autofill_manager_test_delegate.h" #include "components/autofill/core/browser/autofill_profile.h" @@ -210,7 +211,8 @@ class AutofillInteractiveTest : public InProcessBrowserTest { // Inject the test delegate into the AutofillManager. content::WebContents* web_contents = GetWebContents(); ContentAutofillDriver* autofill_driver = - ContentAutofillDriver::FromWebContents(web_contents); + ContentAutofillDriverFactory::FromWebContents(web_contents) + ->DriverForFrame(web_contents->GetMainFrame()); AutofillManager* autofill_manager = autofill_driver->autofill_manager(); autofill_manager->SetTestDelegate(&test_delegate_); @@ -225,8 +227,10 @@ class AutofillInteractiveTest : public InProcessBrowserTest { void TearDownOnMainThread() override { // Make sure to close any showing popups prior to tearing down the UI. content::WebContents* web_contents = GetWebContents(); - AutofillManager* autofill_manager = ContentAutofillDriver::FromWebContents( - web_contents)->autofill_manager(); + AutofillManager* autofill_manager = + ContentAutofillDriverFactory::FromWebContents(web_contents) + ->DriverForFrame(web_contents->GetMainFrame()) + ->autofill_manager(); autofill_manager->client()->HideAutofillPopup(); } diff --git a/chrome/browser/autofill/content_autofill_driver_browsertest.cc b/chrome/browser/autofill/content_autofill_driver_browsertest.cc index 1b15094..312a10f 100644 --- a/chrome/browser/autofill/content_autofill_driver_browsertest.cc +++ b/chrome/browser/autofill/content_autofill_driver_browsertest.cc @@ -11,6 +11,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/testing_pref_service_syncable.h" #include "components/autofill/content/browser/content_autofill_driver.h" +#include "components/autofill/content/browser/content_autofill_driver_factory.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/test_autofill_client.h" #include "content/public/browser/navigation_controller.h" @@ -58,10 +59,10 @@ class MockAutofillClient : public TestAutofillClient { // instance. class TestContentAutofillDriver : public ContentAutofillDriver { public: - TestContentAutofillDriver(content::WebContents* web_contents, + TestContentAutofillDriver(content::RenderFrameHost* rfh, AutofillClient* client) : ContentAutofillDriver( - web_contents, + rfh, client, g_browser_process->GetApplicationLocale(), AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {} @@ -86,14 +87,12 @@ class ContentAutofillDriverBrowserTest : public InProcessBrowserTest, Observe(web_contents); AutofillManager::RegisterProfilePrefs(autofill_client_.GetPrefRegistry()); - autofill_driver_.reset( - new TestContentAutofillDriver(web_contents, &autofill_client_)); - } - - // Normally the WebContents will automatically delete the driver, but here - // the driver is owned by this test, so we have to manually destroy. - virtual void WebContentsDestroyed() override { - autofill_driver_.reset(); + web_contents->RemoveUserData( + ContentAutofillDriverFactory:: + kContentAutofillDriverFactoryWebContentsUserDataKey); + ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( + web_contents, &autofill_client_, "en-US", + AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); } virtual void WasHidden() override { @@ -114,7 +113,6 @@ class ContentAutofillDriverBrowserTest : public InProcessBrowserTest, base::Closure nav_entry_committed_callback_; testing::NiceMock<MockAutofillClient> autofill_client_; - scoped_ptr<TestContentAutofillDriver> autofill_driver_; }; IN_PROC_BROWSER_TEST_F(ContentAutofillDriverBrowserTest, diff --git a/chrome/browser/autofill/form_structure_browsertest.cc b/chrome/browser/autofill/form_structure_browsertest.cc index df8a9c3..ea53d05 100644 --- a/chrome/browser/autofill/form_structure_browsertest.cc +++ b/chrome/browser/autofill/form_structure_browsertest.cc @@ -14,6 +14,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "components/autofill/content/browser/content_autofill_driver.h" +#include "components/autofill/content/browser/content_autofill_driver_factory.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/data_driven_test.h" #include "components/autofill/core/browser/form_structure.h" @@ -71,9 +72,11 @@ void FormStructureBrowserTest::GenerateResults(const std::string& input, ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), HTMLToDataURI(input))); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); ContentAutofillDriver* autofill_driver = - ContentAutofillDriver::FromWebContents( - browser()->tab_strip_model()->GetActiveWebContents()); + ContentAutofillDriverFactory::FromWebContents(web_contents) + ->DriverForFrame(web_contents->GetMainFrame()); ASSERT_NE(static_cast<ContentAutofillDriver*>(NULL), autofill_driver); AutofillManager* autofill_manager = autofill_driver->autofill_manager(); ASSERT_NE(static_cast<AutofillManager*>(NULL), autofill_manager); |