Chromium Code Reviews| 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "components/autofill/content/common/autofill_messages.h" | 12 #include "components/autofill/content/common/autofill_messages.h" |
| 13 #include "components/autofill/content/renderer/form_autofill_util.h" | 13 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 14 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 14 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
| 15 #include "components/autofill/content/renderer/renderer_save_password_progress_l ogger.h" | |
| 15 #include "components/autofill/core/common/form_field_data.h" | 16 #include "components/autofill/core/common/form_field_data.h" |
| 16 #include "components/autofill/core/common/password_autofill_util.h" | 17 #include "components/autofill/core/common/password_autofill_util.h" |
| 17 #include "components/autofill/core/common/password_form.h" | 18 #include "components/autofill/core/common/password_form.h" |
| 18 #include "components/autofill/core/common/password_form_fill_data.h" | 19 #include "components/autofill/core/common/password_form_fill_data.h" |
| 19 #include "content/public/renderer/render_view.h" | 20 #include "content/public/renderer/render_view.h" |
| 20 #include "third_party/WebKit/public/platform/WebVector.h" | 21 #include "third_party/WebKit/public/platform/WebVector.h" |
| 21 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 22 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
| 22 #include "third_party/WebKit/public/web/WebDocument.h" | 23 #include "third_party/WebKit/public/web/WebDocument.h" |
| 23 #include "third_party/WebKit/public/web/WebElement.h" | 24 #include "third_party/WebKit/public/web/WebElement.h" |
| 24 #include "third_party/WebKit/public/web/WebFormElement.h" | 25 #include "third_party/WebKit/public/web/WebFormElement.h" |
| 25 #include "third_party/WebKit/public/web/WebInputEvent.h" | 26 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 26 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 27 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 27 #include "third_party/WebKit/public/web/WebNode.h" | 28 #include "third_party/WebKit/public/web/WebNode.h" |
| 28 #include "third_party/WebKit/public/web/WebNodeList.h" | 29 #include "third_party/WebKit/public/web/WebNodeList.h" |
| 29 #include "third_party/WebKit/public/web/WebPasswordFormData.h" | 30 #include "third_party/WebKit/public/web/WebPasswordFormData.h" |
| 30 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 31 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 31 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 32 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 32 #include "third_party/WebKit/public/web/WebView.h" | 33 #include "third_party/WebKit/public/web/WebView.h" |
| 33 #include "ui/events/keycodes/keyboard_codes.h" | 34 #include "ui/events/keycodes/keyboard_codes.h" |
| 35 #include "url/gurl.h" | |
| 34 | 36 |
| 35 namespace autofill { | 37 namespace autofill { |
| 36 namespace { | 38 namespace { |
| 37 | 39 |
| 38 // The size above which we stop triggering autocomplete. | 40 // The size above which we stop triggering autocomplete. |
| 39 static const size_t kMaximumTextSizeForAutocomplete = 1000; | 41 static const size_t kMaximumTextSizeForAutocomplete = 1000; |
| 40 | 42 |
| 41 // Maps element names to the actual elements to simplify form filling. | 43 // Maps element names to the actual elements to simplify form filling. |
| 42 typedef std::map<base::string16, blink::WebInputElement> | 44 typedef std::map<base::string16, blink::WebInputElement> |
| 43 FormInputElementMap; | 45 FormInputElementMap; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 // appropriately named elements match the element to be saved. Currently | 196 // appropriately named elements match the element to be saved. Currently |
| 195 // we ignore filling passwords where naming is ambigious anyway. | 197 // we ignore filling passwords where naming is ambigious anyway. |
| 196 for (size_t i = 0; i < temp_elements.size(); ++i) { | 198 for (size_t i = 0; i < temp_elements.size(); ++i) { |
| 197 if (temp_elements[i].to<blink::WebElement>().getAttribute("value") == | 199 if (temp_elements[i].to<blink::WebElement>().getAttribute("value") == |
| 198 form.password_value) | 200 form.password_value) |
| 199 return true; | 201 return true; |
| 200 } | 202 } |
| 201 return false; | 203 return false; |
| 202 } | 204 } |
| 203 | 205 |
| 206 void LogHTMLForm(SavePasswordProgressLogger* logger, | |
|
Ilya Sherman
2014/04/23 05:19:56
nit: Docs, please.
vabr (Chromium)
2014/04/23 18:15:35
Done.
| |
| 207 SavePasswordProgressLogger::StringID message_id, | |
| 208 const blink::WebFormElement& form) { | |
| 209 DCHECK(logger); | |
|
Ilya Sherman
2014/04/23 05:19:56
nit: No need for this DCHECK, since you immediatel
vabr (Chromium)
2014/04/23 18:15:35
Done.
| |
| 210 logger->LogHTMLForm(message_id, | |
| 211 form.name().utf8(), | |
| 212 form.method().utf8(), | |
| 213 GURL(form.action().utf8())); | |
| 214 } | |
| 215 | |
| 204 } // namespace | 216 } // namespace |
| 205 | 217 |
| 206 //////////////////////////////////////////////////////////////////////////////// | 218 //////////////////////////////////////////////////////////////////////////////// |
| 207 // PasswordAutofillAgent, public: | 219 // PasswordAutofillAgent, public: |
| 208 | 220 |
| 209 PasswordAutofillAgent::PasswordAutofillAgent(content::RenderView* render_view) | 221 PasswordAutofillAgent::PasswordAutofillAgent(content::RenderView* render_view) |
| 210 : content::RenderViewObserver(render_view), | 222 : content::RenderViewObserver(render_view), |
| 211 usernames_usage_(NOTHING_TO_AUTOFILL), | 223 usernames_usage_(NOTHING_TO_AUTOFILL), |
| 212 web_view_(render_view->GetWebView()), | 224 web_view_(render_view->GetWebView()), |
| 213 weak_ptr_factory_(this) { | 225 logging_state_active_(false), |
| 214 } | 226 weak_ptr_factory_(this) {} |
| 215 | 227 |
| 216 PasswordAutofillAgent::~PasswordAutofillAgent() {} | 228 PasswordAutofillAgent::~PasswordAutofillAgent() {} |
| 217 | 229 |
| 218 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() | 230 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() |
| 219 : was_user_gesture_seen_(false) {} | 231 : was_user_gesture_seen_(false) {} |
| 220 | 232 |
| 221 PasswordAutofillAgent::PasswordValueGatekeeper::~PasswordValueGatekeeper() {} | 233 PasswordAutofillAgent::PasswordValueGatekeeper::~PasswordValueGatekeeper() {} |
| 222 | 234 |
| 223 void PasswordAutofillAgent::PasswordValueGatekeeper::RegisterElement( | 235 void PasswordAutofillAgent::PasswordValueGatekeeper::RegisterElement( |
| 224 blink::WebInputElement* element) { | 236 blink::WebInputElement* element) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 const blink::WebSecurityOrigin& origin) { | 402 const blink::WebSecurityOrigin& origin) { |
| 391 return origin.canAccessPasswordManager(); | 403 return origin.canAccessPasswordManager(); |
| 392 } | 404 } |
| 393 | 405 |
| 394 void PasswordAutofillAgent::OnDynamicFormsSeen(blink::WebFrame* frame) { | 406 void PasswordAutofillAgent::OnDynamicFormsSeen(blink::WebFrame* frame) { |
| 395 SendPasswordForms(frame, false /* only_visible */); | 407 SendPasswordForms(frame, false /* only_visible */); |
| 396 } | 408 } |
| 397 | 409 |
| 398 void PasswordAutofillAgent::SendPasswordForms(blink::WebFrame* frame, | 410 void PasswordAutofillAgent::SendPasswordForms(blink::WebFrame* frame, |
| 399 bool only_visible) { | 411 bool only_visible) { |
| 412 scoped_ptr<RendererSavePasswordProgressLogger> logger; | |
| 413 if (only_visible && logging_state_active_) { | |
|
Ilya Sherman
2014/04/23 05:19:56
nit: Why does the value of |only_visible| matter w
vabr (Chromium)
2014/04/23 18:15:35
Done.
| |
| 414 logger.reset(new RendererSavePasswordProgressLogger(this, routing_id())); | |
| 415 logger->LogMessage( | |
| 416 SavePasswordProgressLogger::STRING_SEND_PASSWORD_FORMS_METHOD); | |
|
Ilya Sherman
2014/04/23 05:19:56
The "SavePasswordProgressLogger::" is unfortunatel
vabr (Chromium)
2014/04/23 18:15:35
I like the idea, super-long lines bothered me as I
| |
| 417 } | |
| 418 | |
| 400 // Make sure that this security origin is allowed to use password manager. | 419 // Make sure that this security origin is allowed to use password manager. |
| 401 blink::WebSecurityOrigin origin = frame->document().securityOrigin(); | 420 blink::WebSecurityOrigin origin = frame->document().securityOrigin(); |
| 402 if (!OriginCanAccessPasswordManager(origin)) | 421 if (logger) |
|
Ilya Sherman
2014/04/23 05:19:56
nit: Needs curly braces.
vabr (Chromium)
2014/04/23 18:15:35
Done.
| |
| 422 logger->LogURL(SavePasswordProgressLogger::STRING_SECURITY_ORIGIN, | |
| 423 GURL(origin.toString().utf8())); | |
|
Ilya Sherman
2014/04/23 05:19:56
The WebUrl class defines a conversion operator to
vabr (Chromium)
2014/04/23 18:15:35
I'm afraid I found no way to get a WebURL from a W
Ilya Sherman
2014/04/23 20:21:44
Hmm, seems that you're right. Ok, nevermind then.
| |
| 424 if (!OriginCanAccessPasswordManager(origin)) { | |
| 425 if (logger) { | |
| 426 logger->LogMessage( | |
| 427 SavePasswordProgressLogger::STRING_SECURITY_ORIGIN_FAILURE); | |
| 428 logger->LogMessage(SavePasswordProgressLogger::STRING_DECISION_DROP); | |
| 429 } | |
| 403 return; | 430 return; |
| 431 } | |
| 404 | 432 |
| 405 // Checks whether the webpage is a redirect page or an empty page. | 433 // Checks whether the webpage is a redirect page or an empty page. |
| 406 if (IsWebpageEmpty(frame)) | 434 if (IsWebpageEmpty(frame)) { |
| 435 if (logger) { | |
| 436 logger->LogMessage(SavePasswordProgressLogger::STRING_WEBPAGE_EMPTY); | |
| 437 logger->LogMessage(SavePasswordProgressLogger::STRING_DECISION_DROP); | |
| 438 } | |
| 407 return; | 439 return; |
| 440 } | |
| 408 | 441 |
| 409 blink::WebVector<blink::WebFormElement> forms; | 442 blink::WebVector<blink::WebFormElement> forms; |
| 410 frame->document().forms(forms); | 443 frame->document().forms(forms); |
| 444 if (logger) | |
| 445 logger->LogNumber(SavePasswordProgressLogger::STRING_NUMBER_OF_ALL_FORMS, | |
| 446 forms.size()); | |
| 411 | 447 |
| 412 std::vector<PasswordForm> password_forms; | 448 std::vector<PasswordForm> password_forms; |
| 413 for (size_t i = 0; i < forms.size(); ++i) { | 449 for (size_t i = 0; i < forms.size(); ++i) { |
| 414 const blink::WebFormElement& form = forms[i]; | 450 const blink::WebFormElement& form = forms[i]; |
| 451 bool is_form_visible = IsWebNodeVisible(form); | |
| 452 if (logger) { | |
| 453 LogHTMLForm(logger.get(), | |
| 454 SavePasswordProgressLogger::STRING_FORM_FOUND_ON_PAGE, | |
| 455 form); | |
| 456 logger->LogBoolean(SavePasswordProgressLogger::STRING_FORM_IS_VISIBLE, | |
| 457 is_form_visible); | |
| 458 } | |
| 415 | 459 |
| 416 // If requested, ignore non-rendered forms, e.g. those styled with | 460 // If requested, ignore non-rendered forms, e.g. those styled with |
| 417 // display:none. | 461 // display:none. |
| 418 if (only_visible && !IsWebNodeVisible(form)) | 462 if (only_visible && !is_form_visible ) |
| 419 continue; | 463 continue; |
| 420 | 464 |
| 421 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); | 465 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); |
| 422 if (password_form.get()) | 466 if (password_form.get()) { |
| 467 if (logger) | |
|
Ilya Sherman
2014/04/23 05:19:56
nit: Needs curly braces.
vabr (Chromium)
2014/04/23 18:15:35
Done.
Sorry about these. I now went through the co
| |
| 468 logger->LogPasswordForm( | |
| 469 SavePasswordProgressLogger::STRING_FORM_IS_PASSWORD, | |
| 470 *password_form); | |
| 423 password_forms.push_back(*password_form); | 471 password_forms.push_back(*password_form); |
| 472 } | |
| 424 } | 473 } |
| 425 | 474 |
| 426 if (password_forms.empty() && !only_visible) { | 475 if (password_forms.empty() && !only_visible) { |
| 427 // We need to send the PasswordFormsRendered message regardless of whether | 476 // We need to send the PasswordFormsRendered message regardless of whether |
| 428 // there are any forms visible, as this is also the code path that triggers | 477 // there are any forms visible, as this is also the code path that triggers |
| 429 // showing the infobar. | 478 // showing the infobar. |
| 430 return; | 479 return; |
| 431 } | 480 } |
| 432 | 481 |
| 433 if (only_visible) { | 482 if (only_visible) { |
| 434 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(), | 483 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(), |
| 435 password_forms)); | 484 password_forms)); |
| 436 } else { | 485 } else { |
| 437 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); | 486 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms)); |
| 438 } | 487 } |
| 439 } | 488 } |
| 440 | 489 |
| 441 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { | 490 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message& message) { |
| 442 bool handled = true; | 491 bool handled = true; |
| 443 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) | 492 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent, message) |
| 444 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) | 493 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm, OnFillPasswordForm) |
| 494 IPC_MESSAGE_HANDLER(AutofillMsg_ChangeLoggingState, OnChangeLoggingState) | |
| 445 IPC_MESSAGE_UNHANDLED(handled = false) | 495 IPC_MESSAGE_UNHANDLED(handled = false) |
| 446 IPC_END_MESSAGE_MAP() | 496 IPC_END_MESSAGE_MAP() |
| 447 return handled; | 497 return handled; |
| 448 } | 498 } |
| 449 | 499 |
| 450 void PasswordAutofillAgent::DidStartLoading() { | 500 void PasswordAutofillAgent::DidStartLoading() { |
| 451 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { | 501 if (usernames_usage_ != NOTHING_TO_AUTOFILL) { |
| 452 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", | 502 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage", |
| 453 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); | 503 usernames_usage_, OTHER_POSSIBLE_USERNAMES_MAX); |
| 454 usernames_usage_ = NOTHING_TO_AUTOFILL; | 504 usernames_usage_ = NOTHING_TO_AUTOFILL; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 485 // into a hidden field and then clear the password (http://crbug.com/28910). | 535 // into a hidden field and then clear the password (http://crbug.com/28910). |
| 486 // This method gets called before any of those handlers run, so save away | 536 // This method gets called before any of those handlers run, so save away |
| 487 // a copy of the password in case it gets lost. | 537 // a copy of the password in case it gets lost. |
| 488 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); | 538 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); |
| 489 if (password_form) | 539 if (password_form) |
| 490 provisionally_saved_forms_[frame].reset(password_form.release()); | 540 provisionally_saved_forms_[frame].reset(password_form.release()); |
| 491 } | 541 } |
| 492 | 542 |
| 493 void PasswordAutofillAgent::WillSubmitForm(blink::WebLocalFrame* frame, | 543 void PasswordAutofillAgent::WillSubmitForm(blink::WebLocalFrame* frame, |
| 494 const blink::WebFormElement& form) { | 544 const blink::WebFormElement& form) { |
| 545 scoped_ptr<RendererSavePasswordProgressLogger> logger; | |
| 546 if (logging_state_active_) { | |
| 547 logger.reset(new RendererSavePasswordProgressLogger(this, routing_id())); | |
| 548 logger->LogMessage( | |
| 549 SavePasswordProgressLogger::STRING_WILL_SUBMIT_FORM_METHOD); | |
| 550 LogHTMLForm(logger.get(), | |
| 551 SavePasswordProgressLogger::STRING_HTML_FORM_FOR_SUBMIT, | |
| 552 form); | |
| 553 } | |
| 554 | |
| 495 scoped_ptr<PasswordForm> submitted_form = CreatePasswordForm(form); | 555 scoped_ptr<PasswordForm> submitted_form = CreatePasswordForm(form); |
| 496 | 556 |
| 497 // If there is a provisionally saved password, copy over the previous | 557 // If there is a provisionally saved password, copy over the previous |
| 498 // password value so we get the user's typed password, not the value that | 558 // password value so we get the user's typed password, not the value that |
| 499 // may have been transformed for submit. | 559 // may have been transformed for submit. |
| 500 // TODO(gcasto): Do we need to have this action equality check? Is it trying | 560 // TODO(gcasto): Do we need to have this action equality check? Is it trying |
| 501 // to prevent accidentally copying over passwords from a different form? | 561 // to prevent accidentally copying over passwords from a different form? |
| 502 if (submitted_form) { | 562 if (submitted_form) { |
| 563 if (logger) | |
| 564 logger->LogPasswordForm( | |
| 565 SavePasswordProgressLogger::STRING_CREATED_PASSWORD_FORM, | |
| 566 *submitted_form); | |
| 503 if (provisionally_saved_forms_[frame].get() && | 567 if (provisionally_saved_forms_[frame].get() && |
| 504 submitted_form->action == provisionally_saved_forms_[frame]->action) { | 568 submitted_form->action == provisionally_saved_forms_[frame]->action) { |
| 569 if (logger) | |
| 570 logger->LogMessage( | |
| 571 SavePasswordProgressLogger::STRING_SUBMITTED_PASSWORD_REPLACED); | |
| 505 submitted_form->password_value = | 572 submitted_form->password_value = |
| 506 provisionally_saved_forms_[frame]->password_value; | 573 provisionally_saved_forms_[frame]->password_value; |
| 507 } | 574 } |
| 508 | 575 |
| 509 // Some observers depend on sending this information now instead of when | 576 // Some observers depend on sending this information now instead of when |
| 510 // the frame starts loading. If there are redirects that cause a new | 577 // the frame starts loading. If there are redirects that cause a new |
| 511 // RenderView to be instantiated (such as redirects to the WebStore) | 578 // RenderView to be instantiated (such as redirects to the WebStore) |
| 512 // we will never get to finish the load. | 579 // we will never get to finish the load. |
| 513 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(), | 580 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(), |
| 514 *submitted_form)); | 581 *submitted_form)); |
| 515 // Remove reference since we have already submitted this form. | 582 // Remove reference since we have already submitted this form. |
| 516 provisionally_saved_forms_.erase(frame); | 583 provisionally_saved_forms_.erase(frame); |
| 584 } else if (logger) { | |
| 585 logger->LogMessage(SavePasswordProgressLogger::STRING_DECISION_DROP); | |
| 517 } | 586 } |
| 518 } | 587 } |
| 519 | 588 |
| 520 void PasswordAutofillAgent::WillProcessUserGesture() { | 589 void PasswordAutofillAgent::WillProcessUserGesture() { |
| 521 gatekeeper_.OnUserGesture(); | 590 gatekeeper_.OnUserGesture(); |
| 522 } | 591 } |
| 523 | 592 |
| 524 blink::WebFrame* PasswordAutofillAgent::CurrentOrChildFrameWithSavedForms( | 593 blink::WebFrame* PasswordAutofillAgent::CurrentOrChildFrameWithSavedForms( |
| 525 const blink::WebFrame* current_frame) { | 594 const blink::WebFrame* current_frame) { |
| 526 for (FrameToPasswordFormMap::const_iterator it = | 595 for (FrameToPasswordFormMap::const_iterator it = |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 537 if (current_frame == form_frame || | 606 if (current_frame == form_frame || |
| 538 current_frame->findChildByName(form_frame->assignedName())) { | 607 current_frame->findChildByName(form_frame->assignedName())) { |
| 539 return form_frame; | 608 return form_frame; |
| 540 } | 609 } |
| 541 } | 610 } |
| 542 return NULL; | 611 return NULL; |
| 543 } | 612 } |
| 544 | 613 |
| 545 void PasswordAutofillAgent::DidStartProvisionalLoad( | 614 void PasswordAutofillAgent::DidStartProvisionalLoad( |
| 546 blink::WebLocalFrame* frame) { | 615 blink::WebLocalFrame* frame) { |
| 616 scoped_ptr<RendererSavePasswordProgressLogger> logger; | |
| 617 if (logging_state_active_) { | |
| 618 logger.reset(new RendererSavePasswordProgressLogger(this, routing_id())); | |
| 619 logger->LogMessage( | |
| 620 SavePasswordProgressLogger::STRING_DID_START_PROVISIONAL_LOAD_METHOD); | |
| 621 } | |
| 622 | |
| 547 if (!frame->parent()) { | 623 if (!frame->parent()) { |
| 548 // If the navigation is not triggered by a user gesture, e.g. by some ajax | 624 // If the navigation is not triggered by a user gesture, e.g. by some ajax |
| 549 // callback, then inherit the submitted password form from the previous | 625 // callback, then inherit the submitted password form from the previous |
| 550 // state. This fixes the no password save issue for ajax login, tracked in | 626 // state. This fixes the no password save issue for ajax login, tracked in |
| 551 // [http://crbug/43219]. Note that this still fails for sites that use | 627 // [http://crbug/43219]. Note that this still fails for sites that use |
| 552 // synchonous XHR as isProcessingUserGesture() will return true. | 628 // synchonous XHR as isProcessingUserGesture() will return true. |
| 553 blink::WebFrame* form_frame = CurrentOrChildFrameWithSavedForms(frame); | 629 blink::WebFrame* form_frame = CurrentOrChildFrameWithSavedForms(frame); |
| 630 if (logger) | |
| 631 logger->LogBoolean(SavePasswordProgressLogger::STRING_FORM_FRAME_EQ_FRAME, | |
| 632 form_frame == frame); | |
| 554 if (!blink::WebUserGestureIndicator::isProcessingUserGesture()) { | 633 if (!blink::WebUserGestureIndicator::isProcessingUserGesture()) { |
| 555 // If onsubmit has been called, try and save that form. | 634 // If onsubmit has been called, try and save that form. |
| 556 if (provisionally_saved_forms_[form_frame].get()) { | 635 if (provisionally_saved_forms_[form_frame].get()) { |
| 636 if (logger) | |
| 637 logger->LogPasswordForm(SavePasswordProgressLogger:: | |
| 638 STRING_PROVISIONALLY_SAVED_FORM_FOR_FRAME, | |
| 639 *provisionally_saved_forms_[form_frame]); | |
| 557 Send(new AutofillHostMsg_PasswordFormSubmitted( | 640 Send(new AutofillHostMsg_PasswordFormSubmitted( |
| 558 routing_id(), | 641 routing_id(), |
| 559 *provisionally_saved_forms_[form_frame])); | 642 *provisionally_saved_forms_[form_frame])); |
| 560 provisionally_saved_forms_.erase(form_frame); | 643 provisionally_saved_forms_.erase(form_frame); |
| 561 } else { | 644 } else { |
| 562 // Loop through the forms on the page looking for one that has been | 645 // Loop through the forms on the page looking for one that has been |
| 563 // filled out. If one exists, try and save the credentials. | 646 // filled out. If one exists, try and save the credentials. |
| 564 blink::WebVector<blink::WebFormElement> forms; | 647 blink::WebVector<blink::WebFormElement> forms; |
| 565 frame->document().forms(forms); | 648 frame->document().forms(forms); |
| 566 | 649 |
| 650 bool password_forms_found = false; | |
| 567 for (size_t i = 0; i < forms.size(); ++i) { | 651 for (size_t i = 0; i < forms.size(); ++i) { |
| 568 blink::WebFormElement form_element= forms[i]; | 652 blink::WebFormElement form_element= forms[i]; |
| 653 if (logger) | |
| 654 LogHTMLForm(logger.get(), | |
| 655 SavePasswordProgressLogger::STRING_FORM_FOUND_ON_PAGE, | |
| 656 form_element); | |
| 569 scoped_ptr<PasswordForm> password_form( | 657 scoped_ptr<PasswordForm> password_form( |
| 570 CreatePasswordForm(form_element)); | 658 CreatePasswordForm(form_element)); |
| 571 if (password_form.get() && | 659 if (password_form.get() && |
| 572 !password_form->username_value.empty() && | 660 !password_form->username_value.empty() && |
| 573 !password_form->password_value.empty() && | 661 !password_form->password_value.empty() && |
| 574 !PasswordValueIsDefault(*password_form, form_element)) { | 662 !PasswordValueIsDefault(*password_form, form_element)) { |
| 663 password_forms_found = true; | |
| 664 if (logger) | |
| 665 logger->LogPasswordForm(SavePasswordProgressLogger:: | |
| 666 STRING_PASSWORD_FORM_FOUND_ON_PAGE, | |
| 667 *password_form); | |
| 575 Send(new AutofillHostMsg_PasswordFormSubmitted( | 668 Send(new AutofillHostMsg_PasswordFormSubmitted( |
| 576 routing_id(), *password_form)); | 669 routing_id(), *password_form)); |
| 577 } | 670 } |
| 578 } | 671 } |
| 672 if (!password_forms_found && logger) { | |
| 673 logger->LogMessage(SavePasswordProgressLogger::STRING_DECISION_DROP); | |
| 674 } | |
| 579 } | 675 } |
| 580 } | 676 } |
| 581 // Clear the whole map during main frame navigation. | 677 // Clear the whole map during main frame navigation. |
| 582 provisionally_saved_forms_.clear(); | 678 provisionally_saved_forms_.clear(); |
| 583 | 679 |
| 584 // This is a new navigation, so require a new user gesture before filling in | 680 // This is a new navigation, so require a new user gesture before filling in |
| 585 // passwords. | 681 // passwords. |
| 586 gatekeeper_.Reset(); | 682 gatekeeper_.Reset(); |
| 683 } else { | |
| 684 if (logger) | |
| 685 logger->LogMessage(SavePasswordProgressLogger::STRING_DECISION_DROP); | |
| 587 } | 686 } |
| 588 } | 687 } |
| 589 | 688 |
| 590 void PasswordAutofillAgent::OnFillPasswordForm( | 689 void PasswordAutofillAgent::OnFillPasswordForm( |
| 591 const PasswordFormFillData& form_data) { | 690 const PasswordFormFillData& form_data) { |
| 592 if (usernames_usage_ == NOTHING_TO_AUTOFILL) { | 691 if (usernames_usage_ == NOTHING_TO_AUTOFILL) { |
| 593 if (form_data.other_possible_usernames.size()) | 692 if (form_data.other_possible_usernames.size()) |
| 594 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_PRESENT; | 693 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_PRESENT; |
| 595 else if (usernames_usage_ == NOTHING_TO_AUTOFILL) | 694 else if (usernames_usage_ == NOTHING_TO_AUTOFILL) |
| 596 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_ABSENT; | 695 usernames_usage_ = OTHER_POSSIBLE_USERNAMES_ABSENT; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 FormFieldData field; | 732 FormFieldData field; |
| 634 FindFormAndFieldForFormControlElement( | 733 FindFormAndFieldForFormControlElement( |
| 635 username_element, &form, &field, REQUIRE_NONE); | 734 username_element, &form, &field, REQUIRE_NONE); |
| 636 Send(new AutofillHostMsg_AddPasswordFormMapping( | 735 Send(new AutofillHostMsg_AddPasswordFormMapping( |
| 637 routing_id(), | 736 routing_id(), |
| 638 field, | 737 field, |
| 639 form_data)); | 738 form_data)); |
| 640 } | 739 } |
| 641 } | 740 } |
| 642 | 741 |
| 742 void PasswordAutofillAgent::OnChangeLoggingState(bool active) { | |
| 743 logging_state_active_ = active; | |
| 744 } | |
| 745 | |
| 643 //////////////////////////////////////////////////////////////////////////////// | 746 //////////////////////////////////////////////////////////////////////////////// |
| 644 // PasswordAutofillAgent, private: | 747 // PasswordAutofillAgent, private: |
| 645 | 748 |
| 646 void PasswordAutofillAgent::GetSuggestions( | 749 void PasswordAutofillAgent::GetSuggestions( |
| 647 const PasswordFormFillData& fill_data, | 750 const PasswordFormFillData& fill_data, |
| 648 const base::string16& input, | 751 const base::string16& input, |
| 649 std::vector<base::string16>* suggestions, | 752 std::vector<base::string16>* suggestions, |
| 650 std::vector<base::string16>* realms) { | 753 std::vector<base::string16>* realms) { |
| 651 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { | 754 if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) { |
| 652 suggestions->push_back(fill_data.basic_data.fields[0].value); | 755 suggestions->push_back(fill_data.basic_data.fields[0].value); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 896 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); | 999 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); |
| 897 if (iter == login_to_password_info_.end()) | 1000 if (iter == login_to_password_info_.end()) |
| 898 return false; | 1001 return false; |
| 899 | 1002 |
| 900 *found_input = input; | 1003 *found_input = input; |
| 901 *found_password = iter->second; | 1004 *found_password = iter->second; |
| 902 return true; | 1005 return true; |
| 903 } | 1006 } |
| 904 | 1007 |
| 905 } // namespace autofill | 1008 } // namespace autofill |
| OLD | NEW |