| Index: components/autofill/content/renderer/password_autofill_agent.cc
|
| diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc
|
| index c55ec4512c49917820f6572457617bb86bad69d7..0cfd948c47147bd49044ef99995960a0a2097a1e 100644
|
| --- a/components/autofill/content/renderer/password_autofill_agent.cc
|
| +++ b/components/autofill/content/renderer/password_autofill_agent.cc
|
| @@ -848,9 +848,59 @@ bool PasswordAutofillAgent::OriginCanAccessPasswordManager(
|
| }
|
|
|
| void PasswordAutofillAgent::OnDynamicFormsSeen() {
|
| + //LOG(INFO) << this << "DynamicFormsSeen";
|
| SendPasswordForms(false /* only_visible */);
|
| }
|
|
|
| +void PasswordAutofillAgent::OnFormElementsRemoved(
|
| + const blink::WebVector<blink::WebNode>& nodes) {
|
| + //LOG(INFO) << nodes.size();
|
| + std::set<blink::WebFormElement> form_elements;
|
| + for (size_t i = 0; i < nodes.size(); ++i) {
|
| + if (!nodes[i].isElementNode()) {
|
| + //LOG(INFO) << "early exit";
|
| + continue;
|
| + }
|
| +
|
| + blink::WebElement element = nodes[i].toConst<blink::WebElement>();
|
| + if (!element.hasHTMLTagName("input")) {
|
| + //LOG(INFO) << "later exit";
|
| + continue;
|
| + }
|
| +
|
| + blink::WebInputElement input_element = element.to<blink::WebInputElement>();
|
| + //LOG(INFO) << input_element.getAttribute("id").utf8();
|
| + if (!input_element.form().isNull()) {
|
| + //LOG(INFO) << input_element.form().name().utf8();
|
| + form_elements.insert(input_element.form());
|
| + } else {
|
| + //LOG(INFO) << "no form";
|
| + }
|
| + }
|
| + //LOG(INFO) << form_elements.size();
|
| +
|
| + if (!provisionally_saved_form_ ||
|
| + provisionally_saved_form_->username_value.empty() ||
|
| + (provisionally_saved_form_->password_value.empty() &&
|
| + provisionally_saved_form_->new_password_value.empty())) {
|
| + //LOG(INFO) << "no provisionally saved form";
|
| + return;
|
| + }
|
| +
|
| + //LOG(INFO) << provisionally_saved_form_->action;
|
| + for (std::set<blink::WebFormElement>::iterator it = form_elements.begin();
|
| + it != form_elements.end(); ++it) {
|
| + GURL action(GetCanonicalActionURL(*it));
|
| + //LOG(INFO) << action.spec();
|
| + if (action == provisionally_saved_form_->action) {
|
| + Send(new AutofillHostMsg_PasswordFormSubmitted(
|
| + routing_id(), *provisionally_saved_form_));
|
| + provisionally_saved_form_.reset();
|
| + return;
|
| + }
|
| + }
|
| +}
|
| +
|
| void PasswordAutofillAgent::FirstUserGestureObserved() {
|
| gatekeeper_.OnUserGesture();
|
| }
|
| @@ -992,11 +1042,24 @@ void PasswordAutofillAgent::DidStopLoading() {
|
| }
|
|
|
| void PasswordAutofillAgent::FrameDetached() {
|
| + /* LOG(INFO) << this << "closing";
|
| + if (!render_frame()->GetWebFrame()->parent())
|
| + LOG(INFO) << "MainFrame";
|
| + if (ProvisionallySavedPasswordIsValid())
|
| + LOG(INFO) << "Password Valid";*/
|
| + if (render_frame()->GetWebFrame()->parent() &&
|
| + ProvisionallySavedPasswordIsValid()) {
|
| + //LOG(INFO) << "SENDING";
|
| + Send(new AutofillHostMsg_PasswordFormSubmitted(
|
| + routing_id(), *provisionally_saved_form_));
|
| + provisionally_saved_form_.reset();
|
| + }
|
| FrameClosing();
|
| }
|
|
|
| void PasswordAutofillAgent::WillSendSubmitEvent(
|
| const blink::WebFormElement& form) {
|
| + LOG(INFO) << "Will send submit event";
|
| // Forms submitted via XHR are not seen by WillSubmitForm if the default
|
| // onsubmit handler is overridden. Such submission first gets detected in
|
| // DidStartProvisionalLoad, which no longer knows about the particular form,
|
| @@ -1355,6 +1418,52 @@ void PasswordAutofillAgent::ProvisionallySavePassword(
|
| provisionally_saved_form_ = password_form.Pass();
|
| }
|
|
|
| +bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() {
|
| + return provisionally_saved_form_ &&
|
| + !provisionally_saved_form_->username_value.empty() &&
|
| + (!provisionally_saved_form_->password_value.empty() ||
|
| + provisionally_saved_form_->new_password_value.empty());
|
| +}
|
| +
|
| +void PasswordAutofillAgent::XHRSucceeded() {
|
| + blink::WebFrame* frame = render_frame()->GetWebFrame();
|
| + blink::WebVector<blink::WebFormElement> forms;
|
| + frame->document().forms(forms);
|
| +
|
| + if (!provisionally_saved_form_ ||
|
| + provisionally_saved_form_->username_value.empty() ||
|
| + (provisionally_saved_form_->password_value.empty() &&
|
| + provisionally_saved_form_->new_password_value.empty()))
|
| + return;
|
| +
|
| + bool matched = false;
|
| + std::vector<PasswordForm> password_forms;
|
| + for (size_t i = 0; i < forms.size(); ++i) {
|
| + const blink::WebFormElement& form = forms[i];
|
| + bool is_form_visible = IsWebNodeVisible(form);
|
| +
|
| + // If requested, ignore non-rendered forms, e.g., those styled with
|
| + // display:none.
|
| + if (!is_form_visible) {
|
| + LOG(INFO) << "Form: " << form.action().utf8() << "is invisible";
|
| + continue;
|
| + }
|
| +
|
| + scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form, nullptr));
|
| + if (password_form.get()) {
|
| + password_forms.push_back(*password_form);
|
| + if (provisionally_saved_form_->username_element == password_form->username_element &&
|
| + (provisionally_saved_form_->password_element == password_form->password_element ||
|
| + provisionally_saved_form_->new_password_element == password_form->new_password_element)) {
|
| + matched = true;
|
| + }
|
| + }
|
| + }
|
| + LOG(INFO) << password_forms.size();
|
| + if (!matched)
|
| + LOG(INFO) << "Should Save";
|
| +}
|
| +
|
| // LegacyPasswordAutofillAgent -------------------------------------------------
|
|
|
| PasswordAutofillAgent::LegacyPasswordAutofillAgent::LegacyPasswordAutofillAgent(
|
|
|