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/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 620 |
621 //////////////////////////////////////////////////////////////////////////////// | 621 //////////////////////////////////////////////////////////////////////////////// |
622 // PasswordAutofillAgent, public: | 622 // PasswordAutofillAgent, public: |
623 | 623 |
624 PasswordAutofillAgent::PasswordAutofillAgent(content::RenderFrame* render_frame) | 624 PasswordAutofillAgent::PasswordAutofillAgent(content::RenderFrame* render_frame) |
625 : content::RenderFrameObserver(render_frame), | 625 : content::RenderFrameObserver(render_frame), |
626 legacy_(render_frame->GetRenderView(), this), | 626 legacy_(render_frame->GetRenderView(), this), |
627 logging_state_active_(false), | 627 logging_state_active_(false), |
628 was_username_autofilled_(false), | 628 was_username_autofilled_(false), |
629 was_password_autofilled_(false), | 629 was_password_autofilled_(false), |
630 did_stop_loading_(false), | |
631 weak_ptr_factory_(this) { | 630 weak_ptr_factory_(this) { |
632 Send(new AutofillHostMsg_PasswordAutofillAgentConstructed(routing_id())); | 631 Send(new AutofillHostMsg_PasswordAutofillAgentConstructed(routing_id())); |
633 } | 632 } |
634 | 633 |
635 PasswordAutofillAgent::~PasswordAutofillAgent() { | 634 PasswordAutofillAgent::~PasswordAutofillAgent() { |
636 } | 635 } |
637 | 636 |
638 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() | 637 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() |
639 : was_user_gesture_seen_(false) { | 638 : was_user_gesture_seen_(false) { |
640 } | 639 } |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 } | 1042 } |
1044 | 1043 |
1045 if (password_forms.empty() && !only_visible) { | 1044 if (password_forms.empty() && !only_visible) { |
1046 // We need to send the PasswordFormsRendered message regardless of whether | 1045 // We need to send the PasswordFormsRendered message regardless of whether |
1047 // there are any forms visible, as this is also the code path that triggers | 1046 // there are any forms visible, as this is also the code path that triggers |
1048 // showing the infobar. | 1047 // showing the infobar. |
1049 return; | 1048 return; |
1050 } | 1049 } |
1051 | 1050 |
1052 if (only_visible) { | 1051 if (only_visible) { |
1053 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(), | 1052 bool is_last_load = true; |
1054 password_forms, | 1053 for (blink::WebFrame* frame = render_frame()->GetWebFrame()->top(); frame; |
1055 did_stop_loading_)); | 1054 frame = frame->traverseNext(false)) { |
| 1055 if (frame != render_frame()->GetWebFrame() && frame->isLoading()) { |
| 1056 is_last_load = false; |
| 1057 break; |
| 1058 } |
| 1059 } |
| 1060 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(), password_forms, |
| 1061 is_last_load)); |
1056 } else { | 1062 } else { |
1057 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); | 1063 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); |
1058 } | 1064 } |
1059 } | 1065 } |
1060 | 1066 |
1061 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { | 1067 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { |
1062 bool handled = true; | 1068 bool handled = true; |
1063 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) | 1069 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) |
1064 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) | 1070 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) |
1065 IPC_MESSAGE_HANDLER(AutofillMsg_SetLoggingState, OnSetLoggingState) | 1071 IPC_MESSAGE_HANDLER(AutofillMsg_SetLoggingState, OnSetLoggingState) |
(...skipping 25 matching lines...) Expand all Loading... |
1091 FrameClosing(); | 1097 FrameClosing(); |
1092 } | 1098 } |
1093 | 1099 |
1094 void PasswordAutofillAgent::DidCommitProvisionalLoad( | 1100 void PasswordAutofillAgent::DidCommitProvisionalLoad( |
1095 bool is_new_navigation, bool is_same_page_navigation) { | 1101 bool is_new_navigation, bool is_same_page_navigation) { |
1096 if (is_same_page_navigation) { | 1102 if (is_same_page_navigation) { |
1097 OnSamePageNavigationCompleted(); | 1103 OnSamePageNavigationCompleted(); |
1098 } | 1104 } |
1099 } | 1105 } |
1100 | 1106 |
1101 void PasswordAutofillAgent::DidStartLoading() { | |
1102 did_stop_loading_ = false; | |
1103 } | |
1104 | |
1105 void PasswordAutofillAgent::DidStopLoading() { | |
1106 did_stop_loading_ = true; | |
1107 } | |
1108 | |
1109 void PasswordAutofillAgent::FrameDetached() { | 1107 void PasswordAutofillAgent::FrameDetached() { |
1110 // If a sub frame has been destroyed while the user was entering information | 1108 // If a sub frame has been destroyed while the user was entering information |
1111 // into a password form, try to save the data. See https://crbug.com/450806 | 1109 // into a password form, try to save the data. See https://crbug.com/450806 |
1112 // for examples of sites that perform login using this technique. | 1110 // for examples of sites that perform login using this technique. |
1113 if (render_frame()->GetWebFrame()->parent() && | 1111 if (render_frame()->GetWebFrame()->parent() && |
1114 ProvisionallySavedPasswordIsValid()) { | 1112 ProvisionallySavedPasswordIsValid()) { |
1115 Send(new AutofillHostMsg_InPageNavigation(routing_id(), | 1113 Send(new AutofillHostMsg_InPageNavigation(routing_id(), |
1116 *provisionally_saved_form_)); | 1114 *provisionally_saved_form_)); |
1117 } | 1115 } |
1118 FrameClosing(); | 1116 FrameClosing(); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 } | 1515 } |
1518 | 1516 |
1519 PasswordAutofillAgent::LegacyPasswordAutofillAgent:: | 1517 PasswordAutofillAgent::LegacyPasswordAutofillAgent:: |
1520 ~LegacyPasswordAutofillAgent() { | 1518 ~LegacyPasswordAutofillAgent() { |
1521 } | 1519 } |
1522 | 1520 |
1523 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::OnDestruct() { | 1521 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::OnDestruct() { |
1524 // No op. Do not delete |this|. | 1522 // No op. Do not delete |this|. |
1525 } | 1523 } |
1526 | 1524 |
1527 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStartLoading() { | |
1528 agent_->DidStartLoading(); | |
1529 } | |
1530 | |
1531 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { | |
1532 agent_->DidStopLoading(); | |
1533 } | |
1534 | |
1535 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: | 1525 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: |
1536 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { | 1526 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { |
1537 agent_->LegacyDidStartProvisionalLoad(navigated_frame); | 1527 agent_->LegacyDidStartProvisionalLoad(navigated_frame); |
1538 } | 1528 } |
1539 | 1529 |
1540 } // namespace autofill | 1530 } // namespace autofill |
OLD | NEW |