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"
16 #include "content/public/browser/web_contents_observer.h"
30 // Class that drives autofill flow in the browser process based on
31 // communication from the renderer and from the external world. There is one
32 // instance per WebContents.
33 class ContentAutofillDriver
: public AutofillDriver
,
34 public content::WebContentsObserver
,
35 public base::SupportsUserData::Data
{
37 static void CreateForWebContentsAndDelegate(
38 content::WebContents
* contents
,
39 AutofillClient
* client
,
40 const std::string
& app_locale
,
41 AutofillManager::AutofillDownloadManagerState enable_download_manager
);
42 static ContentAutofillDriver
* FromWebContents(content::WebContents
* contents
);
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 SendAutofillTypePredictionsToRenderer(
54 const std::vector
<FormStructure
*>& forms
) override
;
55 void RendererShouldAcceptDataListSuggestion(
56 const base::string16
& value
) override
;
57 void RendererShouldClearFilledForm() override
;
58 void RendererShouldClearPreviewedForm() override
;
59 void RendererShouldFillFieldWithValue(const base::string16
& value
) override
;
60 void RendererShouldPreviewFieldWithValue(
61 const base::string16
& value
) override
;
63 AutofillExternalDelegate
* autofill_external_delegate() {
64 return &autofill_external_delegate_
;
67 AutofillManager
* autofill_manager() { return autofill_manager_
.get(); }
70 ContentAutofillDriver(
71 content::WebContents
* web_contents
,
72 AutofillClient
* client
,
73 const std::string
& app_locale
,
74 AutofillManager::AutofillDownloadManagerState enable_download_manager
);
75 ~ContentAutofillDriver() override
;
77 // content::WebContentsObserver:
78 void DidNavigateMainFrame(
79 const content::LoadCommittedDetails
& details
,
80 const content::FrameNavigateParams
& params
) override
;
81 void NavigationEntryCommitted(
82 const content::LoadCommittedDetails
& load_details
) override
;
83 void WasHidden() override
;
84 bool OnMessageReceived(const IPC::Message
& message
) override
;
86 // Sets the manager to |manager| and sets |manager|'s external delegate
87 // to |autofill_external_delegate_|. Takes ownership of |manager|.
88 void SetAutofillManager(scoped_ptr
<AutofillManager
> manager
);
91 // AutofillManager instance via which this object drives the shared Autofill
93 scoped_ptr
<AutofillManager
> autofill_manager_
;
95 // AutofillExternalDelegate instance that this object instantiates in the
96 // case where the Autofill native UI is enabled.
97 AutofillExternalDelegate autofill_external_delegate_
;
99 // Driver for the interactive autocomplete dialog.
100 RequestAutocompleteManager request_autocomplete_manager_
;
103 } // namespace autofill
105 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_