| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/autofill_driver_impl.h" | 5 #include "components/autofill/content/browser/autofill_driver_impl.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_external_delegate.h" | 10 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 const char kAutofillDriverImplWebContentsUserDataKey[] = | 28 const char kAutofillDriverImplWebContentsUserDataKey[] = |
| 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 AutofillDriverImpl::CreateForWebContentsAndDelegate( | 34 void AutofillDriverImpl::CreateForWebContentsAndDelegate( |
| 35 content::WebContents* contents, | 35 content::WebContents* contents, |
| 36 autofill::AutofillManagerDelegate* delegate, | 36 autofill::AutofillManagerDelegate* delegate, |
| 37 PasswordManagerDriver* password_manager_driver, |
| 37 const std::string& app_locale, | 38 const std::string& app_locale, |
| 38 AutofillManager::AutofillDownloadManagerState enable_download_manager) { | 39 AutofillManager::AutofillDownloadManagerState enable_download_manager) { |
| 39 if (FromWebContents(contents)) | 40 if (FromWebContents(contents)) |
| 40 return; | 41 return; |
| 41 | 42 |
| 42 contents->SetUserData(kAutofillDriverImplWebContentsUserDataKey, | 43 contents->SetUserData(kAutofillDriverImplWebContentsUserDataKey, |
| 43 new AutofillDriverImpl(contents, | 44 new AutofillDriverImpl(contents, |
| 44 delegate, | 45 delegate, |
| 46 password_manager_driver, |
| 45 app_locale, | 47 app_locale, |
| 46 enable_download_manager)); | 48 enable_download_manager)); |
| 47 } | 49 } |
| 48 | 50 |
| 49 // static | 51 // static |
| 50 AutofillDriverImpl* AutofillDriverImpl::FromWebContents( | 52 AutofillDriverImpl* AutofillDriverImpl::FromWebContents( |
| 51 content::WebContents* contents) { | 53 content::WebContents* contents) { |
| 52 return static_cast<AutofillDriverImpl*>( | 54 return static_cast<AutofillDriverImpl*>( |
| 53 contents->GetUserData(kAutofillDriverImplWebContentsUserDataKey)); | 55 contents->GetUserData(kAutofillDriverImplWebContentsUserDataKey)); |
| 54 } | 56 } |
| 55 | 57 |
| 56 AutofillDriverImpl::AutofillDriverImpl( | 58 AutofillDriverImpl::AutofillDriverImpl( |
| 57 content::WebContents* web_contents, | 59 content::WebContents* web_contents, |
| 58 autofill::AutofillManagerDelegate* delegate, | 60 autofill::AutofillManagerDelegate* delegate, |
| 61 PasswordManagerDriver* password_manager_driver, |
| 59 const std::string& app_locale, | 62 const std::string& app_locale, |
| 60 AutofillManager::AutofillDownloadManagerState enable_download_manager) | 63 AutofillManager::AutofillDownloadManagerState enable_download_manager) |
| 61 : content::WebContentsObserver(web_contents), | 64 : content::WebContentsObserver(web_contents), |
| 62 autofill_manager_(new AutofillManager( | 65 autofill_manager_(new AutofillManager( |
| 63 this, delegate, app_locale, enable_download_manager)), | 66 this, delegate, app_locale, enable_download_manager)), |
| 64 autofill_external_delegate_(autofill_manager_.get(), this), | 67 autofill_external_delegate_( |
| 68 autofill_manager_.get(), |
| 69 this, |
| 70 new PasswordAutofillManager(password_manager_driver)), |
| 65 request_autocomplete_manager_(this) { | 71 request_autocomplete_manager_(this) { |
| 66 autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); | 72 autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); |
| 67 } | 73 } |
| 68 | 74 |
| 69 AutofillDriverImpl::~AutofillDriverImpl() {} | 75 AutofillDriverImpl::~AutofillDriverImpl() {} |
| 70 | 76 |
| 71 bool AutofillDriverImpl::IsOffTheRecord() const { | 77 bool AutofillDriverImpl::IsOffTheRecord() const { |
| 72 return web_contents()->GetBrowserContext()->IsOffTheRecord(); | 78 return web_contents()->GetBrowserContext()->IsOffTheRecord(); |
| 73 } | 79 } |
| 74 | 80 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 139 |
| 134 void AutofillDriverImpl::RendererShouldAcceptDataListSuggestion( | 140 void AutofillDriverImpl::RendererShouldAcceptDataListSuggestion( |
| 135 const base::string16& value) { | 141 const base::string16& value) { |
| 136 if (!RendererIsAvailable()) | 142 if (!RendererIsAvailable()) |
| 137 return; | 143 return; |
| 138 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | 144 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); |
| 139 host->Send(new AutofillMsg_AcceptDataListSuggestion(host->GetRoutingID(), | 145 host->Send(new AutofillMsg_AcceptDataListSuggestion(host->GetRoutingID(), |
| 140 value)); | 146 value)); |
| 141 } | 147 } |
| 142 | 148 |
| 143 void AutofillDriverImpl::RendererShouldAcceptPasswordAutofillSuggestion( | |
| 144 const base::string16& username) { | |
| 145 if (!RendererIsAvailable()) | |
| 146 return; | |
| 147 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | |
| 148 host->Send( | |
| 149 new AutofillMsg_AcceptPasswordAutofillSuggestion(host->GetRoutingID(), | |
| 150 username)); | |
| 151 } | |
| 152 | |
| 153 void AutofillDriverImpl::RendererShouldClearFilledForm() { | 149 void AutofillDriverImpl::RendererShouldClearFilledForm() { |
| 154 if (!RendererIsAvailable()) | 150 if (!RendererIsAvailable()) |
| 155 return; | 151 return; |
| 156 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | 152 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); |
| 157 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); | 153 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); |
| 158 } | 154 } |
| 159 | 155 |
| 160 void AutofillDriverImpl::RendererShouldClearPreviewedForm() { | 156 void AutofillDriverImpl::RendererShouldClearPreviewedForm() { |
| 161 if (!RendererIsAvailable()) | 157 if (!RendererIsAvailable()) |
| 162 return; | 158 return; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 void AutofillDriverImpl::NavigationEntryCommitted( | 227 void AutofillDriverImpl::NavigationEntryCommitted( |
| 232 const content::LoadCommittedDetails& load_details) { | 228 const content::LoadCommittedDetails& load_details) { |
| 233 autofill_manager_->delegate()->HideAutofillPopup(); | 229 autofill_manager_->delegate()->HideAutofillPopup(); |
| 234 } | 230 } |
| 235 | 231 |
| 236 void AutofillDriverImpl::WasHidden() { | 232 void AutofillDriverImpl::WasHidden() { |
| 237 autofill_manager_->delegate()->HideAutofillPopup(); | 233 autofill_manager_->delegate()->HideAutofillPopup(); |
| 238 } | 234 } |
| 239 | 235 |
| 240 } // namespace autofill | 236 } // namespace autofill |
| OLD | NEW |