| 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/content/renderer/renderer_save_password_progress_l
ogger.h" |
| 16 #include "components/autofill/core/common/form_field_data.h" | 16 #include "components/autofill/core/common/form_field_data.h" |
| 17 #include "components/autofill/core/common/password_autofill_util.h" | 17 #include "components/autofill/core/common/password_autofill_util.h" |
| 18 #include "components/autofill/core/common/password_form.h" | 18 #include "components/autofill/core/common/password_form.h" |
| 19 #include "components/autofill/core/common/password_form_fill_data.h" | 19 #include "components/autofill/core/common/password_form_fill_data.h" |
| 20 #include "content/public/common/page_transition_types.h" | |
| 21 #include "content/public/renderer/document_state.h" | 20 #include "content/public/renderer/document_state.h" |
| 22 #include "content/public/renderer/navigation_state.h" | 21 #include "content/public/renderer/navigation_state.h" |
| 23 #include "content/public/renderer/render_view.h" | 22 #include "content/public/renderer/render_view.h" |
| 24 #include "third_party/WebKit/public/platform/WebVector.h" | 23 #include "third_party/WebKit/public/platform/WebVector.h" |
| 25 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 24 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
| 26 #include "third_party/WebKit/public/web/WebDocument.h" | 25 #include "third_party/WebKit/public/web/WebDocument.h" |
| 27 #include "third_party/WebKit/public/web/WebElement.h" | 26 #include "third_party/WebKit/public/web/WebElement.h" |
| 28 #include "third_party/WebKit/public/web/WebFormElement.h" | 27 #include "third_party/WebKit/public/web/WebFormElement.h" |
| 29 #include "third_party/WebKit/public/web/WebInputEvent.h" | 28 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 30 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 29 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 31 #include "third_party/WebKit/public/web/WebNode.h" | 30 #include "third_party/WebKit/public/web/WebNode.h" |
| 32 #include "third_party/WebKit/public/web/WebNodeList.h" | 31 #include "third_party/WebKit/public/web/WebNodeList.h" |
| 33 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 32 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 34 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 33 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 35 #include "third_party/WebKit/public/web/WebView.h" | 34 #include "third_party/WebKit/public/web/WebView.h" |
| 35 #include "ui/base/page_transition_types.h" |
| 36 #include "ui/events/keycodes/keyboard_codes.h" | 36 #include "ui/events/keycodes/keyboard_codes.h" |
| 37 #include "url/gurl.h" | 37 #include "url/gurl.h" |
| 38 | 38 |
| 39 namespace autofill { | 39 namespace autofill { |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 // The size above which we stop triggering autocomplete. | 42 // The size above which we stop triggering autocomplete. |
| 43 static const size_t kMaximumTextSizeForAutocomplete = 1000; | 43 static const size_t kMaximumTextSizeForAutocomplete = 1000; |
| 44 | 44 |
| 45 // Maps element names to the actual elements to simplify form filling. | 45 // Maps element names to the actual elements to simplify form filling. |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 form_frame == frame); | 721 form_frame == frame); |
| 722 } | 722 } |
| 723 // Bug fix for crbug.com/368690. isProcessingUserGesture() is false when | 723 // Bug fix for crbug.com/368690. isProcessingUserGesture() is false when |
| 724 // the user is performing actions outside the page (e.g. typed url, | 724 // the user is performing actions outside the page (e.g. typed url, |
| 725 // history navigation). We don't want to trigger saving in these cases. | 725 // history navigation). We don't want to trigger saving in these cases. |
| 726 content::DocumentState* document_state = | 726 content::DocumentState* document_state = |
| 727 content::DocumentState::FromDataSource( | 727 content::DocumentState::FromDataSource( |
| 728 frame->provisionalDataSource()); | 728 frame->provisionalDataSource()); |
| 729 content::NavigationState* navigation_state = | 729 content::NavigationState* navigation_state = |
| 730 document_state->navigation_state(); | 730 document_state->navigation_state(); |
| 731 if (content::PageTransitionIsWebTriggerable( | 731 if (ui::PageTransitionIsWebTriggerable( |
| 732 navigation_state->transition_type()) && | 732 navigation_state->transition_type()) && |
| 733 !blink::WebUserGestureIndicator::isProcessingUserGesture()) { | 733 !blink::WebUserGestureIndicator::isProcessingUserGesture()) { |
| 734 // If onsubmit has been called, try and save that form. | 734 // If onsubmit has been called, try and save that form. |
| 735 if (provisionally_saved_forms_[form_frame].get()) { | 735 if (provisionally_saved_forms_[form_frame].get()) { |
| 736 if (logger) { | 736 if (logger) { |
| 737 logger->LogPasswordForm( | 737 logger->LogPasswordForm( |
| 738 Logger::STRING_PROVISIONALLY_SAVED_FORM_FOR_FRAME, | 738 Logger::STRING_PROVISIONALLY_SAVED_FORM_FOR_FRAME, |
| 739 *provisionally_saved_forms_[form_frame]); | 739 *provisionally_saved_forms_[form_frame]); |
| 740 } | 740 } |
| 741 Send(new AutofillHostMsg_PasswordFormSubmitted( | 741 Send(new AutofillHostMsg_PasswordFormSubmitted( |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); | 1134 scoped_ptr<PasswordForm> password_form(CreatePasswordForm(form)); |
| 1135 if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD && | 1135 if (!password_form || (restriction == RESTRICTION_NON_EMPTY_PASSWORD && |
| 1136 password_form->password_value.empty() && | 1136 password_form->password_value.empty() && |
| 1137 password_form->new_password_value.empty())) { | 1137 password_form->new_password_value.empty())) { |
| 1138 return; | 1138 return; |
| 1139 } | 1139 } |
| 1140 provisionally_saved_forms_[frame].reset(password_form.release()); | 1140 provisionally_saved_forms_[frame].reset(password_form.release()); |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 } // namespace autofill | 1143 } // namespace autofill |
| OLD | NEW |