| Index: components/autofill/content/browser/autofill_driver_impl.cc
|
| diff --git a/components/autofill/content/browser/autofill_driver_impl.cc b/components/autofill/content/browser/autofill_driver_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f1002fc1ebf4266ade64e1fd53e3ad46dc07f7c5
|
| --- /dev/null
|
| +++ b/components/autofill/content/browser/autofill_driver_impl.cc
|
| @@ -0,0 +1,83 @@
|
| +// 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 "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 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,
|
| + bool enable_native_ui) {
|
| + if (FromWebContents(contents))
|
| + return;
|
| +
|
| + contents->SetUserData(kAutofillDriverImplWebContentsUserDataKey,
|
| + new AutofillDriverImpl(contents,
|
| + delegate,
|
| + app_locale,
|
| + enable_download_manager,
|
| + enable_native_ui));
|
| +}
|
| +
|
| +// 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,
|
| + bool enable_native_ui)
|
| + : content::WebContentsObserver(web_contents) {
|
| + autofill_manager_.reset(
|
| + new AutofillManager(this, delegate, app_locale, enable_download_manager));
|
| + if (enable_native_ui) {
|
| + // TODO(blundell): Eliminate AutofillExternalDelegate being a WCUD and
|
| + // transfer ownership of it to this class.
|
| + AutofillExternalDelegate::CreateForWebContentsAndManager(
|
| + web_contents, autofill_manager_.get());
|
| + autofill_manager_->SetExternalDelegate(
|
| + AutofillExternalDelegate::FromWebContents(web_contents));
|
| + }
|
| +}
|
| +
|
| +AutofillDriverImpl::~AutofillDriverImpl() {}
|
| +
|
| +content::WebContents* AutofillDriverImpl::GetWebContents() {
|
| + return web_contents();
|
| +}
|
| +
|
| +bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) {
|
| + // TODO(blundell): Move IPC handling into this class.
|
| + return autofill_manager_->OnMessageReceived(message);
|
| +}
|
| +
|
| +void AutofillDriverImpl::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
|
|
|