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

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

Issue 1012853002: [Password Manager] Use successful XHR submission as a signal for password saving (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 9 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
« no previous file with comments | « components/autofill/content/renderer/password_autofill_agent.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_autofill_agent.h" 5 #include "components/autofill/content/renderer/password_autofill_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 852
853 bool PasswordAutofillAgent::OriginCanAccessPasswordManager( 853 bool PasswordAutofillAgent::OriginCanAccessPasswordManager(
854 const blink::WebSecurityOrigin& origin) { 854 const blink::WebSecurityOrigin& origin) {
855 return origin.canAccessPasswordManager(); 855 return origin.canAccessPasswordManager();
856 } 856 }
857 857
858 void PasswordAutofillAgent::OnDynamicFormsSeen() { 858 void PasswordAutofillAgent::OnDynamicFormsSeen() {
859 SendPasswordForms(false /* only_visible */); 859 SendPasswordForms(false /* only_visible */);
860 } 860 }
861 861
862 void PasswordAutofillAgent::XHRSucceeded() {
863 // If the user hasn't fully filled out the form, don't try to save.
vabr (Chromium) 2015/03/17 10:14:38 optional nit: To me, the comment duplicates what t
Garrett Casto 2015/03/17 21:36:15 I'm pretty indifferent. If you don't feel that it
864 if (!ProvisionallySavedPasswordIsValid())
865 return;
866
867 // Prompt to save only if the form is now gone, either invisible or
868 // removed from the DOM.
869 blink::WebFrame* frame = render_frame()->GetWebFrame();
870 blink::WebVector<blink::WebFormElement> forms;
871 frame->document().forms(forms);
872
873 for (size_t i = 0; i < forms.size(); ++i) {
874 const blink::WebFormElement& form = forms[i];
875 bool is_form_visible = IsWebNodeVisible(form);
876
877 if (!is_form_visible) {
vabr (Chromium) 2015/03/17 10:14:38 Why not replace the bool directly with the call to
Garrett Casto 2015/03/17 21:36:15 Copy and paste issue. Fixed.
878 continue;
879 }
880
881 scoped_ptr<PasswordForm> password_form(
882 CreatePasswordForm(form, &nonscript_modified_values_));
883 if (password_form.get()) {
884 if (provisionally_saved_form_->action == password_form->action) {
885 // Form still exists, no save required.
886 return;
887 }
888 }
889 }
890 Send(new AutofillHostMsg_InPageNavigation(routing_id(),
891 *provisionally_saved_form_));
892 provisionally_saved_form_.reset();
893 }
894
862 void PasswordAutofillAgent::FirstUserGestureObserved() { 895 void PasswordAutofillAgent::FirstUserGestureObserved() {
863 gatekeeper_.OnUserGesture(); 896 gatekeeper_.OnUserGesture();
864 } 897 }
865 898
866 void PasswordAutofillAgent::SendPasswordForms(bool only_visible) { 899 void PasswordAutofillAgent::SendPasswordForms(bool only_visible) {
867 scoped_ptr<RendererSavePasswordProgressLogger> logger; 900 scoped_ptr<RendererSavePasswordProgressLogger> logger;
868 if (logging_state_active_) { 901 if (logging_state_active_) {
869 logger.reset(new RendererSavePasswordProgressLogger(this, routing_id())); 902 logger.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
870 logger->LogMessage(Logger::STRING_SEND_PASSWORD_FORMS_METHOD); 903 logger->LogMessage(Logger::STRING_SEND_PASSWORD_FORMS_METHOD);
871 logger->LogBoolean(Logger::STRING_ONLY_VISIBLE, only_visible); 904 logger->LogBoolean(Logger::STRING_ONLY_VISIBLE, only_visible);
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 scoped_ptr<PasswordForm> password_form( 1391 scoped_ptr<PasswordForm> password_form(
1359 CreatePasswordForm(form, &nonscript_modified_values_)); 1392 CreatePasswordForm(form, &nonscript_modified_values_));
1360 if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD && 1393 if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD &&
1361 password_form->password_value.empty() && 1394 password_form->password_value.empty() &&
1362 password_form->new_password_value.empty())) { 1395 password_form->new_password_value.empty())) {
1363 return; 1396 return;
1364 } 1397 }
1365 provisionally_saved_form_ = password_form.Pass(); 1398 provisionally_saved_form_ = password_form.Pass();
1366 } 1399 }
1367 1400
1401 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() {
1402 return provisionally_saved_form_ &&
1403 !provisionally_saved_form_->username_value.empty() &&
1404 (!provisionally_saved_form_->password_value.empty() ||
vabr (Chromium) 2015/03/17 10:14:38 Did you mean to apply the negation to the whole di
Garrett Casto 2015/03/17 21:36:15 Yikes. Nice catch. Added additional tests to verif
1405 provisionally_saved_form_->new_password_value.empty());
1406 }
1407
1368 // LegacyPasswordAutofillAgent ------------------------------------------------- 1408 // LegacyPasswordAutofillAgent -------------------------------------------------
1369 1409
1370 PasswordAutofillAgent::LegacyPasswordAutofillAgent::LegacyPasswordAutofillAgent( 1410 PasswordAutofillAgent::LegacyPasswordAutofillAgent::LegacyPasswordAutofillAgent(
1371 content::RenderView* render_view, 1411 content::RenderView* render_view,
1372 PasswordAutofillAgent* agent) 1412 PasswordAutofillAgent* agent)
1373 : content::RenderViewObserver(render_view), agent_(agent) { 1413 : content::RenderViewObserver(render_view), agent_(agent) {
1374 } 1414 }
1375 1415
1376 PasswordAutofillAgent::LegacyPasswordAutofillAgent:: 1416 PasswordAutofillAgent::LegacyPasswordAutofillAgent::
1377 ~LegacyPasswordAutofillAgent() { 1417 ~LegacyPasswordAutofillAgent() {
(...skipping 10 matching lines...) Expand all
1388 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { 1428 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() {
1389 agent_->DidStopLoading(); 1429 agent_->DidStopLoading();
1390 } 1430 }
1391 1431
1392 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: 1432 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::
1393 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { 1433 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) {
1394 agent_->LegacyDidStartProvisionalLoad(navigated_frame); 1434 agent_->LegacyDidStartProvisionalLoad(navigated_frame);
1395 } 1435 }
1396 1436
1397 } // namespace autofill 1437 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/renderer/password_autofill_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698