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