diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-12 20:34:36 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-12 20:34:36 +0000 |
commit | e13549ec4ece604cb4cb8b2cfaefc016015fef33 (patch) | |
tree | fcf74cf7b81c6184097d3124b3a14009dacf43f3 | |
parent | 7e206c0c5a75c51c0b77440cfcdbf33c1368fb3c (diff) | |
download | chromium_src-e13549ec4ece604cb4cb8b2cfaefc016015fef33.zip chromium_src-e13549ec4ece604cb4cb8b2cfaefc016015fef33.tar.gz chromium_src-e13549ec4ece604cb4cb8b2cfaefc016015fef33.tar.bz2 |
Rename AutofillDriverImpl to ContentAutofillDriver
This renaming follows the agreed-upon convention wherein the content-based
implementation of a layered component Foo's FooDriver interface will be called
ContentFooDriver.
BUG=303078
TBR=joi
Review URL: https://codereview.chromium.org/194963003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256629 0039d316-1c4b-4281-b951-d872f2087c98
21 files changed, 376 insertions, 375 deletions
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 7e8d684..7eceea1 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -38,7 +38,7 @@ #include "base/pickle.h" #include "base/strings/string16.h" #include "base/supports_user_data.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/navigation_interception/intercept_navigation_delegate.h" @@ -65,7 +65,7 @@ struct AwDrawSWFunctionTable; struct AwDrawGLFunctionTable; -using autofill::AutofillDriverImpl; +using autofill::ContentAutofillDriver; using autofill::AutofillManager; using base::android::AttachCurrentThread; using base::android::ConvertJavaStringToUTF16; @@ -248,7 +248,7 @@ void AwContents::SetSaveFormData(bool enabled) { InitAutofillIfNecessary(enabled); // We need to check for the existence, since autofill_manager_delegate // may not be created when the setting is false. - if (AutofillDriverImpl::FromWebContents(web_contents_.get())) { + if (ContentAutofillDriver::FromWebContents(web_contents_.get())) { AwAutofillManagerDelegate::FromWebContents(web_contents_.get())-> SetSaveFormData(enabled); } @@ -260,13 +260,13 @@ void AwContents::InitAutofillIfNecessary(bool enabled) { return; // Check if the autofill driver already exists. content::WebContents* web_contents = web_contents_.get(); - if (AutofillDriverImpl::FromWebContents(web_contents)) + if (ContentAutofillDriver::FromWebContents(web_contents)) return; AwBrowserContext::FromWebContents(web_contents)-> CreateUserPrefServiceIfNecessary(); AwAutofillManagerDelegate::CreateForWebContents(web_contents); - AutofillDriverImpl::CreateForWebContentsAndDelegate( + ContentAutofillDriver::CreateForWebContentsAndDelegate( web_contents, AwAutofillManagerDelegate::FromWebContents(web_contents), l10n_util::GetDefaultLocale(), diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc index 7008fdb..723b652e 100644 --- a/chrome/browser/autofill/autofill_browsertest.cc +++ b/chrome/browser/autofill/autofill_browsertest.cc @@ -28,7 +28,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/test_switches.h" #include "chrome/test/base/ui_test_utils.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.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" @@ -130,8 +130,8 @@ 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 = - AutofillDriverImpl::FromWebContents(web_contents)->autofill_manager(); + AutofillManager* autofill_manager = ContentAutofillDriver::FromWebContents( + web_contents)->autofill_manager(); autofill_manager->delegate()->HideAutofillPopup(); } diff --git a/chrome/browser/autofill/autofill_interactive_uitest.cc b/chrome/browser/autofill/autofill_interactive_uitest.cc index 3a99cc5..6707986 100644 --- a/chrome/browser/autofill/autofill_interactive_uitest.cc +++ b/chrome/browser/autofill/autofill_interactive_uitest.cc @@ -31,7 +31,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/test_switches.h" #include "chrome/test/base/ui_test_utils.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.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" @@ -213,8 +213,8 @@ class AutofillInteractiveTest : public InProcessBrowserTest { // Inject the test delegate into the AutofillManager. content::WebContents* web_contents = GetWebContents(); - AutofillDriverImpl* autofill_driver = - AutofillDriverImpl::FromWebContents(web_contents); + ContentAutofillDriver* autofill_driver = + ContentAutofillDriver::FromWebContents(web_contents); AutofillManager* autofill_manager = autofill_driver->autofill_manager(); autofill_manager->SetTestDelegate(&test_delegate_); } @@ -222,8 +222,8 @@ class AutofillInteractiveTest : public InProcessBrowserTest { virtual void CleanUpOnMainThread() OVERRIDE { // Make sure to close any showing popups prior to tearing down the UI. content::WebContents* web_contents = GetWebContents(); - AutofillManager* autofill_manager = - AutofillDriverImpl::FromWebContents(web_contents)->autofill_manager(); + AutofillManager* autofill_manager = ContentAutofillDriver::FromWebContents( + web_contents)->autofill_manager(); autofill_manager->delegate()->HideAutofillPopup(); } diff --git a/chrome/browser/autofill/autofill_driver_impl_browsertest.cc b/chrome/browser/autofill/content_autofill_driver_browsertest.cc index 4fe1b88..d452e1e 100644 --- a/chrome/browser/autofill/autofill_driver_impl_browsertest.cc +++ b/chrome/browser/autofill/content_autofill_driver_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,7 +10,7 @@ #include "chrome/common/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/testing_pref_service_syncable.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/test_autofill_manager_delegate.h" #include "content/public/browser/navigation_controller.h" @@ -55,30 +55,30 @@ class MockAutofillManagerDelegate DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); }; -// Subclass AutofillDriverImpl so we can create an AutofillDriverImpl instance. -class TestAutofillDriverImpl : public AutofillDriverImpl { +// Subclass ContentAutofillDriver so we can create an ContentAutofillDriver +// instance. +class TestContentAutofillDriver : public ContentAutofillDriver { public: - TestAutofillDriverImpl(content::WebContents* web_contents, - AutofillManagerDelegate* delegate) - : AutofillDriverImpl( - web_contents, - delegate, - g_browser_process->GetApplicationLocale(), - AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {} - virtual ~TestAutofillDriverImpl() {} + TestContentAutofillDriver(content::WebContents* web_contents, + AutofillManagerDelegate* delegate) + : ContentAutofillDriver( + web_contents, + delegate, + g_browser_process->GetApplicationLocale(), + AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {} + virtual ~TestContentAutofillDriver() {} private: - DISALLOW_COPY_AND_ASSIGN(TestAutofillDriverImpl); + DISALLOW_COPY_AND_ASSIGN(TestContentAutofillDriver); }; } // namespace -class AutofillDriverImplBrowserTest - : public InProcessBrowserTest, - public content::WebContentsObserver { +class ContentAutofillDriverBrowserTest : public InProcessBrowserTest, + public content::WebContentsObserver { public: - AutofillDriverImplBrowserTest() {} - virtual ~AutofillDriverImplBrowserTest() {} + ContentAutofillDriverBrowserTest() {} + virtual ~ContentAutofillDriverBrowserTest() {} virtual void SetUpOnMainThread() OVERRIDE { web_contents_ = browser()->tab_strip_model()->GetActiveWebContents(); @@ -86,8 +86,8 @@ class AutofillDriverImplBrowserTest Observe(web_contents_); AutofillManager::RegisterProfilePrefs(manager_delegate_.GetPrefRegistry()); - autofill_driver_.reset(new TestAutofillDriverImpl(web_contents_, - &manager_delegate_)); + autofill_driver_.reset( + new TestContentAutofillDriver(web_contents_, &manager_delegate_)); } // Normally the WebContents will automatically delete the driver, but here @@ -116,10 +116,10 @@ class AutofillDriverImplBrowserTest base::Closure nav_entry_committed_callback_; testing::NiceMock<MockAutofillManagerDelegate> manager_delegate_; - scoped_ptr<TestAutofillDriverImpl> autofill_driver_; + scoped_ptr<TestContentAutofillDriver> autofill_driver_; }; -IN_PROC_BROWSER_TEST_F(AutofillDriverImplBrowserTest, +IN_PROC_BROWSER_TEST_F(ContentAutofillDriverBrowserTest, SwitchTabAndHideAutofillPopup) { // Notification is different on platforms. On linux this will be called twice, // while on windows only once. @@ -129,13 +129,14 @@ IN_PROC_BROWSER_TEST_F(AutofillDriverImplBrowserTest, scoped_refptr<content::MessageLoopRunner> runner = new content::MessageLoopRunner; web_contents_hidden_callback_ = runner->QuitClosure(); - chrome::AddSelectedTabWithURL(browser(), GURL(content::kAboutBlankURL), + chrome::AddSelectedTabWithURL(browser(), + GURL(content::kAboutBlankURL), content::PAGE_TRANSITION_AUTO_TOPLEVEL); runner->Run(); web_contents_hidden_callback_.Reset(); } -IN_PROC_BROWSER_TEST_F(AutofillDriverImplBrowserTest, +IN_PROC_BROWSER_TEST_F(ContentAutofillDriverBrowserTest, TestPageNavigationHidingAutofillPopup) { // Notification is different on platforms. On linux this will be called twice, // while on windows only once. @@ -145,12 +146,16 @@ IN_PROC_BROWSER_TEST_F(AutofillDriverImplBrowserTest, scoped_refptr<content::MessageLoopRunner> runner = new content::MessageLoopRunner; nav_entry_committed_callback_ = runner->QuitClosure(); - browser()->OpenURL(content::OpenURLParams( - GURL(chrome::kChromeUIBookmarksURL), content::Referrer(), - CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); - browser()->OpenURL(content::OpenURLParams( - GURL(chrome::kChromeUIAboutURL), content::Referrer(), - CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); + browser()->OpenURL(content::OpenURLParams(GURL(chrome::kChromeUIBookmarksURL), + content::Referrer(), + CURRENT_TAB, + content::PAGE_TRANSITION_TYPED, + false)); + browser()->OpenURL(content::OpenURLParams(GURL(chrome::kChromeUIAboutURL), + content::Referrer(), + CURRENT_TAB, + content::PAGE_TRANSITION_TYPED, + false)); runner->Run(); nav_entry_committed_callback_.Reset(); } diff --git a/chrome/browser/autofill/form_structure_browsertest.cc b/chrome/browser/autofill/form_structure_browsertest.cc index 335ea98..cb3abcc 100644 --- a/chrome/browser/autofill/form_structure_browsertest.cc +++ b/chrome/browser/autofill/form_structure_browsertest.cc @@ -13,7 +13,7 @@ #include "chrome/common/chrome_paths.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.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" @@ -70,9 +70,10 @@ void FormStructureBrowserTest::GenerateResults(const std::string& input, ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), HTMLToDataURI(input))); - AutofillDriverImpl* autofill_driver = AutofillDriverImpl::FromWebContents( - browser()->tab_strip_model()->GetActiveWebContents()); - ASSERT_NE(static_cast<AutofillDriverImpl*>(NULL), autofill_driver); + ContentAutofillDriver* autofill_driver = + ContentAutofillDriver::FromWebContents( + browser()->tab_strip_model()->GetActiveWebContents()); + ASSERT_NE(static_cast<ContentAutofillDriver*>(NULL), autofill_driver); AutofillManager* autofill_manager = autofill_driver->autofill_manager(); ASSERT_NE(static_cast<AutofillManager*>(NULL), autofill_manager); std::vector<FormStructure*> forms = autofill_manager->form_structures_.get(); diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_interactive_uitest.cc b/chrome/browser/ui/autofill/autofill_popup_controller_interactive_uitest.cc index 7a145bb..fd4573f 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_interactive_uitest.cc +++ b/chrome/browser/ui/autofill/autofill_popup_controller_interactive_uitest.cc @@ -9,7 +9,7 @@ #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/test/base/in_process_browser_test.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/test_autofill_external_delegate.h" #include "content/public/browser/web_contents.h" @@ -76,8 +76,8 @@ class AutofillPopupControllerBrowserTest ASSERT_TRUE(web_contents_ != NULL); Observe(web_contents_); - AutofillDriverImpl* driver = - AutofillDriverImpl::FromWebContents(web_contents_); + ContentAutofillDriver* driver = + ContentAutofillDriver::FromWebContents(web_contents_); autofill_external_delegate_.reset( new TestAutofillExternalDelegate( web_contents_, diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc index 83fac19..b383155 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc @@ -12,7 +12,7 @@ #include "chrome/browser/ui/autofill/test_popup_controller_common.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/core/browser/autofill_external_delegate.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/autofill/core/browser/autofill_test_utils.h" @@ -132,13 +132,13 @@ class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness { virtual void SetUp() OVERRIDE { ChromeRenderViewHostTestHarness::SetUp(); - AutofillDriverImpl::CreateForWebContentsAndDelegate( + ContentAutofillDriver::CreateForWebContentsAndDelegate( web_contents(), manager_delegate_.get(), "en-US", AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER); - AutofillDriverImpl* driver = - AutofillDriverImpl::FromWebContents(web_contents()); + ContentAutofillDriver* driver = + ContentAutofillDriver::FromWebContents(web_contents()); external_delegate_.reset( new NiceMock<MockAutofillExternalDelegate>( driver->autofill_manager(), @@ -428,8 +428,8 @@ TEST_F(AutofillPopupControllerUnitTest, PopupsWithOnlyDataLists) { } TEST_F(AutofillPopupControllerUnitTest, GetOrCreate) { - AutofillDriverImpl* driver = - AutofillDriverImpl::FromWebContents(web_contents()); + ContentAutofillDriver* driver = + ContentAutofillDriver::FromWebContents(web_contents()); MockAutofillExternalDelegate delegate(driver->autofill_manager(), driver); WeakPtr<AutofillPopupControllerImpl> controller = diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc index 9937f16..afd8906f 100644 --- a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc +++ b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc @@ -20,7 +20,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" #include "chrome/browser/webdata/web_data_service_factory.h" #include "chrome/common/url_constants.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/content/common/autofill_messages.h" #include "components/autofill/core/common/autofill_pref_names.h" #include "content/public/browser/render_view_host.h" diff --git a/chrome/browser/ui/tab_helpers.cc b/chrome/browser/ui/tab_helpers.cc index 7a46b4e..90f7f38 100644 --- a/chrome/browser/ui/tab_helpers.cc +++ b/chrome/browser/ui/tab_helpers.cc @@ -27,7 +27,7 @@ #include "chrome/browser/ui/prefs/prefs_tab_helper.h" #include "chrome/browser/ui/tab_contents/core_tab_helper.h" #include "chrome/common/chrome_switches.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/core/browser/autofill_manager.h" #include "components/password_manager/core/browser/password_manager.h" #include "content/public/browser/web_contents.h" @@ -119,7 +119,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) { // --- Common tab helpers --- autofill::TabAutofillManagerDelegate::CreateForWebContents(web_contents); - autofill::AutofillDriverImpl::CreateForWebContentsAndDelegate( + autofill::ContentAutofillDriver::CreateForWebContentsAndDelegate( web_contents, autofill::TabAutofillManagerDelegate::FromWebContents(web_contents), g_browser_process->GetApplicationLocale(), diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index ffa1059..3800d32 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -964,7 +964,7 @@ 'browser/apps/window_controls_browsertest.cc', 'browser/autocomplete/autocomplete_browsertest.cc', 'browser/autofill/autofill_browsertest.cc', - 'browser/autofill/autofill_driver_impl_browsertest.cc', + 'browser/autofill/content_autofill_driver_browsertest.cc', 'browser/autofill/form_structure_browsertest.cc', 'browser/autofill/risk/fingerprint_browsertest.cc', 'browser/bitmap_fetcher_browsertest.cc', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 81276f1..9a96479 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -1947,7 +1947,7 @@ # TODO(joi): Move to //components/components_tests.gypi once # remaining dependencies back to //chrome are eliminated. - '../components/autofill/content/browser/autofill_driver_impl_unittest.cc', + '../components/autofill/content/browser/content_autofill_driver_unittest.cc', '../components/autofill/content/browser/request_autocomplete_manager_unittest.cc', '../components/autofill/content/browser/wallet/full_wallet_unittest.cc', '../components/autofill/content/browser/wallet/instrument_unittest.cc', diff --git a/components/autofill.gypi b/components/autofill.gypi index 2b35f1d..a190d6c 100644 --- a/components/autofill.gypi +++ b/components/autofill.gypi @@ -354,8 +354,8 @@ 'webdata_common', ], 'sources': [ - 'autofill/content/browser/autofill_driver_impl.cc', - 'autofill/content/browser/autofill_driver_impl.h', + 'autofill/content/browser/content_autofill_driver.cc', + 'autofill/content/browser/content_autofill_driver.h', 'autofill/content/browser/request_autocomplete_manager.cc', 'autofill/content/browser/request_autocomplete_manager.h', 'autofill/content/browser/risk/fingerprint.cc', diff --git a/components/autofill/content/browser/DEPS b/components/autofill/content/browser/DEPS index c9bd39f..907ebab 100644 --- a/components/autofill/content/browser/DEPS +++ b/components/autofill/content/browser/DEPS @@ -25,7 +25,7 @@ specific_include_rules = { # plain BrowserContext to a Profile. If on the other hand we move it # to the 'components_unittests' target, it will at this point fail # to build due to a few link-time dependencies. - 'autofill_driver_impl_unittest.cc': [ + 'content_autofill_driver_unittest.cc': [ "!chrome/test/base/chrome_render_view_host_test_harness.h", ], 'request_autocomplete_manager_unittest.cc': [ diff --git a/components/autofill/content/browser/autofill_driver_impl.cc b/components/autofill/content/browser/autofill_driver_impl.cc deleted file mode 100644 index ab30c8d..0000000 --- a/components/autofill/content/browser/autofill_driver_impl.cc +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill/content/browser/autofill_driver_impl.h" - -#include "base/command_line.h" -#include "base/threading/sequenced_worker_pool.h" -#include "components/autofill/content/common/autofill_messages.h" -#include "components/autofill/core/browser/autofill_external_delegate.h" -#include "components/autofill/core/browser/autofill_manager.h" -#include "components/autofill/core/browser/autofill_manager_delegate.h" -#include "components/autofill/core/browser/form_structure.h" -#include "components/autofill/core/common/autofill_switches.h" -#include "content/public/browser/browser_context.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/navigation_controller.h" -#include "content/public/browser/navigation_details.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/frame_navigate_params.h" -#include "ipc/ipc_message_macros.h" - -namespace autofill { - -namespace { - -const char kAutofillDriverImplWebContentsUserDataKey[] = - "web_contents_autofill_driver_impl"; - -} // namespace - -// static -void AutofillDriverImpl::CreateForWebContentsAndDelegate( - content::WebContents* contents, - autofill::AutofillManagerDelegate* delegate, - const std::string& app_locale, - AutofillManager::AutofillDownloadManagerState enable_download_manager) { - if (FromWebContents(contents)) - return; - - contents->SetUserData(kAutofillDriverImplWebContentsUserDataKey, - new AutofillDriverImpl(contents, - delegate, - app_locale, - enable_download_manager)); -} - -// static -AutofillDriverImpl* AutofillDriverImpl::FromWebContents( - content::WebContents* contents) { - return static_cast<AutofillDriverImpl*>( - contents->GetUserData(kAutofillDriverImplWebContentsUserDataKey)); -} - -AutofillDriverImpl::AutofillDriverImpl( - content::WebContents* web_contents, - autofill::AutofillManagerDelegate* delegate, - const std::string& app_locale, - AutofillManager::AutofillDownloadManagerState enable_download_manager) - : content::WebContentsObserver(web_contents), - autofill_manager_(new AutofillManager( - this, delegate, app_locale, enable_download_manager)), - autofill_external_delegate_(autofill_manager_.get(), this), - request_autocomplete_manager_(this) { - autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); -} - -AutofillDriverImpl::~AutofillDriverImpl() {} - -bool AutofillDriverImpl::IsOffTheRecord() const { - return web_contents()->GetBrowserContext()->IsOffTheRecord(); -} - -net::URLRequestContextGetter* AutofillDriverImpl::GetURLRequestContext() { - return web_contents()->GetBrowserContext()->GetRequestContext(); -} - -content::WebContents* AutofillDriverImpl::GetWebContents() { - return web_contents(); -} - -base::SequencedWorkerPool* AutofillDriverImpl::GetBlockingPool() { - return content::BrowserThread::GetBlockingPool(); -} - -bool AutofillDriverImpl::RendererIsAvailable() { - return (web_contents()->GetRenderViewHost() != NULL); -} - -void AutofillDriverImpl::SendFormDataToRenderer(int query_id, - RendererFormDataAction action, - const FormData& data) { - if (!RendererIsAvailable()) - return; - content::RenderViewHost* host = web_contents()->GetRenderViewHost(); - switch (action) { - case FORM_DATA_ACTION_FILL: - host->Send( - new AutofillMsg_FillForm(host->GetRoutingID(), query_id, data)); - break; - case FORM_DATA_ACTION_PREVIEW: - host->Send( - new AutofillMsg_PreviewForm(host->GetRoutingID(), query_id, data)); - break; - } -} - -void AutofillDriverImpl::SendAutofillTypePredictionsToRenderer( - const std::vector<FormStructure*>& forms) { - if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kShowAutofillTypePredictions)) - return; - - if (!RendererIsAvailable()) - return; - content::RenderViewHost* host = web_contents()->GetRenderViewHost(); - - std::vector<FormDataPredictions> type_predictions; - FormStructure::GetFieldTypePredictions(forms, &type_predictions); - host->Send( - new AutofillMsg_FieldTypePredictionsAvailable(host->GetRoutingID(), - type_predictions)); -} - -void AutofillDriverImpl::RendererShouldAcceptDataListSuggestion( - const base::string16& value) { - if (!RendererIsAvailable()) - return; - content::RenderViewHost* host = web_contents()->GetRenderViewHost(); - host->Send(new AutofillMsg_AcceptDataListSuggestion(host->GetRoutingID(), - value)); -} - -void AutofillDriverImpl::RendererShouldAcceptPasswordAutofillSuggestion( - const base::string16& username) { - if (!RendererIsAvailable()) - return; - content::RenderViewHost* host = web_contents()->GetRenderViewHost(); - host->Send( - new AutofillMsg_AcceptPasswordAutofillSuggestion(host->GetRoutingID(), - username)); -} - -void AutofillDriverImpl::RendererShouldClearFilledForm() { - if (!RendererIsAvailable()) - return; - content::RenderViewHost* host = web_contents()->GetRenderViewHost(); - host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); -} - -void AutofillDriverImpl::RendererShouldClearPreviewedForm() { - if (!RendererIsAvailable()) - return; - content::RenderViewHost* host = web_contents()->GetRenderViewHost(); - host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); -} - -void AutofillDriverImpl::RendererShouldSetNodeText( - const base::string16& value) { - if (!RendererIsAvailable()) - return; - content::RenderViewHost* host = web_contents()->GetRenderViewHost(); - host->Send(new AutofillMsg_SetNodeText(host->GetRoutingID(), value)); -} - -bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(AutofillDriverImpl, message) - IPC_MESSAGE_FORWARD(AutofillHostMsg_FormsSeen, autofill_manager_.get(), - AutofillManager::OnFormsSeen) - IPC_MESSAGE_FORWARD(AutofillHostMsg_FormSubmitted, autofill_manager_.get(), - AutofillManager::OnFormSubmitted) - IPC_MESSAGE_FORWARD(AutofillHostMsg_TextFieldDidChange, - autofill_manager_.get(), - AutofillManager::OnTextFieldDidChange) - IPC_MESSAGE_FORWARD(AutofillHostMsg_QueryFormFieldAutofill, - autofill_manager_.get(), - AutofillManager::OnQueryFormFieldAutofill) - IPC_MESSAGE_FORWARD(AutofillHostMsg_DidPreviewAutofillFormData, - autofill_manager_.get(), - AutofillManager::OnDidPreviewAutofillFormData) - IPC_MESSAGE_FORWARD(AutofillHostMsg_DidFillAutofillFormData, - autofill_manager_.get(), - AutofillManager::OnDidFillAutofillFormData) - IPC_MESSAGE_FORWARD(AutofillHostMsg_DidEndTextFieldEditing, - autofill_manager_.get(), - AutofillManager::OnDidEndTextFieldEditing) - IPC_MESSAGE_FORWARD(AutofillHostMsg_HidePopup, autofill_manager_.get(), - AutofillManager::OnHidePopup) - IPC_MESSAGE_FORWARD(AutofillHostMsg_AddPasswordFormMapping, - autofill_manager_.get(), - AutofillManager::OnAddPasswordFormMapping) - IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions, - autofill_manager_.get(), - AutofillManager::OnShowPasswordSuggestions) - IPC_MESSAGE_FORWARD(AutofillHostMsg_SetDataList, autofill_manager_.get(), - AutofillManager::OnSetDataList) - IPC_MESSAGE_FORWARD(AutofillHostMsg_RequestAutocomplete, - &request_autocomplete_manager_, - RequestAutocompleteManager::OnRequestAutocomplete) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void AutofillDriverImpl::DidNavigateMainFrame( - const content::LoadCommittedDetails& details, - const content::FrameNavigateParams& params) { - if (details.is_navigation_to_different_page()) - autofill_manager_->Reset(); -} - -void AutofillDriverImpl::SetAutofillManager( - scoped_ptr<AutofillManager> manager) { - autofill_manager_ = manager.Pass(); - autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); -} - -void AutofillDriverImpl::NavigationEntryCommitted( - const content::LoadCommittedDetails& load_details) { - autofill_manager_->delegate()->HideAutofillPopup(); -} - -void AutofillDriverImpl::WasHidden() { - autofill_manager_->delegate()->HideAutofillPopup(); -} - -} // namespace autofill diff --git a/components/autofill/content/browser/content_autofill_driver.cc b/components/autofill/content/browser/content_autofill_driver.cc new file mode 100644 index 0000000..02aaf22 --- /dev/null +++ b/components/autofill/content/browser/content_autofill_driver.cc @@ -0,0 +1,233 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/autofill/content/browser/content_autofill_driver.h" + +#include "base/command_line.h" +#include "base/threading/sequenced_worker_pool.h" +#include "components/autofill/content/common/autofill_messages.h" +#include "components/autofill/core/browser/autofill_external_delegate.h" +#include "components/autofill/core/browser/autofill_manager.h" +#include "components/autofill/core/browser/autofill_manager_delegate.h" +#include "components/autofill/core/browser/form_structure.h" +#include "components/autofill/core/common/autofill_switches.h" +#include "content/public/browser/browser_context.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/navigation_controller.h" +#include "content/public/browser/navigation_details.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/web_contents.h" +#include "content/public/common/frame_navigate_params.h" +#include "ipc/ipc_message_macros.h" + +namespace autofill { + +namespace { + +const char kContentAutofillDriverWebContentsUserDataKey[] = + "web_contents_autofill_driver_impl"; + +} // namespace + +// static +void ContentAutofillDriver::CreateForWebContentsAndDelegate( + content::WebContents* contents, + autofill::AutofillManagerDelegate* delegate, + const std::string& app_locale, + AutofillManager::AutofillDownloadManagerState enable_download_manager) { + if (FromWebContents(contents)) + return; + + contents->SetUserData( + kContentAutofillDriverWebContentsUserDataKey, + new ContentAutofillDriver( + contents, delegate, app_locale, enable_download_manager)); +} + +// static +ContentAutofillDriver* ContentAutofillDriver::FromWebContents( + content::WebContents* contents) { + return static_cast<ContentAutofillDriver*>( + contents->GetUserData(kContentAutofillDriverWebContentsUserDataKey)); +} + +ContentAutofillDriver::ContentAutofillDriver( + content::WebContents* web_contents, + autofill::AutofillManagerDelegate* delegate, + const std::string& app_locale, + AutofillManager::AutofillDownloadManagerState enable_download_manager) + : content::WebContentsObserver(web_contents), + autofill_manager_(new AutofillManager(this, + delegate, + app_locale, + enable_download_manager)), + autofill_external_delegate_(autofill_manager_.get(), this), + request_autocomplete_manager_(this) { + autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); +} + +ContentAutofillDriver::~ContentAutofillDriver() {} + +bool ContentAutofillDriver::IsOffTheRecord() const { + return web_contents()->GetBrowserContext()->IsOffTheRecord(); +} + +net::URLRequestContextGetter* ContentAutofillDriver::GetURLRequestContext() { + return web_contents()->GetBrowserContext()->GetRequestContext(); +} + +content::WebContents* ContentAutofillDriver::GetWebContents() { + return web_contents(); +} + +base::SequencedWorkerPool* ContentAutofillDriver::GetBlockingPool() { + return content::BrowserThread::GetBlockingPool(); +} + +bool ContentAutofillDriver::RendererIsAvailable() { + return (web_contents()->GetRenderViewHost() != NULL); +} + +void ContentAutofillDriver::SendFormDataToRenderer( + int query_id, + RendererFormDataAction action, + const FormData& data) { + if (!RendererIsAvailable()) + return; + content::RenderViewHost* host = web_contents()->GetRenderViewHost(); + switch (action) { + case FORM_DATA_ACTION_FILL: + host->Send( + new AutofillMsg_FillForm(host->GetRoutingID(), query_id, data)); + break; + case FORM_DATA_ACTION_PREVIEW: + host->Send( + new AutofillMsg_PreviewForm(host->GetRoutingID(), query_id, data)); + break; + } +} + +void ContentAutofillDriver::SendAutofillTypePredictionsToRenderer( + const std::vector<FormStructure*>& forms) { + if (!CommandLine::ForCurrentProcess()->HasSwitch( + switches::kShowAutofillTypePredictions)) + return; + + if (!RendererIsAvailable()) + return; + content::RenderViewHost* host = web_contents()->GetRenderViewHost(); + + std::vector<FormDataPredictions> type_predictions; + FormStructure::GetFieldTypePredictions(forms, &type_predictions); + host->Send(new AutofillMsg_FieldTypePredictionsAvailable(host->GetRoutingID(), + type_predictions)); +} + +void ContentAutofillDriver::RendererShouldAcceptDataListSuggestion( + const base::string16& value) { + if (!RendererIsAvailable()) + return; + content::RenderViewHost* host = web_contents()->GetRenderViewHost(); + host->Send( + new AutofillMsg_AcceptDataListSuggestion(host->GetRoutingID(), value)); +} + +void ContentAutofillDriver::RendererShouldAcceptPasswordAutofillSuggestion( + const base::string16& username) { + if (!RendererIsAvailable()) + return; + content::RenderViewHost* host = web_contents()->GetRenderViewHost(); + host->Send(new AutofillMsg_AcceptPasswordAutofillSuggestion( + host->GetRoutingID(), username)); +} + +void ContentAutofillDriver::RendererShouldClearFilledForm() { + if (!RendererIsAvailable()) + return; + content::RenderViewHost* host = web_contents()->GetRenderViewHost(); + host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); +} + +void ContentAutofillDriver::RendererShouldClearPreviewedForm() { + if (!RendererIsAvailable()) + return; + content::RenderViewHost* host = web_contents()->GetRenderViewHost(); + host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); +} + +void ContentAutofillDriver::RendererShouldSetNodeText( + const base::string16& value) { + if (!RendererIsAvailable()) + return; + content::RenderViewHost* host = web_contents()->GetRenderViewHost(); + host->Send(new AutofillMsg_SetNodeText(host->GetRoutingID(), value)); +} + +bool ContentAutofillDriver::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(ContentAutofillDriver, message) + IPC_MESSAGE_FORWARD(AutofillHostMsg_FormsSeen, + autofill_manager_.get(), + AutofillManager::OnFormsSeen) + IPC_MESSAGE_FORWARD(AutofillHostMsg_FormSubmitted, + autofill_manager_.get(), + AutofillManager::OnFormSubmitted) + IPC_MESSAGE_FORWARD(AutofillHostMsg_TextFieldDidChange, + autofill_manager_.get(), + AutofillManager::OnTextFieldDidChange) + IPC_MESSAGE_FORWARD(AutofillHostMsg_QueryFormFieldAutofill, + autofill_manager_.get(), + AutofillManager::OnQueryFormFieldAutofill) + IPC_MESSAGE_FORWARD(AutofillHostMsg_DidPreviewAutofillFormData, + autofill_manager_.get(), + AutofillManager::OnDidPreviewAutofillFormData) + IPC_MESSAGE_FORWARD(AutofillHostMsg_DidFillAutofillFormData, + autofill_manager_.get(), + AutofillManager::OnDidFillAutofillFormData) + IPC_MESSAGE_FORWARD(AutofillHostMsg_DidEndTextFieldEditing, + autofill_manager_.get(), + AutofillManager::OnDidEndTextFieldEditing) + IPC_MESSAGE_FORWARD(AutofillHostMsg_HidePopup, + autofill_manager_.get(), + AutofillManager::OnHidePopup) + IPC_MESSAGE_FORWARD(AutofillHostMsg_AddPasswordFormMapping, + autofill_manager_.get(), + AutofillManager::OnAddPasswordFormMapping) + IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions, + autofill_manager_.get(), + AutofillManager::OnShowPasswordSuggestions) + IPC_MESSAGE_FORWARD(AutofillHostMsg_SetDataList, + autofill_manager_.get(), + AutofillManager::OnSetDataList) + IPC_MESSAGE_FORWARD(AutofillHostMsg_RequestAutocomplete, + &request_autocomplete_manager_, + RequestAutocompleteManager::OnRequestAutocomplete) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void ContentAutofillDriver::DidNavigateMainFrame( + const content::LoadCommittedDetails& details, + const content::FrameNavigateParams& params) { + if (details.is_navigation_to_different_page()) + autofill_manager_->Reset(); +} + +void ContentAutofillDriver::SetAutofillManager( + scoped_ptr<AutofillManager> manager) { + autofill_manager_ = manager.Pass(); + autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); +} + +void ContentAutofillDriver::NavigationEntryCommitted( + const content::LoadCommittedDetails& load_details) { + autofill_manager_->delegate()->HideAutofillPopup(); +} + +void ContentAutofillDriver::WasHidden() { + autofill_manager_->delegate()->HideAutofillPopup(); +} + +} // namespace autofill diff --git a/components/autofill/content/browser/autofill_driver_impl.h b/components/autofill/content/browser/content_autofill_driver.h index 6fa1b41..dcf1a5f 100644 --- a/components/autofill/content/browser/autofill_driver_impl.h +++ b/components/autofill/content/browser/content_autofill_driver.h @@ -1,9 +1,9 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_ -#define COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_ +#ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ +#define COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ #include <string> @@ -31,16 +31,16 @@ class AutofillManagerDelegate; // Class that drives autofill flow in the browser process based on // communication from the renderer and from the external world. There is one // instance per WebContents. -class AutofillDriverImpl : public AutofillDriver, - public content::WebContentsObserver, - public base::SupportsUserData::Data { +class ContentAutofillDriver : public AutofillDriver, + public content::WebContentsObserver, + public base::SupportsUserData::Data { public: static void CreateForWebContentsAndDelegate( content::WebContents* contents, autofill::AutofillManagerDelegate* delegate, const std::string& app_locale, AutofillManager::AutofillDownloadManagerState enable_download_manager); - static AutofillDriverImpl* FromWebContents(content::WebContents* contents); + static ContentAutofillDriver* FromWebContents(content::WebContents* contents); // AutofillDriver: virtual bool IsOffTheRecord() const OVERRIDE; @@ -70,12 +70,12 @@ class AutofillDriverImpl : public AutofillDriver, AutofillManager* autofill_manager() { return autofill_manager_.get(); } protected: - AutofillDriverImpl( + ContentAutofillDriver( content::WebContents* web_contents, autofill::AutofillManagerDelegate* delegate, const std::string& app_locale, AutofillManager::AutofillDownloadManagerState enable_download_manager); - virtual ~AutofillDriverImpl(); + virtual ~ContentAutofillDriver(); // content::WebContentsObserver: virtual void DidNavigateMainFrame( @@ -105,4 +105,4 @@ class AutofillDriverImpl : public AutofillDriver, } // namespace autofill -#endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_ +#endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ diff --git a/components/autofill/content/browser/autofill_driver_impl_unittest.cc b/components/autofill/content/browser/content_autofill_driver_unittest.cc index 1e69b43..fc0b140 100644 --- a/components/autofill/content/browser/autofill_driver_impl_unittest.cc +++ b/components/autofill/content/browser/content_autofill_driver_unittest.cc @@ -1,4 +1,4 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "base/strings/utf_string_conversions.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/content/common/autofill_messages.h" #include "components/autofill/core/browser/autofill_external_delegate.h" #include "components/autofill/core/browser/autofill_manager.h" @@ -38,41 +38,39 @@ const AutofillManager::AutofillDownloadManagerState kDownloadState = class MockAutofillManager : public AutofillManager { public: - MockAutofillManager(AutofillDriver* driver, - AutofillManagerDelegate* delegate) - : AutofillManager(driver, delegate, kAppLocale, kDownloadState) { - } + MockAutofillManager(AutofillDriver* driver, AutofillManagerDelegate* delegate) + : AutofillManager(driver, delegate, kAppLocale, kDownloadState) {} virtual ~MockAutofillManager() {} MOCK_METHOD0(Reset, void()); }; -class TestAutofillDriverImpl : public AutofillDriverImpl { +class TestContentAutofillDriver : public ContentAutofillDriver { public: - TestAutofillDriverImpl(content::WebContents* contents, - AutofillManagerDelegate* delegate) - : AutofillDriverImpl(contents, delegate, kAppLocale, kDownloadState) { + TestContentAutofillDriver(content::WebContents* contents, + AutofillManagerDelegate* delegate) + : ContentAutofillDriver(contents, delegate, kAppLocale, kDownloadState) { scoped_ptr<AutofillManager> autofill_manager( new MockAutofillManager(this, delegate)); SetAutofillManager(autofill_manager.Pass()); } - virtual ~TestAutofillDriverImpl() {} + virtual ~TestContentAutofillDriver() {} virtual MockAutofillManager* mock_autofill_manager() { return static_cast<MockAutofillManager*>(autofill_manager()); } - using AutofillDriverImpl::DidNavigateMainFrame; + using ContentAutofillDriver::DidNavigateMainFrame; }; -class AutofillDriverImplTest : public ChromeRenderViewHostTestHarness { +class ContentAutofillDriverTest : public ChromeRenderViewHostTestHarness { public: virtual void SetUp() OVERRIDE { ChromeRenderViewHostTestHarness::SetUp(); test_manager_delegate_.reset(new TestAutofillManagerDelegate()); - driver_.reset(new TestAutofillDriverImpl(web_contents(), - test_manager_delegate_.get())); + driver_.reset(new TestContentAutofillDriver(web_contents(), + test_manager_delegate_.get())); } virtual void TearDown() OVERRIDE { @@ -168,10 +166,9 @@ class AutofillDriverImplTest : public ChromeRenderViewHostTestHarness { &autofill_param)) return false; break; - case AutofillMsg_AcceptPasswordAutofillSuggestion::ID: + case AutofillMsg_AcceptPasswordAutofillSuggestion::ID: if (!AutofillMsg_AcceptPasswordAutofillSuggestion::Read( - message, - &autofill_param)) + message, &autofill_param)) return false; break; default: @@ -196,10 +193,10 @@ class AutofillDriverImplTest : public ChromeRenderViewHostTestHarness { } scoped_ptr<TestAutofillManagerDelegate> test_manager_delegate_; - scoped_ptr<TestAutofillDriverImpl> driver_; + scoped_ptr<TestContentAutofillDriver> driver_; }; -TEST_F(AutofillDriverImplTest, GetURLRequestContext) { +TEST_F(ContentAutofillDriverTest, GetURLRequestContext) { net::URLRequestContextGetter* request_context = driver_->GetURLRequestContext(); net::URLRequestContextGetter* expected_request_context = @@ -207,7 +204,7 @@ TEST_F(AutofillDriverImplTest, GetURLRequestContext) { EXPECT_EQ(request_context, expected_request_context); } -TEST_F(AutofillDriverImplTest, NavigatedToDifferentPage) { +TEST_F(ContentAutofillDriverTest, NavigatedToDifferentPage) { EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()); content::LoadCommittedDetails details = content::LoadCommittedDetails(); details.is_main_frame = true; @@ -217,7 +214,7 @@ TEST_F(AutofillDriverImplTest, NavigatedToDifferentPage) { driver_->DidNavigateMainFrame(details, params); } -TEST_F(AutofillDriverImplTest, NavigatedWithinSamePage) { +TEST_F(ContentAutofillDriverTest, NavigatedWithinSamePage) { EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()).Times(0); content::LoadCommittedDetails details = content::LoadCommittedDetails(); details.is_main_frame = false; @@ -226,43 +223,40 @@ TEST_F(AutofillDriverImplTest, NavigatedWithinSamePage) { driver_->DidNavigateMainFrame(details, params); } -TEST_F(AutofillDriverImplTest, FormDataSentToRenderer_FillForm) { +TEST_F(ContentAutofillDriverTest, FormDataSentToRenderer_FillForm) { int input_page_id = 42; FormData input_form_data; test::CreateTestAddressFormData(&input_form_data); - driver_->SendFormDataToRenderer(input_page_id, - AutofillDriver::FORM_DATA_ACTION_FILL, - input_form_data); + driver_->SendFormDataToRenderer( + input_page_id, AutofillDriver::FORM_DATA_ACTION_FILL, input_form_data); int output_page_id = 0; FormData output_form_data; - EXPECT_FALSE(GetAutofillPreviewFormMessage(&output_page_id, - &output_form_data)); - EXPECT_TRUE(GetAutofillFillFormMessage(&output_page_id, - &output_form_data)); + EXPECT_FALSE( + GetAutofillPreviewFormMessage(&output_page_id, &output_form_data)); + EXPECT_TRUE(GetAutofillFillFormMessage(&output_page_id, &output_form_data)); EXPECT_EQ(input_page_id, output_page_id); EXPECT_EQ(input_form_data, output_form_data); } -TEST_F(AutofillDriverImplTest, FormDataSentToRenderer_PreviewForm) { +TEST_F(ContentAutofillDriverTest, FormDataSentToRenderer_PreviewForm) { int input_page_id = 42; FormData input_form_data; test::CreateTestAddressFormData(&input_form_data); - driver_->SendFormDataToRenderer(input_page_id, - AutofillDriver::FORM_DATA_ACTION_PREVIEW, - input_form_data); + driver_->SendFormDataToRenderer( + input_page_id, AutofillDriver::FORM_DATA_ACTION_PREVIEW, input_form_data); int output_page_id = 0; FormData output_form_data; - EXPECT_FALSE(GetAutofillFillFormMessage(&output_page_id, - &output_form_data)); - EXPECT_TRUE(GetAutofillPreviewFormMessage(&output_page_id, - &output_form_data)); + EXPECT_FALSE(GetAutofillFillFormMessage(&output_page_id, &output_form_data)); + EXPECT_TRUE( + GetAutofillPreviewFormMessage(&output_page_id, &output_form_data)); EXPECT_EQ(input_page_id, output_page_id); EXPECT_EQ(input_form_data, output_form_data); } -TEST_F(AutofillDriverImplTest, TypePredictionsNotSentToRendererWhenDisabled) { +TEST_F(ContentAutofillDriverTest, + TypePredictionsNotSentToRendererWhenDisabled) { FormData form; test::CreateTestAddressFormData(&form); FormStructure form_structure(form); @@ -271,7 +265,7 @@ TEST_F(AutofillDriverImplTest, TypePredictionsNotSentToRendererWhenDisabled) { EXPECT_FALSE(GetFieldTypePredictionsAvailable(NULL)); } -TEST_F(AutofillDriverImplTest, TypePredictionsSentToRendererWhenEnabled) { +TEST_F(ContentAutofillDriverTest, TypePredictionsSentToRendererWhenEnabled) { CommandLine::ForCurrentProcess()->AppendSwitch( switches::kShowAutofillTypePredictions); @@ -288,42 +282,40 @@ TEST_F(AutofillDriverImplTest, TypePredictionsSentToRendererWhenEnabled) { EXPECT_EQ(expected_type_predictions, output_type_predictions); } -TEST_F(AutofillDriverImplTest, AcceptDataListSuggestion) { +TEST_F(ContentAutofillDriverTest, AcceptDataListSuggestion) { base::string16 input_value(base::ASCIIToUTF16("barfoo")); base::string16 output_value; driver_->RendererShouldAcceptDataListSuggestion(input_value); EXPECT_TRUE(GetString16FromMessageWithID( - AutofillMsg_AcceptDataListSuggestion::ID, - &output_value)); + AutofillMsg_AcceptDataListSuggestion::ID, &output_value)); EXPECT_EQ(input_value, output_value); } -TEST_F(AutofillDriverImplTest, AcceptPasswordAutofillSuggestion) { +TEST_F(ContentAutofillDriverTest, AcceptPasswordAutofillSuggestion) { base::string16 input_value(base::ASCIIToUTF16("barbaz")); base::string16 output_value; driver_->RendererShouldAcceptPasswordAutofillSuggestion(input_value); EXPECT_TRUE(GetString16FromMessageWithID( - AutofillMsg_AcceptPasswordAutofillSuggestion::ID, - &output_value)); + AutofillMsg_AcceptPasswordAutofillSuggestion::ID, &output_value)); EXPECT_EQ(input_value, output_value); } -TEST_F(AutofillDriverImplTest, ClearFilledFormSentToRenderer) { +TEST_F(ContentAutofillDriverTest, ClearFilledFormSentToRenderer) { driver_->RendererShouldClearFilledForm(); EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearForm::ID)); } -TEST_F(AutofillDriverImplTest, ClearPreviewedFormSentToRenderer) { +TEST_F(ContentAutofillDriverTest, ClearPreviewedFormSentToRenderer) { driver_->RendererShouldClearPreviewedForm(); EXPECT_TRUE(HasMessageMatchingID(AutofillMsg_ClearPreviewedForm::ID)); } -TEST_F(AutofillDriverImplTest, SetNodeText) { +TEST_F(ContentAutofillDriverTest, SetNodeText) { base::string16 input_value(base::ASCIIToUTF16("barqux")); base::string16 output_value; driver_->RendererShouldSetNodeText(input_value); - EXPECT_TRUE(GetString16FromMessageWithID(AutofillMsg_SetNodeText::ID, - &output_value)); + EXPECT_TRUE( + GetString16FromMessageWithID(AutofillMsg_SetNodeText::ID, &output_value)); EXPECT_EQ(input_value, output_value); } diff --git a/components/autofill/content/browser/request_autocomplete_manager.cc b/components/autofill/content/browser/request_autocomplete_manager.cc index 9f70b93..28aae9e 100644 --- a/components/autofill/content/browser/request_autocomplete_manager.cc +++ b/components/autofill/content/browser/request_autocomplete_manager.cc @@ -4,7 +4,7 @@ #include "components/autofill/content/browser/request_autocomplete_manager.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/content/common/autofill_messages.h" #include "components/autofill/core/browser/form_structure.h" #include "components/autofill/core/common/autofill_data_validation.h" @@ -16,9 +16,8 @@ namespace autofill { RequestAutocompleteManager::RequestAutocompleteManager( - AutofillDriverImpl* autofill_driver) - : autofill_driver_(autofill_driver), - weak_ptr_factory_(this) { + ContentAutofillDriver* autofill_driver) + : autofill_driver_(autofill_driver), weak_ptr_factory_(this) { DCHECK(autofill_driver_); } diff --git a/components/autofill/content/browser/request_autocomplete_manager.h b/components/autofill/content/browser/request_autocomplete_manager.h index 093e935..85b05ea 100644 --- a/components/autofill/content/browser/request_autocomplete_manager.h +++ b/components/autofill/content/browser/request_autocomplete_manager.h @@ -13,14 +13,14 @@ class GURL; namespace autofill { -class AutofillDriverImpl; +class ContentAutofillDriver; struct FormData; class FormStructure; // Driver for the requestAutocomplete flow. class RequestAutocompleteManager { public: - explicit RequestAutocompleteManager(AutofillDriverImpl* autofill_driver); + explicit RequestAutocompleteManager(ContentAutofillDriver* autofill_driver); ~RequestAutocompleteManager(); // Requests an interactive autocomplete UI to be shown for |frame_url| with @@ -49,7 +49,7 @@ class RequestAutocompleteManager { void ReturnAutocompleteData(const FormStructure* result); // The autofill driver owns and outlives |this|. - AutofillDriverImpl* const autofill_driver_; // weak. + ContentAutofillDriver* const autofill_driver_; // weak. base::WeakPtrFactory<RequestAutocompleteManager> weak_ptr_factory_; }; diff --git a/components/autofill/content/browser/request_autocomplete_manager_unittest.cc b/components/autofill/content/browser/request_autocomplete_manager_unittest.cc index 72fae80..4906172 100644 --- a/components/autofill/content/browser/request_autocomplete_manager_unittest.cc +++ b/components/autofill/content/browser/request_autocomplete_manager_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "chrome/test/base/chrome_render_view_host_test_harness.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/content/browser/request_autocomplete_manager.h" #include "components/autofill/content/common/autofill_messages.h" #include "components/autofill/core/browser/test_autofill_manager_delegate.h" @@ -69,23 +69,23 @@ class CustomTestAutofillManagerDelegate : public TestAutofillManagerDelegate { DISALLOW_COPY_AND_ASSIGN(CustomTestAutofillManagerDelegate); }; -class TestAutofillDriverImpl : public AutofillDriverImpl { +class TestContentAutofillDriver : public ContentAutofillDriver { public: - TestAutofillDriverImpl(content::WebContents* contents, - AutofillManagerDelegate* delegate) - : AutofillDriverImpl(contents, delegate, kAppLocale, kDownloadState) { + TestContentAutofillDriver(content::WebContents* contents, + AutofillManagerDelegate* delegate) + : ContentAutofillDriver(contents, delegate, kAppLocale, kDownloadState) { SetAutofillManager(make_scoped_ptr<AutofillManager>( new TestAutofillManager(this, delegate))); } - virtual ~TestAutofillDriverImpl() {} + virtual ~TestContentAutofillDriver() {} TestAutofillManager* mock_autofill_manager() { return static_cast<TestAutofillManager*>(autofill_manager()); } - using AutofillDriverImpl::DidNavigateMainFrame; + using ContentAutofillDriver::DidNavigateMainFrame; - DISALLOW_COPY_AND_ASSIGN(TestAutofillDriverImpl); + DISALLOW_COPY_AND_ASSIGN(TestContentAutofillDriver); }; } // namespace @@ -97,8 +97,8 @@ class RequestAutocompleteManagerTest : public ChromeRenderViewHostTestHarness { virtual void SetUp() OVERRIDE { ChromeRenderViewHostTestHarness::SetUp(); - driver_.reset(new TestAutofillDriverImpl(web_contents(), - &manager_delegate_)); + driver_.reset( + new TestContentAutofillDriver(web_contents(), &manager_delegate_)); request_autocomplete_manager_.reset( new RequestAutocompleteManager(driver_.get())); } @@ -131,7 +131,7 @@ class RequestAutocompleteManagerTest : public ChromeRenderViewHostTestHarness { protected: CustomTestAutofillManagerDelegate manager_delegate_; - scoped_ptr<TestAutofillDriverImpl> driver_; + scoped_ptr<TestContentAutofillDriver> driver_; scoped_ptr<RequestAutocompleteManager> request_autocomplete_manager_; DISALLOW_COPY_AND_ASSIGN(RequestAutocompleteManagerTest); diff --git a/components/password_manager/content/browser/content_password_manager_driver.cc b/components/password_manager/content/browser/content_password_manager_driver.cc index 83af883..c95a292 100644 --- a/components/password_manager/content/browser/content_password_manager_driver.cc +++ b/components/password_manager/content/browser/content_password_manager_driver.cc @@ -4,7 +4,7 @@ #include "components/password_manager/content/browser/content_password_manager_driver.h" -#include "components/autofill/content/browser/autofill_driver_impl.h" +#include "components/autofill/content/browser/content_autofill_driver.h" #include "components/autofill/content/common/autofill_messages.h" #include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/password_form.h" @@ -101,7 +101,7 @@ bool ContentPasswordManagerDriver::OnMessageReceived( } autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() { - autofill::AutofillDriverImpl* driver = - autofill::AutofillDriverImpl::FromWebContents(web_contents()); + autofill::ContentAutofillDriver* driver = + autofill::ContentAutofillDriver::FromWebContents(web_contents()); return driver ? driver->autofill_manager() : NULL; } |