1 // Copyright 2014 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_CONTENT_AUTOFILL_DRIVER_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/supports_user_data.h"
12 #include "components/autofill/content/browser/request_autocomplete_manager.h"
13 #include "components/autofill/core/browser/autofill_driver.h"
14 #include "components/autofill/core/browser/autofill_external_delegate.h"
15 #include "components/autofill/core/browser/autofill_manager.h"
19 class RenderFrameHost
;
20 struct FrameNavigateParams
;
21 struct LoadCommittedDetails
;
32 // Class that drives autofill flow in the browser process based on
33 // communication from the renderer and from the external world. There is one
34 // instance per RenderFrameHost.
35 class ContentAutofillDriver
: public AutofillDriver
{
37 ContentAutofillDriver(
38 content::RenderFrameHost
* render_frame_host
,
39 AutofillClient
* client
,
40 const std::string
& app_locale
,
41 AutofillManager::AutofillDownloadManagerState enable_download_manager
);
42 ~ContentAutofillDriver() override
;
45 bool IsOffTheRecord() const override
;
46 net::URLRequestContextGetter
* GetURLRequestContext() override
;
47 base::SequencedWorkerPool
* GetBlockingPool() override
;
48 bool RendererIsAvailable() override
;
49 void SendFormDataToRenderer(int query_id
,
50 RendererFormDataAction action
,
51 const FormData
& data
) override
;
52 void PingRenderer() override
;
53 void PropagateAutofillPredictions(
54 const std::vector
<autofill::FormStructure
*>& forms
) override
;
55 void SendAutofillTypePredictionsToRenderer(
56 const std::vector
<FormStructure
*>& forms
) override
;
57 void RendererShouldAcceptDataListSuggestion(
58 const base::string16
& value
) override
;
59 void RendererShouldClearFilledForm() override
;
60 void RendererShouldClearPreviewedForm() override
;
61 void RendererShouldFillFieldWithValue(const base::string16
& value
) override
;
62 void RendererShouldPreviewFieldWithValue(
63 const base::string16
& value
) override
;
64 void PopupHidden() override
;
66 // Handles a message that came from the associated render frame.
67 bool HandleMessage(const IPC::Message
& message
);
69 // Called when the frame has navigated.
70 void DidNavigateFrame(const content::LoadCommittedDetails
& details
,
71 const content::FrameNavigateParams
& params
);
73 AutofillExternalDelegate
* autofill_external_delegate() {
74 return &autofill_external_delegate_
;
77 AutofillManager
* autofill_manager() { return autofill_manager_
.get(); }
78 content::RenderFrameHost
* render_frame_host() { return render_frame_host_
; }
81 // Sets the manager to |manager| and sets |manager|'s external delegate
82 // to |autofill_external_delegate_|. Takes ownership of |manager|.
83 void SetAutofillManager(scoped_ptr
<AutofillManager
> manager
);
86 // Weak ref to the RenderFrameHost the driver is associated with. Should
87 // always be non-NULL and valid for lifetime of |this|.
88 content::RenderFrameHost
* const render_frame_host_
;
90 // The per-tab client.
91 AutofillClient
* client_
;
93 // AutofillManager instance via which this object drives the shared Autofill
95 scoped_ptr
<AutofillManager
> autofill_manager_
;
97 // AutofillExternalDelegate instance that this object instantiates in the
98 // case where the Autofill native UI is enabled.
99 AutofillExternalDelegate autofill_external_delegate_
;
101 // Driver for the interactive autocomplete dialog.
102 RequestAutocompleteManager request_autocomplete_manager_
;
105 } // namespace autofill
107 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_