| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/content/browser/content_autofill_driver.h" | 5 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
| 9 #include "components/autofill/content/common/autofill_messages.h" | 9 #include "components/autofill/content/common/autofill_messages.h" |
| 10 #include "components/autofill/core/browser/autofill_client.h" |
| 10 #include "components/autofill/core/browser/autofill_external_delegate.h" | 11 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| 11 #include "components/autofill/core/browser/autofill_manager.h" | 12 #include "components/autofill/core/browser/autofill_manager.h" |
| 12 #include "components/autofill/core/browser/autofill_manager_delegate.h" | |
| 13 #include "components/autofill/core/browser/form_structure.h" | 13 #include "components/autofill/core/browser/form_structure.h" |
| 14 #include "components/autofill/core/common/autofill_switches.h" | 14 #include "components/autofill/core/common/autofill_switches.h" |
| 15 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
| 18 #include "content/public/browser/navigation_details.h" | 18 #include "content/public/browser/navigation_details.h" |
| 19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/common/frame_navigate_params.h" | 21 #include "content/public/common/frame_navigate_params.h" |
| 22 #include "ipc/ipc_message_macros.h" | 22 #include "ipc/ipc_message_macros.h" |
| 23 | 23 |
| 24 namespace autofill { | 24 namespace autofill { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 const char kContentAutofillDriverWebContentsUserDataKey[] = | 28 const char kContentAutofillDriverWebContentsUserDataKey[] = |
| 29 "web_contents_autofill_driver_impl"; | 29 "web_contents_autofill_driver_impl"; |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 // static | 33 // static |
| 34 void ContentAutofillDriver::CreateForWebContentsAndDelegate( | 34 void ContentAutofillDriver::CreateForWebContentsAndDelegate( |
| 35 content::WebContents* contents, | 35 content::WebContents* contents, |
| 36 autofill::AutofillManagerDelegate* delegate, | 36 AutofillClient* client, |
| 37 const std::string& app_locale, | 37 const std::string& app_locale, |
| 38 AutofillManager::AutofillDownloadManagerState enable_download_manager) { | 38 AutofillManager::AutofillDownloadManagerState enable_download_manager) { |
| 39 if (FromWebContents(contents)) | 39 if (FromWebContents(contents)) |
| 40 return; | 40 return; |
| 41 | 41 |
| 42 contents->SetUserData( | 42 contents->SetUserData( |
| 43 kContentAutofillDriverWebContentsUserDataKey, | 43 kContentAutofillDriverWebContentsUserDataKey, |
| 44 new ContentAutofillDriver( | 44 new ContentAutofillDriver( |
| 45 contents, delegate, app_locale, enable_download_manager)); | 45 contents, client, app_locale, enable_download_manager)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // static | 48 // static |
| 49 ContentAutofillDriver* ContentAutofillDriver::FromWebContents( | 49 ContentAutofillDriver* ContentAutofillDriver::FromWebContents( |
| 50 content::WebContents* contents) { | 50 content::WebContents* contents) { |
| 51 return static_cast<ContentAutofillDriver*>( | 51 return static_cast<ContentAutofillDriver*>( |
| 52 contents->GetUserData(kContentAutofillDriverWebContentsUserDataKey)); | 52 contents->GetUserData(kContentAutofillDriverWebContentsUserDataKey)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 ContentAutofillDriver::ContentAutofillDriver( | 55 ContentAutofillDriver::ContentAutofillDriver( |
| 56 content::WebContents* web_contents, | 56 content::WebContents* web_contents, |
| 57 autofill::AutofillManagerDelegate* delegate, | 57 AutofillClient* client, |
| 58 const std::string& app_locale, | 58 const std::string& app_locale, |
| 59 AutofillManager::AutofillDownloadManagerState enable_download_manager) | 59 AutofillManager::AutofillDownloadManagerState enable_download_manager) |
| 60 : content::WebContentsObserver(web_contents), | 60 : content::WebContentsObserver(web_contents), |
| 61 autofill_manager_(new AutofillManager(this, | 61 autofill_manager_(new AutofillManager(this, |
| 62 delegate, | 62 client, |
| 63 app_locale, | 63 app_locale, |
| 64 enable_download_manager)), | 64 enable_download_manager)), |
| 65 autofill_external_delegate_(autofill_manager_.get(), this), | 65 autofill_external_delegate_(autofill_manager_.get(), this), |
| 66 request_autocomplete_manager_(this) { | 66 request_autocomplete_manager_(this) { |
| 67 autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); | 67 autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); |
| 68 } | 68 } |
| 69 | 69 |
| 70 ContentAutofillDriver::~ContentAutofillDriver() {} | 70 ContentAutofillDriver::~ContentAutofillDriver() {} |
| 71 | 71 |
| 72 bool ContentAutofillDriver::IsOffTheRecord() const { | 72 bool ContentAutofillDriver::IsOffTheRecord() const { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 212 } |
| 213 | 213 |
| 214 void ContentAutofillDriver::SetAutofillManager( | 214 void ContentAutofillDriver::SetAutofillManager( |
| 215 scoped_ptr<AutofillManager> manager) { | 215 scoped_ptr<AutofillManager> manager) { |
| 216 autofill_manager_ = manager.Pass(); | 216 autofill_manager_ = manager.Pass(); |
| 217 autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); | 217 autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void ContentAutofillDriver::NavigationEntryCommitted( | 220 void ContentAutofillDriver::NavigationEntryCommitted( |
| 221 const content::LoadCommittedDetails& load_details) { | 221 const content::LoadCommittedDetails& load_details) { |
| 222 autofill_manager_->delegate()->HideAutofillPopup(); | 222 autofill_manager_->client()->HideAutofillPopup(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void ContentAutofillDriver::WasHidden() { | 225 void ContentAutofillDriver::WasHidden() { |
| 226 autofill_manager_->delegate()->HideAutofillPopup(); | 226 autofill_manager_->client()->HideAutofillPopup(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace autofill | 229 } // namespace autofill |
| OLD | NEW |