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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_
8 #include "base/callback_forward.h"
9 #include "base/memory/weak_ptr.h"
10 #include "third_party/WebKit/public/web/WebFormElement.h"
16 class AutofillDriverImpl;
20 // Driver for the requestAutocomplete flow.
21 class RequestAutocompleteManager {
23 explicit RequestAutocompleteManager(AutofillDriverImpl* autofill_driver);
24 ~RequestAutocompleteManager();
26 // Requests an interactive autocomplete UI to be shown for |frame_url| with
28 void OnRequestAutocomplete(const FormData& form, const GURL& frame_url);
31 // Tells the renderer that the current interactive autocomplete dialog
32 // finished with the |result| saying if it was successfull or not, and
33 // |form_data| containing the filled form data.
34 void ReturnAutocompleteResult(
35 blink::WebFormElement::AutocompleteResult result,
36 const FormData& form_data);
38 // Shows the requestAutocomplete dialog for |source_url| with data from |form|
39 // and calls |callback| once the interaction is complete.
40 void ShowRequestAutocompleteDialog(
42 const GURL& source_url,
43 const base::Callback<void(const FormStructure*)>& callback);
45 // If |result| is not null, derives a FormData object from it and passes it
46 // back to the page along an |AutocompleteResultSuccess| result. Otherwise, it
47 // passes to the page an empty FormData along an
48 // |AutocompleteResultErrorCancel| result.
49 void ReturnAutocompleteData(const FormStructure* result);
51 // The autofill driver owns and outlives |this|.
52 AutofillDriverImpl* const autofill_driver_; // weak.
54 base::WeakPtrFactory<RequestAutocompleteManager> weak_ptr_factory_;
57 } // namespace autofill
59 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_REQUEST_AUTOCOMPLETE_MANAGER_H_