| 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 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_ |
| 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "components/autofill/core/browser/autofill_manager_delegate.h" |
| 10 #include "third_party/WebKit/public/web/WebFormElement.h" | 11 #include "third_party/WebKit/public/web/WebFormElement.h" |
| 11 | 12 |
| 12 class GURL; | 13 class GURL; |
| 13 | 14 |
| 14 namespace autofill { | 15 namespace autofill { |
| 15 | 16 |
| 16 class ContentAutofillDriver; | 17 class ContentAutofillDriver; |
| 17 struct FormData; | 18 struct FormData; |
| 18 class FormStructure; | 19 class FormStructure; |
| 19 | 20 |
| 20 // Driver for the requestAutocomplete flow. | 21 // Driver for the requestAutocomplete flow. |
| 21 class RequestAutocompleteManager { | 22 class RequestAutocompleteManager { |
| 22 public: | 23 public: |
| 23 explicit RequestAutocompleteManager(ContentAutofillDriver* autofill_driver); | 24 explicit RequestAutocompleteManager(ContentAutofillDriver* autofill_driver); |
| 24 ~RequestAutocompleteManager(); | 25 ~RequestAutocompleteManager(); |
| 25 | 26 |
| 26 // Requests an interactive autocomplete UI to be shown for |frame_url| with | 27 // Requests an interactive autocomplete UI to be shown for |frame_url| with |
| 27 // |form|. | 28 // |form|. |
| 28 void OnRequestAutocomplete(const FormData& form, const GURL& frame_url); | 29 void OnRequestAutocomplete(const FormData& form, const GURL& frame_url); |
| 29 | 30 |
| 30 // Requests that any running interactive autocomplete be cancelled. | 31 // Requests that any running interactive autocomplete be cancelled. |
| 31 void OnCancelRequestAutocomplete(); | 32 void OnCancelRequestAutocomplete(); |
| 32 | 33 |
| 33 private: | 34 private: |
| 35 // FIXME |
| 34 // Tells the renderer that the current interactive autocomplete dialog | 36 // Tells the renderer that the current interactive autocomplete dialog |
| 35 // finished with the |result| saying if it was successfull or not, and | 37 // finished with the |result| saying if it was successfull or not, and |
| 36 // |form_data| containing the filled form data. | 38 // |form_data| containing the filled form data. |
| 37 void ReturnAutocompleteResult( | 39 void ReturnAutocompleteResult( |
| 38 blink::WebFormElement::AutocompleteResult result, | 40 blink::WebFormElement::AutocompleteResult result, |
| 39 const FormData& form_data); | 41 const FormStructure* form_structure); |
| 40 | 42 |
| 41 // Shows the requestAutocomplete dialog for |source_url| with data from |form| | 43 // Shows the requestAutocomplete dialog for |source_url| with data from |form| |
| 42 // and calls |callback| once the interaction is complete. | 44 // and calls |callback| once the interaction is complete. |
| 43 void ShowRequestAutocompleteDialog( | 45 void ShowRequestAutocompleteDialog( |
| 44 const FormData& form, | 46 const FormData& form, |
| 45 const GURL& source_url, | 47 const GURL& source_url, |
| 46 const base::Callback<void(const FormStructure*)>& callback); | 48 const AutofillManagerDelegate::ResultCallback& callback); |
| 47 | |
| 48 // If |result| is not null, derives a FormData object from it and passes it | |
| 49 // back to the page along an |AutocompleteResultSuccess| result. Otherwise, it | |
| 50 // passes to the page an empty FormData along an | |
| 51 // |AutocompleteResultErrorCancel| result. | |
| 52 void ReturnAutocompleteData(const FormStructure* result); | |
| 53 | 49 |
| 54 // The autofill driver owns and outlives |this|. | 50 // The autofill driver owns and outlives |this|. |
| 55 ContentAutofillDriver* const autofill_driver_; // weak. | 51 ContentAutofillDriver* const autofill_driver_; // weak. |
| 56 | 52 |
| 57 base::WeakPtrFactory<RequestAutocompleteManager> weak_ptr_factory_; | 53 base::WeakPtrFactory<RequestAutocompleteManager> weak_ptr_factory_; |
| 58 }; | 54 }; |
| 59 | 55 |
| 60 } // namespace autofill | 56 } // namespace autofill |
| 61 | 57 |
| 62 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_ | 58 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_ |
| OLD | NEW |