Chromium Code Reviews| 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.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* 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
| |
| 17 "web_contents_autofill_driver"; | |
| 18 | |
| 19 } // namespace | |
| 20 | |
| 21 // static | |
| 22 void AutofillDriver::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(kAutofillDriverWebContentsUserDataKey, | |
| 32 new AutofillDriver(contents, | |
| 33 delegate, | |
| 34 app_locale, | |
| 35 enable_download_manager, | |
| 36 enable_native_UI)); | |
| 37 } | |
| 38 | |
| 39 // static | |
| 40 AutofillDriver* AutofillDriver::FromWebContents( | |
| 41 content::WebContents* contents) { | |
| 42 return static_cast<AutofillDriver*>( | |
| 43 contents->GetUserData(kAutofillDriverWebContentsUserDataKey)); | |
| 44 } | |
| 45 | |
| 46 AutofillDriver::AutofillDriver( | |
| 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 delegate, | |
| 57 app_locale, | |
| 58 enable_download_manager); | |
| 59 autofill_manager_ = AutofillManager::FromWebContents(web_contents); | |
| 60 | |
| 61 if (enable_native_UI) { | |
| 62 // TODO(blundell): Eliminate AutofillExternalDelegate being a WCUD. | |
| 63 AutofillExternalDelegate::CreateForWebContentsAndManager( | |
| 64 web_contents, autofill_manager_); | |
| 65 autofill_external_delegate_ = | |
| 66 AutofillExternalDelegate::FromWebContents(web_contents); | |
| 67 autofill_manager_->SetExternalDelegate(autofill_external_delegate_); | |
| 68 } | |
| 69 } | |
| 70 | |
| 71 AutofillDriver::~AutofillDriver() {} | |
| 72 | |
| 73 bool AutofillDriver::OnMessageReceived(const IPC::Message& message) { | |
| 74 // TODO(blundell): Move IPC handling into this class. | |
| 75 return autofill_manager_->OnMessageReceived(message); | |
| 76 } | |
| 77 | |
| 78 void AutofillDriver::DidNavigateMainFrame( | |
| 79 const content::LoadCommittedDetails& details, | |
| 80 const content::FrameNavigateParams& params) { | |
| 81 // TODO(blundell): Move the logic of this method into this class. | |
| 82 autofill_manager_->DidNavigateMainFrame(details, params); | |
| 83 } | |
| 84 | |
| 85 } // namespace autofill | |
| OLD | NEW |