| OLD | NEW | 
|---|
| 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  Loading... | 
| 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 (!ProvisionallySavedPasswordIsValid()) | 
|  | 864     return; | 
|  | 865 | 
|  | 866   // Prompt to save only if the form is now gone, either invisible or | 
|  | 867   // removed from the DOM. | 
|  | 868   blink::WebFrame* frame = render_frame()->GetWebFrame(); | 
|  | 869   blink::WebVector<blink::WebFormElement> forms; | 
|  | 870   frame->document().forms(forms); | 
|  | 871 | 
|  | 872   for (size_t i = 0; i < forms.size(); ++i) { | 
|  | 873     const blink::WebFormElement& form = forms[i]; | 
|  | 874     if (!IsWebNodeVisible(form)) { | 
|  | 875       continue; | 
|  | 876     } | 
|  | 877 | 
|  | 878     scoped_ptr<PasswordForm> password_form( | 
|  | 879         CreatePasswordForm(form, &nonscript_modified_values_)); | 
|  | 880     if (password_form.get()) { | 
|  | 881       if (provisionally_saved_form_->action == password_form->action) { | 
|  | 882         // Form still exists, no save required. | 
|  | 883         return; | 
|  | 884       } | 
|  | 885     } | 
|  | 886   } | 
|  | 887   Send(new AutofillHostMsg_InPageNavigation(routing_id(), | 
|  | 888                                             *provisionally_saved_form_)); | 
|  | 889   provisionally_saved_form_.reset(); | 
|  | 890 } | 
|  | 891 | 
| 862 void PasswordAutofillAgent::FirstUserGestureObserved() { | 892 void PasswordAutofillAgent::FirstUserGestureObserved() { | 
| 863   gatekeeper_.OnUserGesture(); | 893   gatekeeper_.OnUserGesture(); | 
| 864 } | 894 } | 
| 865 | 895 | 
| 866 void PasswordAutofillAgent::SendPasswordForms(bool only_visible) { | 896 void PasswordAutofillAgent::SendPasswordForms(bool only_visible) { | 
| 867   scoped_ptr<RendererSavePasswordProgressLogger> logger; | 897   scoped_ptr<RendererSavePasswordProgressLogger> logger; | 
| 868   if (logging_state_active_) { | 898   if (logging_state_active_) { | 
| 869     logger.reset(new RendererSavePasswordProgressLogger(this, routing_id())); | 899     logger.reset(new RendererSavePasswordProgressLogger(this, routing_id())); | 
| 870     logger->LogMessage(Logger::STRING_SEND_PASSWORD_FORMS_METHOD); | 900     logger->LogMessage(Logger::STRING_SEND_PASSWORD_FORMS_METHOD); | 
| 871     logger->LogBoolean(Logger::STRING_ONLY_VISIBLE, only_visible); | 901     logger->LogBoolean(Logger::STRING_ONLY_VISIBLE, only_visible); | 
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1358   scoped_ptr<PasswordForm> password_form( | 1388   scoped_ptr<PasswordForm> password_form( | 
| 1359       CreatePasswordForm(form, &nonscript_modified_values_)); | 1389       CreatePasswordForm(form, &nonscript_modified_values_)); | 
| 1360   if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD && | 1390   if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD && | 
| 1361                          password_form->password_value.empty() && | 1391                          password_form->password_value.empty() && | 
| 1362                          password_form->new_password_value.empty())) { | 1392                          password_form->new_password_value.empty())) { | 
| 1363     return; | 1393     return; | 
| 1364   } | 1394   } | 
| 1365   provisionally_saved_form_ = password_form.Pass(); | 1395   provisionally_saved_form_ = password_form.Pass(); | 
| 1366 } | 1396 } | 
| 1367 | 1397 | 
|  | 1398 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() { | 
|  | 1399    return provisionally_saved_form_ && | 
|  | 1400        !provisionally_saved_form_->username_value.empty() && | 
|  | 1401        !(provisionally_saved_form_->password_value.empty() && | 
|  | 1402          provisionally_saved_form_->new_password_value.empty()); | 
|  | 1403 } | 
|  | 1404 | 
| 1368 // LegacyPasswordAutofillAgent ------------------------------------------------- | 1405 // LegacyPasswordAutofillAgent ------------------------------------------------- | 
| 1369 | 1406 | 
| 1370 PasswordAutofillAgent::LegacyPasswordAutofillAgent::LegacyPasswordAutofillAgent( | 1407 PasswordAutofillAgent::LegacyPasswordAutofillAgent::LegacyPasswordAutofillAgent( | 
| 1371     content::RenderView* render_view, | 1408     content::RenderView* render_view, | 
| 1372     PasswordAutofillAgent* agent) | 1409     PasswordAutofillAgent* agent) | 
| 1373     : content::RenderViewObserver(render_view), agent_(agent) { | 1410     : content::RenderViewObserver(render_view), agent_(agent) { | 
| 1374 } | 1411 } | 
| 1375 | 1412 | 
| 1376 PasswordAutofillAgent::LegacyPasswordAutofillAgent:: | 1413 PasswordAutofillAgent::LegacyPasswordAutofillAgent:: | 
| 1377     ~LegacyPasswordAutofillAgent() { | 1414     ~LegacyPasswordAutofillAgent() { | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 1388 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { | 1425 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { | 
| 1389   agent_->DidStopLoading(); | 1426   agent_->DidStopLoading(); | 
| 1390 } | 1427 } | 
| 1391 | 1428 | 
| 1392 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: | 1429 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: | 
| 1393     DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { | 1430     DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { | 
| 1394   agent_->LegacyDidStartProvisionalLoad(navigated_frame); | 1431   agent_->LegacyDidStartProvisionalLoad(navigated_frame); | 
| 1395 } | 1432 } | 
| 1396 | 1433 | 
| 1397 }  // namespace autofill | 1434 }  // namespace autofill | 
| OLD | NEW | 
|---|