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

Side by Side Diff: components/autofill/content/renderer/password_generation_agent.cc

Issue 2055633003: [Password Generation] Sends form classifier vote to autofill server (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pg_form_classification
Patch Set: replaced " DCHECK(client_->IsSavingAndFillingEnabledForCurrentPage()) Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 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 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/renderer/password_generation_agent.h" 5 #include "components/autofill/content/renderer/password_generation_agent.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "components/autofill/content/common/autofill_messages.h" 11 #include "components/autofill/content/common/autofill_messages.h"
12 #include "components/autofill/content/renderer/form_autofill_util.h" 12 #include "components/autofill/content/renderer/form_autofill_util.h"
13 #include "components/autofill/content/renderer/form_classifier.h"
13 #include "components/autofill/content/renderer/password_autofill_agent.h" 14 #include "components/autofill/content/renderer/password_autofill_agent.h"
14 #include "components/autofill/content/renderer/password_form_conversion_utils.h" 15 #include "components/autofill/content/renderer/password_form_conversion_utils.h"
15 #include "components/autofill/core/common/autofill_switches.h" 16 #include "components/autofill/core/common/autofill_switches.h"
16 #include "components/autofill/core/common/form_data.h" 17 #include "components/autofill/core/common/form_data.h"
17 #include "components/autofill/core/common/password_form.h" 18 #include "components/autofill/core/common/password_form.h"
18 #include "components/autofill/core/common/password_form_generation_data.h" 19 #include "components/autofill/core/common/password_form_generation_data.h"
19 #include "components/autofill/core/common/password_generation_util.h" 20 #include "components/autofill/core/common/password_generation_util.h"
20 #include "content/public/renderer/render_frame.h" 21 #include "content/public/renderer/render_frame.h"
21 #include "content/public/renderer/render_view.h" 22 #include "content/public/renderer/render_view.h"
22 #include "google_apis/gaia/gaia_urls.h" 23 #include "google_apis/gaia/gaia_urls.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 188 }
188 189
189 void PasswordGenerationAgent::OnDestruct() { 190 void PasswordGenerationAgent::OnDestruct() {
190 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 191 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
191 } 192 }
192 193
193 void PasswordGenerationAgent::OnDynamicFormsSeen() { 194 void PasswordGenerationAgent::OnDynamicFormsSeen() {
194 FindPossibleGenerationForm(); 195 FindPossibleGenerationForm();
195 } 196 }
196 197
198 void PasswordGenerationAgent::RunFormClassifierAndSaveVote(
199 const blink::WebFormElement& web_form,
200 const PasswordForm& form) {
201 base::string16 generation_field;
202 ClassifyFormAndFindGenerationField(web_form, &generation_field);
203 Send(new AutofillHostMsg_SaveGenerationFieldDetectedByClassifier(
204 routing_id(), form, generation_field));
205 }
206
197 void PasswordGenerationAgent::FindPossibleGenerationForm() { 207 void PasswordGenerationAgent::FindPossibleGenerationForm() {
198 if (!enabled_ || !render_frame()) 208 if (!enabled_ || !render_frame())
199 return; 209 return;
200 210
201 // We don't want to generate passwords if the browser won't store or sync 211 // We don't want to generate passwords if the browser won't store or sync
202 // them. 212 // them.
203 if (!ShouldAnalyzeDocument()) 213 if (!ShouldAnalyzeDocument())
204 return; 214 return;
205 215
206 // If we have already found a signup form for this page, no need to continue. 216 // If we have already found a signup form for this page, no need to continue.
(...skipping 18 matching lines...) Expand all
225 // Do not generate password for GAIA since it is used to retrieve the 235 // Do not generate password for GAIA since it is used to retrieve the
226 // generated paswords. 236 // generated paswords.
227 GURL realm(password_form->signon_realm); 237 GURL realm(password_form->signon_realm);
228 if (realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) 238 if (realm == GaiaUrls::GetInstance()->gaia_login_form_realm())
229 continue; 239 continue;
230 240
231 std::vector<blink::WebInputElement> passwords; 241 std::vector<blink::WebInputElement> passwords;
232 if (GetAccountCreationPasswordFields( 242 if (GetAccountCreationPasswordFields(
233 form_util::ExtractAutofillableElementsInForm(forms[i]), 243 form_util::ExtractAutofillableElementsInForm(forms[i]),
234 &passwords)) { 244 &passwords)) {
245 RunFormClassifierAndSaveVote(forms[i], *password_form);
235 AccountCreationFormData ac_form_data( 246 AccountCreationFormData ac_form_data(
236 make_linked_ptr(password_form.release()), passwords); 247 make_linked_ptr(password_form.release()), passwords);
237 possible_account_creation_forms_.push_back(ac_form_data); 248 possible_account_creation_forms_.push_back(ac_form_data);
238 } 249 }
239 } 250 }
240 251
241 if (!possible_account_creation_forms_.empty()) { 252 if (!possible_account_creation_forms_.empty()) {
242 VLOG(2) << possible_account_creation_forms_.size() 253 VLOG(2) << possible_account_creation_forms_.size()
243 << " possible account creation forms deteceted"; 254 << " possible account creation forms deteceted";
244 DetermineGenerationElement(); 255 DetermineGenerationElement();
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 GetAccountCreationPasswordFields(control_elements, &password_elements); 565 GetAccountCreationPasswordFields(control_elements, &password_elements);
555 password_elements = FindPasswordElementsForGeneration( 566 password_elements = FindPasswordElementsForGeneration(
556 password_elements, last_focused_password_element_.nameForAutofill()); 567 password_elements, last_focused_password_element_.nameForAutofill());
557 generation_form_data_.reset(new AccountCreationFormData( 568 generation_form_data_.reset(new AccountCreationFormData(
558 make_linked_ptr(password_form.release()), password_elements)); 569 make_linked_ptr(password_form.release()), password_elements));
559 is_manually_triggered_ = true; 570 is_manually_triggered_ = true;
560 ShowGenerationPopup(); 571 ShowGenerationPopup();
561 } 572 }
562 573
563 } // namespace autofill 574 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698