OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/autofill/content/browser/autofill_driver_impl.h" |
| 6 |
| 7 #include "components/autofill/browser/autofill_external_delegate.h" |
| 8 #include "components/autofill/browser/autofill_manager.h" |
| 9 #include "components/autofill/browser/autofill_manager_delegate.h" |
| 10 #include "content/public/browser/web_contents.h" |
| 11 |
| 12 namespace autofill { |
| 13 |
| 14 namespace { |
| 15 |
| 16 const char kAutofillDriverImplWebContentsUserDataKey[] = |
| 17 "web_contents_autofill_driver_impl"; |
| 18 |
| 19 } // namespace |
| 20 |
| 21 // static |
| 22 void AutofillDriverImpl::CreateForWebContentsAndDelegate( |
| 23 content::WebContents* contents, |
| 24 autofill::AutofillManagerDelegate* delegate, |
| 25 const std::string& app_locale, |
| 26 AutofillManager::AutofillDownloadManagerState enable_download_manager, |
| 27 bool enable_native_UI) { |
| 28 if (FromWebContents(contents)) |
| 29 return; |
| 30 |
| 31 contents->SetUserData(kAutofillDriverImplWebContentsUserDataKey, |
| 32 new AutofillDriverImpl(contents, |
| 33 delegate, |
| 34 app_locale, |
| 35 enable_download_manager, |
| 36 enable_native_UI)); |
| 37 } |
| 38 |
| 39 // static |
| 40 AutofillDriverImpl* AutofillDriverImpl::FromWebContents( |
| 41 content::WebContents* contents) { |
| 42 return static_cast<AutofillDriverImpl*>( |
| 43 contents->GetUserData(kAutofillDriverImplWebContentsUserDataKey)); |
| 44 } |
| 45 |
| 46 AutofillDriverImpl::AutofillDriverImpl( |
| 47 content::WebContents* web_contents, |
| 48 autofill::AutofillManagerDelegate* delegate, |
| 49 const std::string& app_locale, |
| 50 AutofillManager::AutofillDownloadManagerState enable_download_manager, |
| 51 bool enable_native_UI) |
| 52 : content::WebContentsObserver(web_contents), |
| 53 autofill_external_delegate_(NULL) { |
| 54 // TODO(blundell): Eliminate AutofillManager being a WCUD. |
| 55 AutofillManager::CreateForWebContentsAndDelegate(web_contents, |
| 56 this, |
| 57 delegate, |
| 58 app_locale, |
| 59 enable_download_manager); |
| 60 autofill_manager_ = AutofillManager::FromWebContents(web_contents); |
| 61 |
| 62 if (enable_native_UI) { |
| 63 // TODO(blundell): Eliminate AutofillExternalDelegate being a WCUD. |
| 64 AutofillExternalDelegate::CreateForWebContentsAndManager( |
| 65 web_contents, autofill_manager_); |
| 66 autofill_external_delegate_ = |
| 67 AutofillExternalDelegate::FromWebContents(web_contents); |
| 68 autofill_manager_->SetExternalDelegate(autofill_external_delegate_); |
| 69 } |
| 70 } |
| 71 |
| 72 AutofillDriverImpl::~AutofillDriverImpl() {} |
| 73 |
| 74 content::WebContents* AutofillDriverImpl::GetWebContents() { |
| 75 return web_contents(); |
| 76 } |
| 77 |
| 78 bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) { |
| 79 // TODO(blundell): Move IPC handling into this class. |
| 80 return autofill_manager_->OnMessageReceived(message); |
| 81 } |
| 82 |
| 83 void AutofillDriverImpl::DidNavigateMainFrame( |
| 84 const content::LoadCommittedDetails& details, |
| 85 const content::FrameNavigateParams& params) { |
| 86 // TODO(blundell): Move the logic of this method into this class. |
| 87 autofill_manager_->DidNavigateMainFrame(details, params); |
| 88 } |
| 89 |
| 90 } // namespace autofill |
OLD | NEW |