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_manager_.reset( |
| 54 new AutofillManager(this, delegate, app_locale, enable_download_manager)); |
| 55 if (enable_native_ui) { |
| 56 // TODO(blundell): Eliminate AutofillExternalDelegate being a WCUD and |
| 57 // transfer ownership of it to this class. |
| 58 AutofillExternalDelegate::CreateForWebContentsAndManager( |
| 59 web_contents, autofill_manager_.get()); |
| 60 autofill_manager_->SetExternalDelegate( |
| 61 AutofillExternalDelegate::FromWebContents(web_contents)); |
| 62 } |
| 63 } |
| 64 |
| 65 AutofillDriverImpl::~AutofillDriverImpl() {} |
| 66 |
| 67 content::WebContents* AutofillDriverImpl::GetWebContents() { |
| 68 return web_contents(); |
| 69 } |
| 70 |
| 71 bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) { |
| 72 // TODO(blundell): Move IPC handling into this class. |
| 73 return autofill_manager_->OnMessageReceived(message); |
| 74 } |
| 75 |
| 76 void AutofillDriverImpl::DidNavigateMainFrame( |
| 77 const content::LoadCommittedDetails& details, |
| 78 const content::FrameNavigateParams& params) { |
| 79 // TODO(blundell): Move the logic of this method into this class. |
| 80 autofill_manager_->DidNavigateMainFrame(details, params); |
| 81 } |
| 82 |
| 83 } // namespace autofill |
OLD | NEW |