Chromium Code Reviews| Index: components/autofill/content/browser/autofill_driver.cc |
| diff --git a/components/autofill/content/browser/autofill_driver.cc b/components/autofill/content/browser/autofill_driver.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..750878efdd55aac807aa80855a4fddfc4eb775a9 |
| --- /dev/null |
| +++ b/components/autofill/content/browser/autofill_driver.cc |
| @@ -0,0 +1,85 @@ |
| +// 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.h" |
| + |
| +#include "components/autofill/browser/autofill_external_delegate.h" |
| +#include "components/autofill/browser/autofill_manager.h" |
| +#include "components/autofill/browser/autofill_manager_delegate.h" |
| +#include "content/public/browser/web_contents.h" |
| + |
| +namespace autofill { |
| + |
| +namespace { |
| + |
| +const char* kAutofillDriverWebContentsUserDataKey = |
|
Ilya Sherman
2013/06/05 10:50:02
nit: const char kAutofillDriverWebContentsUserData
blundell
2013/06/11 15:35:47
I looked into doing this but it got messy as some
blundell
2013/06/11 21:19:27
This comment was meant to address your suggestion
|
| + "web_contents_autofill_driver"; |
| + |
| +} // namespace |
| + |
| +// static |
| +void AutofillDriver::CreateForWebContentsAndDelegate( |
| + content::WebContents* contents, |
| + autofill::AutofillManagerDelegate* delegate, |
| + const std::string& app_locale, |
| + AutofillManager::AutofillDownloadManagerState enable_download_manager, |
| + bool enable_native_UI) { |
| + if (FromWebContents(contents)) |
| + return; |
| + |
| + contents->SetUserData(kAutofillDriverWebContentsUserDataKey, |
| + new AutofillDriver(contents, |
| + delegate, |
| + app_locale, |
| + enable_download_manager, |
| + enable_native_UI)); |
| +} |
| + |
| +// static |
| +AutofillDriver* AutofillDriver::FromWebContents( |
| + content::WebContents* contents) { |
| + return static_cast<AutofillDriver*>( |
| + contents->GetUserData(kAutofillDriverWebContentsUserDataKey)); |
| +} |
| + |
| +AutofillDriver::AutofillDriver( |
| + content::WebContents* web_contents, |
| + autofill::AutofillManagerDelegate* delegate, |
| + const std::string& app_locale, |
| + AutofillManager::AutofillDownloadManagerState enable_download_manager, |
| + bool enable_native_UI) |
| + : content::WebContentsObserver(web_contents), |
| + autofill_external_delegate_(NULL) { |
| + // TODO(blundell): Eliminate AutofillManager being a WCUD. |
| + AutofillManager::CreateForWebContentsAndDelegate(web_contents, |
| + delegate, |
| + app_locale, |
| + enable_download_manager); |
| + autofill_manager_ = AutofillManager::FromWebContents(web_contents); |
| + |
| + if (enable_native_UI) { |
| + // TODO(blundell): Eliminate AutofillExternalDelegate being a WCUD. |
| + AutofillExternalDelegate::CreateForWebContentsAndManager( |
| + web_contents, autofill_manager_); |
| + autofill_external_delegate_ = |
| + AutofillExternalDelegate::FromWebContents(web_contents); |
| + autofill_manager_->SetExternalDelegate(autofill_external_delegate_); |
| + } |
| +} |
| + |
| +AutofillDriver::~AutofillDriver() {} |
| + |
| +bool AutofillDriver::OnMessageReceived(const IPC::Message& message) { |
| + // TODO(blundell): Move IPC handling into this class. |
| + return autofill_manager_->OnMessageReceived(message); |
| +} |
| + |
| +void AutofillDriver::DidNavigateMainFrame( |
| + const content::LoadCommittedDetails& details, |
| + const content::FrameNavigateParams& params) { |
| + // TODO(blundell): Move the logic of this method into this class. |
| + autofill_manager_->DidNavigateMainFrame(details, params); |
| +} |
| + |
| +} // namespace autofill |