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

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

Issue 2180093002: [Autofill] Switch on use_new_wrapper_types mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nit Created 4 years, 4 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 #include "components/autofill/content/browser/content_autofill_driver.h" 5 #include "components/autofill/content/browser/content_autofill_driver.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
11 #include "components/autofill/content/browser/content_autofill_driver_factory.h" 11 #include "components/autofill/content/browser/content_autofill_driver_factory.h"
12 #include "components/autofill/content/common/autofill_messages.h" 12 #include "components/autofill/content/common/autofill_messages.h"
13 #include "components/autofill/core/browser/autofill_client.h" 13 #include "components/autofill/core/browser/autofill_client.h"
14 #include "components/autofill/core/browser/autofill_external_delegate.h" 14 #include "components/autofill/core/browser/autofill_external_delegate.h"
15 #include "components/autofill/core/browser/autofill_manager.h" 15 #include "components/autofill/core/browser/autofill_manager.h"
16 #include "components/autofill/core/browser/form_structure.h" 16 #include "components/autofill/core/browser/form_structure.h"
17 #include "components/autofill/core/common/autofill_switches.h" 17 #include "components/autofill/core/common/autofill_switches.h"
18 #include "content/public/browser/browser_context.h" 18 #include "content/public/browser/browser_context.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
21 #include "content/public/browser/navigation_details.h" 21 #include "content/public/browser/navigation_details.h"
22 #include "content/public/browser/render_frame_host.h" 22 #include "content/public/browser/render_frame_host.h"
23 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
24 #include "content/public/browser/render_widget_host_view.h" 24 #include "content/public/browser/render_widget_host_view.h"
25 #include "content/public/browser/site_instance.h" 25 #include "content/public/browser/site_instance.h"
26 #include "content/public/browser/storage_partition.h" 26 #include "content/public/browser/storage_partition.h"
27 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
28 #include "mojo/common/common_type_converters.h"
29 #include "services/shell/public/cpp/interface_provider.h" 28 #include "services/shell/public/cpp/interface_provider.h"
30 #include "ui/gfx/geometry/size_f.h" 29 #include "ui/gfx/geometry/size_f.h"
31 30
32 namespace autofill { 31 namespace autofill {
33 32
34 ContentAutofillDriver::ContentAutofillDriver( 33 ContentAutofillDriver::ContentAutofillDriver(
35 content::RenderFrameHost* render_frame_host, 34 content::RenderFrameHost* render_frame_host,
36 AutofillClient* client, 35 AutofillClient* client,
37 const std::string& app_locale, 36 const std::string& app_locale,
38 AutofillManager::AutofillDownloadManagerState enable_download_manager) 37 AutofillManager::AutofillDownloadManagerState enable_download_manager)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 const std::vector<FormStructure*>& forms) { 108 const std::vector<FormStructure*>& forms) {
110 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 109 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
111 switches::kShowAutofillTypePredictions)) 110 switches::kShowAutofillTypePredictions))
112 return; 111 return;
113 112
114 if (!RendererIsAvailable()) 113 if (!RendererIsAvailable())
115 return; 114 return;
116 115
117 std::vector<FormDataPredictions> type_predictions = 116 std::vector<FormDataPredictions> type_predictions =
118 FormStructure::GetFieldTypePredictions(forms); 117 FormStructure::GetFieldTypePredictions(forms);
119 GetAutofillAgent()->FieldTypePredictionsAvailable( 118 GetAutofillAgent()->FieldTypePredictionsAvailable(type_predictions);
120 std::move(type_predictions));
121 } 119 }
122 120
123 void ContentAutofillDriver::RendererShouldAcceptDataListSuggestion( 121 void ContentAutofillDriver::RendererShouldAcceptDataListSuggestion(
124 const base::string16& value) { 122 const base::string16& value) {
125 if (!RendererIsAvailable()) 123 if (!RendererIsAvailable())
126 return; 124 return;
127 GetAutofillAgent()->AcceptDataListSuggestion(mojo::String::From(value)); 125 GetAutofillAgent()->AcceptDataListSuggestion(value);
128 } 126 }
129 127
130 void ContentAutofillDriver::RendererShouldClearFilledForm() { 128 void ContentAutofillDriver::RendererShouldClearFilledForm() {
131 if (!RendererIsAvailable()) 129 if (!RendererIsAvailable())
132 return; 130 return;
133 GetAutofillAgent()->ClearForm(); 131 GetAutofillAgent()->ClearForm();
134 } 132 }
135 133
136 void ContentAutofillDriver::RendererShouldClearPreviewedForm() { 134 void ContentAutofillDriver::RendererShouldClearPreviewedForm() {
137 if (!RendererIsAvailable()) 135 if (!RendererIsAvailable())
138 return; 136 return;
139 GetAutofillAgent()->ClearPreviewedForm(); 137 GetAutofillAgent()->ClearPreviewedForm();
140 } 138 }
141 139
142 void ContentAutofillDriver::RendererShouldFillFieldWithValue( 140 void ContentAutofillDriver::RendererShouldFillFieldWithValue(
143 const base::string16& value) { 141 const base::string16& value) {
144 if (!RendererIsAvailable()) 142 if (!RendererIsAvailable())
145 return; 143 return;
146 GetAutofillAgent()->FillFieldWithValue(mojo::String::From(value)); 144 GetAutofillAgent()->FillFieldWithValue(value);
147 } 145 }
148 146
149 void ContentAutofillDriver::RendererShouldPreviewFieldWithValue( 147 void ContentAutofillDriver::RendererShouldPreviewFieldWithValue(
150 const base::string16& value) { 148 const base::string16& value) {
151 if (!RendererIsAvailable()) 149 if (!RendererIsAvailable())
152 return; 150 return;
153 GetAutofillAgent()->PreviewFieldWithValue(mojo::String::From(value)); 151 GetAutofillAgent()->PreviewFieldWithValue(value);
154 } 152 }
155 153
156 void ContentAutofillDriver::PopupHidden() { 154 void ContentAutofillDriver::PopupHidden() {
157 // If the unmask prompt is showing, keep showing the preview. The preview 155 // If the unmask prompt is showing, keep showing the preview. The preview
158 // will be cleared when the prompt closes. 156 // will be cleared when the prompt closes.
159 if (!autofill_manager_->IsShowingUnmaskPrompt()) 157 if (!autofill_manager_->IsShowingUnmaskPrompt())
160 RendererShouldClearPreviewedForm(); 158 RendererShouldClearPreviewedForm();
161 } 159 }
162 160
163 gfx::RectF ContentAutofillDriver::TransformBoundingBoxToViewportCoordinates( 161 gfx::RectF ContentAutofillDriver::TransformBoundingBoxToViewportCoordinates(
164 const gfx::RectF& bounding_box) { 162 const gfx::RectF& bounding_box) {
165 gfx::Point orig_point(bounding_box.x(), bounding_box.y()); 163 gfx::Point orig_point(bounding_box.x(), bounding_box.y());
166 gfx::Point transformed_point; 164 gfx::Point transformed_point;
167 transformed_point = 165 transformed_point =
168 render_frame_host_->GetView()->TransformPointToRootCoordSpace(orig_point); 166 render_frame_host_->GetView()->TransformPointToRootCoordSpace(orig_point);
169 167
170 gfx::RectF new_box; 168 gfx::RectF new_box;
171 new_box.SetRect(transformed_point.x(), transformed_point.y(), 169 new_box.SetRect(transformed_point.x(), transformed_point.y(),
172 bounding_box.width(), bounding_box.height()); 170 bounding_box.width(), bounding_box.height());
173 return new_box; 171 return new_box;
174 } 172 }
175 173
176 // mojom::AutofillDriver: 174 // mojom::AutofillDriver:
177 void ContentAutofillDriver::FirstUserGestureObserved() { 175 void ContentAutofillDriver::FirstUserGestureObserved() {
178 client_->OnFirstUserGestureObserved(); 176 client_->OnFirstUserGestureObserved();
179 } 177 }
180 178
181 void ContentAutofillDriver::FormsSeen(mojo::Array<FormData> forms, 179 void ContentAutofillDriver::FormsSeen(const std::vector<FormData>& forms,
182 base::TimeTicks timestamp) { 180 base::TimeTicks timestamp) {
183 autofill_manager_->OnFormsSeen(forms.storage(), timestamp); 181 autofill_manager_->OnFormsSeen(forms, timestamp);
184 } 182 }
185 183
186 void ContentAutofillDriver::WillSubmitForm(const FormData& form, 184 void ContentAutofillDriver::WillSubmitForm(const FormData& form,
187 base::TimeTicks timestamp) { 185 base::TimeTicks timestamp) {
188 autofill_manager_->OnWillSubmitForm(form, timestamp); 186 autofill_manager_->OnWillSubmitForm(form, timestamp);
189 } 187 }
190 188
191 void ContentAutofillDriver::FormSubmitted(const FormData& form) { 189 void ContentAutofillDriver::FormSubmitted(const FormData& form) {
192 autofill_manager_->OnFormSubmitted(form); 190 autofill_manager_->OnFormSubmitted(form);
193 } 191 }
(...skipping 30 matching lines...) Expand all
224 } 222 }
225 223
226 void ContentAutofillDriver::DidPreviewAutofillFormData() { 224 void ContentAutofillDriver::DidPreviewAutofillFormData() {
227 autofill_manager_->OnDidPreviewAutofillFormData(); 225 autofill_manager_->OnDidPreviewAutofillFormData();
228 } 226 }
229 227
230 void ContentAutofillDriver::DidEndTextFieldEditing() { 228 void ContentAutofillDriver::DidEndTextFieldEditing() {
231 autofill_manager_->OnDidEndTextFieldEditing(); 229 autofill_manager_->OnDidEndTextFieldEditing();
232 } 230 }
233 231
234 void ContentAutofillDriver::SetDataList(mojo::Array<mojo::String> values, 232 void ContentAutofillDriver::SetDataList(
235 mojo::Array<mojo::String> labels) { 233 const std::vector<base::string16>& values,
236 autofill_manager_->OnSetDataList(values.To<std::vector<base::string16>>(), 234 const std::vector<base::string16>& labels) {
237 labels.To<std::vector<base::string16>>()); 235 autofill_manager_->OnSetDataList(values, labels);
238 } 236 }
239 237
240 void ContentAutofillDriver::DidNavigateFrame( 238 void ContentAutofillDriver::DidNavigateFrame(
241 const content::LoadCommittedDetails& details, 239 const content::LoadCommittedDetails& details,
242 const content::FrameNavigateParams& params) { 240 const content::FrameNavigateParams& params) {
243 if (details.is_navigation_to_different_page()) 241 if (details.is_navigation_to_different_page())
244 autofill_manager_->Reset(); 242 autofill_manager_->Reset();
245 } 243 }
246 244
247 void ContentAutofillDriver::SetAutofillManager( 245 void ContentAutofillDriver::SetAutofillManager(
(...skipping 10 matching lines...) Expand all
258 // Here is a lazy binding, and will not reconnect after connection error. 256 // Here is a lazy binding, and will not reconnect after connection error.
259 if (!mojo_autofill_agent_) { 257 if (!mojo_autofill_agent_) {
260 render_frame_host_->GetRemoteInterfaces()->GetInterface( 258 render_frame_host_->GetRemoteInterfaces()->GetInterface(
261 mojo::GetProxy(&mojo_autofill_agent_)); 259 mojo::GetProxy(&mojo_autofill_agent_));
262 } 260 }
263 261
264 return mojo_autofill_agent_; 262 return mojo_autofill_agent_;
265 } 263 }
266 264
267 } // namespace autofill 265 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698