Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: components/autofill/content/browser/content_autofill_driver.h

Issue 2007473004: [Autofill] Migrate ContentAutofillDriver<-->AutofillAgent IPCs to mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize remote_interfaces_ in Init() Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_CONTENT_AUTOFILL_DRIVER_H_ 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/supports_user_data.h" 11 #include "base/supports_user_data.h"
12 #include "components/autofill/content/public/interfaces/autofill_agent.mojom.h" 12 #include "components/autofill/content/public/interfaces/autofill_agent.mojom.h"
13 #include "components/autofill/content/public/interfaces/autofill_driver.mojom.h" 13 #include "components/autofill/content/public/interfaces/autofill_driver.mojom.h"
14 #include "components/autofill/core/browser/autofill_driver.h" 14 #include "components/autofill/core/browser/autofill_driver.h"
15 #include "components/autofill/core/browser/autofill_external_delegate.h" 15 #include "components/autofill/core/browser/autofill_external_delegate.h"
16 #include "components/autofill/core/browser/autofill_manager.h" 16 #include "components/autofill/core/browser/autofill_manager.h"
17 #include "mojo/public/cpp/bindings/binding_set.h" 17 #include "mojo/public/cpp/bindings/binding.h"
18 18
19 namespace content { 19 namespace content {
20 class BrowserContext; 20 class BrowserContext;
21 class RenderFrameHost; 21 class RenderFrameHost;
22 struct FrameNavigateParams; 22 struct FrameNavigateParams;
23 struct LoadCommittedDetails; 23 struct LoadCommittedDetails;
24 } 24 }
25 25
26 namespace IPC {
27 class Message;
28 }
29
30 namespace autofill { 26 namespace autofill {
31 27
32 class AutofillClient; 28 class AutofillClient;
33 29
34 // Class that drives autofill flow in the browser process based on 30 // Class that drives autofill flow in the browser process based on
35 // communication from the renderer and from the external world. There is one 31 // communication from the renderer and from the external world. There is one
36 // instance per RenderFrameHost. 32 // instance per RenderFrameHost.
37 class ContentAutofillDriver : public AutofillDriver, 33 class ContentAutofillDriver : public AutofillDriver,
38 public mojom::AutofillDriver { 34 public mojom::AutofillDriver {
39 public: 35 public:
40 ContentAutofillDriver( 36 ContentAutofillDriver(
41 content::RenderFrameHost* render_frame_host, 37 content::RenderFrameHost* render_frame_host,
42 AutofillClient* client, 38 AutofillClient* client,
43 const std::string& app_locale, 39 const std::string& app_locale,
44 AutofillManager::AutofillDownloadManagerState enable_download_manager); 40 AutofillManager::AutofillDownloadManagerState enable_download_manager);
45 ~ContentAutofillDriver() override; 41 ~ContentAutofillDriver() override;
46 42
43 // Gets the driver for |render_frame_host|.
44 static ContentAutofillDriver* GetForRenderFrameHost(
45 content::RenderFrameHost* render_frame_host);
46
47 void BindRequest(mojom::AutofillDriverRequest request); 47 void BindRequest(mojom::AutofillDriverRequest request);
48 48
49 // AutofillDriver: 49 // AutofillDriver:
50 bool IsOffTheRecord() const override; 50 bool IsOffTheRecord() const override;
51 net::URLRequestContextGetter* GetURLRequestContext() override; 51 net::URLRequestContextGetter* GetURLRequestContext() override;
52 base::SequencedWorkerPool* GetBlockingPool() override; 52 base::SequencedWorkerPool* GetBlockingPool() override;
53 bool RendererIsAvailable() override; 53 bool RendererIsAvailable() override;
54 void SendFormDataToRenderer(int query_id, 54 void SendFormDataToRenderer(int query_id,
55 RendererFormDataAction action, 55 RendererFormDataAction action,
56 const FormData& data) override; 56 const FormData& data) override;
57 void PropagateAutofillPredictions( 57 void PropagateAutofillPredictions(
58 const std::vector<autofill::FormStructure*>& forms) override; 58 const std::vector<autofill::FormStructure*>& forms) override;
59 void SendAutofillTypePredictionsToRenderer( 59 void SendAutofillTypePredictionsToRenderer(
60 const std::vector<FormStructure*>& forms) override; 60 const std::vector<FormStructure*>& forms) override;
61 void RendererShouldAcceptDataListSuggestion( 61 void RendererShouldAcceptDataListSuggestion(
62 const base::string16& value) override; 62 const base::string16& value) override;
63 void RendererShouldClearFilledForm() override; 63 void RendererShouldClearFilledForm() override;
64 void RendererShouldClearPreviewedForm() override; 64 void RendererShouldClearPreviewedForm() override;
65 void RendererShouldFillFieldWithValue(const base::string16& value) override; 65 void RendererShouldFillFieldWithValue(const base::string16& value) override;
66 void RendererShouldPreviewFieldWithValue( 66 void RendererShouldPreviewFieldWithValue(
67 const base::string16& value) override; 67 const base::string16& value) override;
68 void PopupHidden() override; 68 void PopupHidden() override;
69 gfx::RectF TransformBoundingBoxToViewportCoordinates( 69 gfx::RectF TransformBoundingBoxToViewportCoordinates(
70 const gfx::RectF& bounding_box) override; 70 const gfx::RectF& bounding_box) override;
71 71
72 // mojom::AutofillDriver: 72 // mojom::AutofillDriver:
73 void FirstUserGestureObserved() override; 73 void FirstUserGestureObserved() override;
74 74 void FormsSeen(mojo::Array<FormData> forms,
75 // Handles a message that came from the associated render frame. 75 base::TimeTicks timestamp) override;
76 bool HandleMessage(const IPC::Message& message); 76 void WillSubmitForm(const FormData& form, base::TimeTicks timestamp) override;
77 void FormSubmitted(const FormData& form) override;
78 void TextFieldDidChange(const FormData& form,
79 const FormFieldData& field,
80 base::TimeTicks timestamp) override;
81 void QueryFormFieldAutofill(int32_t id,
82 const FormData& form,
83 const FormFieldData& field,
84 const gfx::RectF& bounding_box) override;
85 void HidePopup() override;
86 void PingAck() override;
87 void FocusNoLongerOnForm() override;
88 void DidFillAutofillFormData(const FormData& form,
89 base::TimeTicks timestamp) override;
90 void DidPreviewAutofillFormData() override;
91 void DidEndTextFieldEditing() override;
92 void SetDataList(mojo::Array<mojo::String> values,
93 mojo::Array<mojo::String> labels) override;
77 94
78 // Called when the frame has navigated. 95 // Called when the frame has navigated.
79 void DidNavigateFrame(const content::LoadCommittedDetails& details, 96 void DidNavigateFrame(const content::LoadCommittedDetails& details,
80 const content::FrameNavigateParams& params); 97 const content::FrameNavigateParams& params);
81 98
82 // Tells the render frame that a user gesture was observed 99 // Tells the render frame that a user gesture was observed
83 // somewhere in the tab (including in a different frame). 100 // somewhere in the tab (including in a different frame).
84 void NotifyFirstUserGestureObservedInTab(); 101 void NotifyFirstUserGestureObservedInTab();
85 102
86 AutofillExternalDelegate* autofill_external_delegate() { 103 AutofillExternalDelegate* autofill_external_delegate() {
87 return &autofill_external_delegate_; 104 return &autofill_external_delegate_;
88 } 105 }
89 106
90 AutofillManager* autofill_manager() { return autofill_manager_.get(); } 107 AutofillManager* autofill_manager() { return autofill_manager_.get(); }
91 content::RenderFrameHost* render_frame_host() { return render_frame_host_; } 108 content::RenderFrameHost* render_frame_host() { return render_frame_host_; }
92 109
110 const mojom::AutofillAgentPtr& GetAutofillAgent();
111
93 protected: 112 protected:
94 // Sets the manager to |manager| and sets |manager|'s external delegate 113 // Sets the manager to |manager| and sets |manager|'s external delegate
95 // to |autofill_external_delegate_|. Takes ownership of |manager|. 114 // to |autofill_external_delegate_|. Takes ownership of |manager|.
96 void SetAutofillManager(std::unique_ptr<AutofillManager> manager); 115 void SetAutofillManager(std::unique_ptr<AutofillManager> manager);
97 116
98 private: 117 private:
99 void ConnectToMojoAutofillAgentIfNeeded();
100
101 // Weak ref to the RenderFrameHost the driver is associated with. Should 118 // Weak ref to the RenderFrameHost the driver is associated with. Should
102 // always be non-NULL and valid for lifetime of |this|. 119 // always be non-NULL and valid for lifetime of |this|.
103 content::RenderFrameHost* const render_frame_host_; 120 content::RenderFrameHost* const render_frame_host_;
104 121
105 // The per-tab client. 122 // The per-tab client.
106 AutofillClient* client_; 123 AutofillClient* client_;
107 124
108 // AutofillManager instance via which this object drives the shared Autofill 125 // AutofillManager instance via which this object drives the shared Autofill
109 // code. 126 // code.
110 std::unique_ptr<AutofillManager> autofill_manager_; 127 std::unique_ptr<AutofillManager> autofill_manager_;
111 128
112 // AutofillExternalDelegate instance that this object instantiates in the 129 // AutofillExternalDelegate instance that this object instantiates in the
113 // case where the Autofill native UI is enabled. 130 // case where the Autofill native UI is enabled.
114 AutofillExternalDelegate autofill_external_delegate_; 131 AutofillExternalDelegate autofill_external_delegate_;
115 132
116 mojo::BindingSet<mojom::AutofillDriver> bindings_; 133 mojo::Binding<mojom::AutofillDriver> binding_;
117 134
118 mojom::AutofillAgentPtr mojo_autofill_agent_; 135 mojom::AutofillAgentPtr mojo_autofill_agent_;
119 }; 136 };
120 137
121 } // namespace autofill 138 } // namespace autofill
122 139
123 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ 140 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698