| 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/request_autocomplete_manager.h" | 5 #include "components/autofill/content/browser/request_autocomplete_manager.h" |
| 6 | 6 |
| 7 #include "components/autofill/content/browser/autofill_driver_impl.h" | 7 #include "components/autofill/content/browser/autofill_driver_impl.h" |
| 8 #include "components/autofill/content/common/autofill_messages.h" | 8 #include "components/autofill/content/common/autofill_messages.h" |
| 9 #include "components/autofill/core/browser/form_structure.h" | 9 #include "components/autofill/core/browser/form_structure.h" |
| 10 #include "components/autofill/core/common/autofill_data_sanitizer.h" |
| 10 #include "components/autofill/core/common/form_data.h" | 11 #include "components/autofill/core/common/form_data.h" |
| 11 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
| 12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 14 | 15 |
| 15 namespace autofill { | 16 namespace autofill { |
| 16 | 17 |
| 17 RequestAutocompleteManager::RequestAutocompleteManager( | 18 RequestAutocompleteManager::RequestAutocompleteManager( |
| 18 AutofillDriverImpl* autofill_driver) | 19 AutofillDriverImpl* autofill_driver) |
| 19 : autofill_driver_(autofill_driver), | 20 : autofill_driver_(autofill_driver), |
| 20 weak_ptr_factory_(this) { | 21 weak_ptr_factory_(this) { |
| 21 DCHECK(autofill_driver_); | 22 DCHECK(autofill_driver_); |
| 22 } | 23 } |
| 23 | 24 |
| 24 RequestAutocompleteManager::~RequestAutocompleteManager() {} | 25 RequestAutocompleteManager::~RequestAutocompleteManager() {} |
| 25 | 26 |
| 26 void RequestAutocompleteManager::OnRequestAutocomplete( | 27 void RequestAutocompleteManager::OnRequestAutocomplete( |
| 27 const FormData& form, | 28 const FormData& form, |
| 28 const GURL& frame_url) { | 29 const GURL& frame_url) { |
| 30 // Bail if the arguments appear to be corrupt. |
| 31 if (!IsSanitizedFormData(form)) |
| 32 return; |
| 33 |
| 29 if (!autofill_driver_->autofill_manager()->IsAutofillEnabled()) { | 34 if (!autofill_driver_->autofill_manager()->IsAutofillEnabled()) { |
| 30 ReturnAutocompleteResult( | 35 ReturnAutocompleteResult( |
| 31 blink::WebFormElement::AutocompleteResultErrorDisabled, | 36 blink::WebFormElement::AutocompleteResultErrorDisabled, |
| 32 FormData()); | 37 FormData()); |
| 33 return; | 38 return; |
| 34 } | 39 } |
| 35 | 40 |
| 36 base::Callback<void(const FormStructure*)> callback = | 41 base::Callback<void(const FormStructure*)> callback = |
| 37 base::Bind(&RequestAutocompleteManager::ReturnAutocompleteData, | 42 base::Bind(&RequestAutocompleteManager::ReturnAutocompleteData, |
| 38 weak_ptr_factory_.GetWeakPtr()); | 43 weak_ptr_factory_.GetWeakPtr()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 void RequestAutocompleteManager::ShowRequestAutocompleteDialog( | 76 void RequestAutocompleteManager::ShowRequestAutocompleteDialog( |
| 72 const FormData& form, | 77 const FormData& form, |
| 73 const GURL& source_url, | 78 const GURL& source_url, |
| 74 const base::Callback<void(const FormStructure*)>& callback) { | 79 const base::Callback<void(const FormStructure*)>& callback) { |
| 75 AutofillManagerDelegate* delegate = | 80 AutofillManagerDelegate* delegate = |
| 76 autofill_driver_->autofill_manager()->delegate(); | 81 autofill_driver_->autofill_manager()->delegate(); |
| 77 delegate->ShowRequestAutocompleteDialog(form, source_url, callback); | 82 delegate->ShowRequestAutocompleteDialog(form, source_url, callback); |
| 78 } | 83 } |
| 79 | 84 |
| 80 } // namespace autofill | 85 } // namespace autofill |
| OLD | NEW |