| 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_client.h" | 10 #include "components/autofill/core/browser/autofill_client.h" |
| 11 | 11 |
| 12 class GURL; | 12 class GURL; |
| 13 | 13 |
| 14 namespace autofill { | 14 namespace autofill { |
| 15 | 15 |
| 16 class ContentAutofillDriver; | 16 class ContentAutofillDriver; |
| 17 struct FormData; | 17 struct FormData; |
| 18 class FormStructure; | 18 class FormStructure; |
| 19 | 19 |
| 20 // Driver for the requestAutocomplete flow. | 20 // Driver for the requestAutocomplete flow. |
| 21 class RequestAutocompleteManager { | 21 class RequestAutocompleteManager { |
| 22 public: | 22 public: |
| 23 explicit RequestAutocompleteManager(ContentAutofillDriver* autofill_driver); | 23 explicit RequestAutocompleteManager(ContentAutofillDriver* autofill_driver); |
| 24 ~RequestAutocompleteManager(); | 24 ~RequestAutocompleteManager(); |
| 25 | 25 |
| 26 // Requests an interactive autocomplete UI to be shown for |frame_url| with | 26 // Requests an interactive autocomplete UI to be shown for the associated |
| 27 // |form|. | 27 // frame. |
| 28 void OnRequestAutocomplete(const FormData& form, const GURL& frame_url); | 28 void OnRequestAutocomplete(const FormData& form); |
| 29 | |
| 30 // Requests that any running interactive autocomplete be cancelled. | |
| 31 void OnCancelRequestAutocomplete(); | |
| 32 | 29 |
| 33 private: | 30 private: |
| 34 // Tells the renderer that the current interactive autocomplete dialog | 31 // Tells the renderer that the current interactive autocomplete dialog |
| 35 // finished with the |result| saying if it was successful or not, and | 32 // finished with the |result| saying if it was successful or not, and |
| 36 // |form_structure| containing the filled form data. |debug_message| will | 33 // |form_structure| containing the filled form data. |debug_message| will |
| 37 // be printed to the developer console. | 34 // be printed to the developer console. |
| 38 void ReturnAutocompleteResult( | 35 void ReturnAutocompleteResult( |
| 39 AutofillClient::RequestAutocompleteResult result, | 36 AutofillClient::RequestAutocompleteResult result, |
| 40 const base::string16& debug_message, | 37 const base::string16& debug_message, |
| 41 const FormStructure* form_structure); | 38 const FormStructure* form_structure); |
| 42 | 39 |
| 43 // Shows the requestAutocomplete dialog for |source_url| with data from |form| | 40 // Shows the requestAutocomplete dialog for |source_url| with data from |form| |
| 44 // and calls |callback| once the interaction is complete. | 41 // and calls |callback| once the interaction is complete. |
| 45 void ShowRequestAutocompleteDialog( | 42 void ShowRequestAutocompleteDialog( |
| 46 const FormData& form, | 43 const FormData& form, |
| 47 const GURL& source_url, | |
| 48 const AutofillClient::ResultCallback& callback); | 44 const AutofillClient::ResultCallback& callback); |
| 49 | 45 |
| 50 // The autofill driver owns and outlives |this|. | 46 // The autofill driver owns and outlives |this|. |
| 51 ContentAutofillDriver* const autofill_driver_; // weak. | 47 ContentAutofillDriver* const autofill_driver_; // weak. |
| 52 | 48 |
| 53 base::WeakPtrFactory<RequestAutocompleteManager> weak_ptr_factory_; | 49 base::WeakPtrFactory<RequestAutocompleteManager> weak_ptr_factory_; |
| 54 }; | 50 }; |
| 55 | 51 |
| 56 } // namespace autofill | 52 } // namespace autofill |
| 57 | 53 |
| 58 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_ | 54 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_ |
| OLD | NEW |