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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/i18n/case_conversion.h" | 14 #include "base/i18n/case_conversion.h" |
15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "components/autofill/content/common/autofill_messages.h" | 20 #include "components/autofill/content/common/autofill_messages.h" |
21 #include "components/autofill/content/renderer/form_autofill_util.h" | 21 #include "components/autofill/content/renderer/form_autofill_util.h" |
22 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 22 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
23 #include "components/autofill/content/renderer/renderer_save_password_progress_l
ogger.h" | 23 #include "components/autofill/content/renderer/renderer_save_password_progress_l
ogger.h" |
24 #include "components/autofill/core/common/autofill_constants.h" | 24 #include "components/autofill/core/common/autofill_constants.h" |
25 #include "components/autofill/core/common/autofill_util.h" | 25 #include "components/autofill/core/common/autofill_util.h" |
26 #include "components/autofill/core/common/form_field_data.h" | 26 #include "components/autofill/core/common/form_field_data.h" |
27 #include "components/autofill/core/common/password_form.h" | 27 #include "components/autofill/core/common/password_form.h" |
28 #include "components/autofill/core/common/password_form_fill_data.h" | 28 #include "components/autofill/core/common/password_form_fill_data.h" |
| 29 #include "content/public/common/service_registry.h" |
29 #include "content/public/renderer/document_state.h" | 30 #include "content/public/renderer/document_state.h" |
30 #include "content/public/renderer/navigation_state.h" | 31 #include "content/public/renderer/navigation_state.h" |
31 #include "content/public/renderer/render_frame.h" | 32 #include "content/public/renderer/render_frame.h" |
32 #include "content/public/renderer/render_view.h" | 33 #include "content/public/renderer/render_view.h" |
33 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 34 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
34 #include "third_party/WebKit/public/platform/WebVector.h" | 35 #include "third_party/WebKit/public/platform/WebVector.h" |
35 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 36 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
36 #include "third_party/WebKit/public/web/WebDocument.h" | 37 #include "third_party/WebKit/public/web/WebDocument.h" |
37 #include "third_party/WebKit/public/web/WebElement.h" | 38 #include "third_party/WebKit/public/web/WebElement.h" |
38 #include "third_party/WebKit/public/web/WebFormElement.h" | 39 #include "third_party/WebKit/public/web/WebFormElement.h" |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 : content::RenderFrameObserver(render_frame), | 553 : content::RenderFrameObserver(render_frame), |
553 logging_state_active_(false), | 554 logging_state_active_(false), |
554 was_username_autofilled_(false), | 555 was_username_autofilled_(false), |
555 was_password_autofilled_(false) { | 556 was_password_autofilled_(false) { |
556 Send(new AutofillHostMsg_PasswordAutofillAgentConstructed(routing_id())); | 557 Send(new AutofillHostMsg_PasswordAutofillAgentConstructed(routing_id())); |
557 } | 558 } |
558 | 559 |
559 PasswordAutofillAgent::~PasswordAutofillAgent() { | 560 PasswordAutofillAgent::~PasswordAutofillAgent() { |
560 } | 561 } |
561 | 562 |
| 563 void PasswordAutofillAgent::SetAutofillAgent(AutofillAgent* autofill_agent) { |
| 564 autofill_agent_ = autofill_agent; |
| 565 } |
| 566 |
562 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() | 567 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper() |
563 : was_user_gesture_seen_(false) { | 568 : was_user_gesture_seen_(false) { |
564 } | 569 } |
565 | 570 |
566 PasswordAutofillAgent::PasswordValueGatekeeper::~PasswordValueGatekeeper() { | 571 PasswordAutofillAgent::PasswordValueGatekeeper::~PasswordValueGatekeeper() { |
567 } | 572 } |
568 | 573 |
569 void PasswordAutofillAgent::PasswordValueGatekeeper::RegisterElement( | 574 void PasswordAutofillAgent::PasswordValueGatekeeper::RegisterElement( |
570 blink::WebInputElement* element) { | 575 blink::WebInputElement* element) { |
571 if (was_user_gesture_seen_) | 576 if (was_user_gesture_seen_) |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 blink::WebFrame* frame = user_input.document().frame(); | 1409 blink::WebFrame* frame = user_input.document().frame(); |
1405 if (!frame) | 1410 if (!frame) |
1406 return false; | 1411 return false; |
1407 | 1412 |
1408 blink::WebView* webview = frame->view(); | 1413 blink::WebView* webview = frame->view(); |
1409 if (!webview) | 1414 if (!webview) |
1410 return false; | 1415 return false; |
1411 | 1416 |
1412 if (user_input.isPasswordField() && !user_input.isAutofilled() && | 1417 if (user_input.isPasswordField() && !user_input.isAutofilled() && |
1413 !user_input.value().isEmpty()) { | 1418 !user_input.value().isEmpty()) { |
1414 Send(new AutofillHostMsg_HidePopup(routing_id())); | 1419 GetMojoAutofillDriver()->HidePopup(); |
1415 return false; | 1420 return false; |
1416 } | 1421 } |
1417 | 1422 |
1418 FormData form; | 1423 FormData form; |
1419 FormFieldData field; | 1424 FormFieldData field; |
1420 form_util::FindFormAndFieldForFormControlElement(user_input, &form, &field); | 1425 form_util::FindFormAndFieldForFormControlElement(user_input, &form, &field); |
1421 | 1426 |
1422 int options = 0; | 1427 int options = 0; |
1423 if (show_all) | 1428 if (show_all) |
1424 options |= SHOW_ALL; | 1429 options |= SHOW_ALL; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 provisionally_saved_form_ = std::move(password_form); | 1478 provisionally_saved_form_ = std::move(password_form); |
1474 } | 1479 } |
1475 | 1480 |
1476 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() { | 1481 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() { |
1477 return provisionally_saved_form_ && | 1482 return provisionally_saved_form_ && |
1478 !provisionally_saved_form_->username_value.empty() && | 1483 !provisionally_saved_form_->username_value.empty() && |
1479 !(provisionally_saved_form_->password_value.empty() && | 1484 !(provisionally_saved_form_->password_value.empty() && |
1480 provisionally_saved_form_->new_password_value.empty()); | 1485 provisionally_saved_form_->new_password_value.empty()); |
1481 } | 1486 } |
1482 | 1487 |
| 1488 const mojom::AutofillDriverPtr& PasswordAutofillAgent::GetMojoAutofillDriver() { |
| 1489 DCHECK(autofill_agent_); |
| 1490 return autofill_agent_->GetMojoAutofillDriver(); |
| 1491 } |
| 1492 |
1483 } // namespace autofill | 1493 } // namespace autofill |
OLD | NEW |