| 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 | 831 |
| 832 if (iter == login_to_password_info_.end()) | 832 if (iter == login_to_password_info_.end()) |
| 833 return false; | 833 return false; |
| 834 | 834 |
| 835 *password_info = &iter->second; | 835 *password_info = &iter->second; |
| 836 return true; | 836 return true; |
| 837 } | 837 } |
| 838 | 838 |
| 839 bool PasswordAutofillAgent::ShowSuggestions( | 839 bool PasswordAutofillAgent::ShowSuggestions( |
| 840 const blink::WebInputElement& element, | 840 const blink::WebInputElement& element, |
| 841 bool show_all) { | 841 bool show_all, |
| 842 bool generation_popup_showing) { |
| 842 const blink::WebInputElement* username_element; | 843 const blink::WebInputElement* username_element; |
| 843 PasswordInfo* password_info; | 844 PasswordInfo* password_info; |
| 844 if (!FindPasswordInfoForElement(element, &username_element, &password_info)) | 845 if (!FindPasswordInfoForElement(element, &username_element, &password_info)) |
| 845 return false; | 846 return false; |
| 846 | 847 |
| 847 // If autocomplete='off' is set on the form elements, no suggestion dialog | 848 // If autocomplete='off' is set on the form elements, no suggestion dialog |
| 848 // should be shown. However, return |true| to indicate that this is a known | 849 // should be shown. However, return |true| to indicate that this is a known |
| 849 // password form and that the request to show suggestions has been handled (as | 850 // password form and that the request to show suggestions has been handled (as |
| 850 // a no-op). | 851 // a no-op). |
| 851 if (!IsElementAutocompletable(element) || | 852 if (!IsElementAutocompletable(element) || |
| 852 !IsElementAutocompletable(password_info->password_field)) | 853 !IsElementAutocompletable(password_info->password_field)) |
| 853 return true; | 854 return true; |
| 854 | 855 |
| 855 bool username_is_available = | 856 bool username_is_available = |
| 856 !username_element->isNull() && IsElementEditable(*username_element); | 857 !username_element->isNull() && IsElementEditable(*username_element); |
| 857 // If the element is a password field, a popup should only be shown if there | 858 // If the element is a password field, a popup should only be shown if there |
| 858 // is no username or the corresponding username element is not editable since | 859 // is no username or the corresponding username element is not editable since |
| 859 // it is only in that case that the username element does not have a | 860 // it is only in that case that the username element does not have a |
| 860 // suggestions popup. | 861 // suggestions popup. |
| 861 if (element.isPasswordField() && username_is_available) | 862 if (element.isPasswordField() && username_is_available) |
| 862 return true; | 863 return true; |
| 863 | 864 |
| 865 UMA_HISTOGRAM_BOOLEAN( |
| 866 "PasswordManager.AutocompletePopupSuppressedByGeneration", |
| 867 generation_popup_showing); |
| 868 |
| 869 if (generation_popup_showing) |
| 870 return false; |
| 871 |
| 864 // Chrome should never show more than one account for a password element since | 872 // Chrome should never show more than one account for a password element since |
| 865 // this implies that the username element cannot be modified. Thus even if | 873 // this implies that the username element cannot be modified. Thus even if |
| 866 // |show_all| is true, check if the element in question is a password element | 874 // |show_all| is true, check if the element in question is a password element |
| 867 // for the call to ShowSuggestionPopup. | 875 // for the call to ShowSuggestionPopup. |
| 868 return ShowSuggestionPopup( | 876 return ShowSuggestionPopup( |
| 869 password_info->fill_data, | 877 password_info->fill_data, |
| 870 username_element->isNull() ? element : *username_element, | 878 username_element->isNull() ? element : *username_element, |
| 871 show_all && !element.isPasswordField(), element.isPasswordField()); | 879 show_all && !element.isPasswordField(), element.isPasswordField()); |
| 872 } | 880 } |
| 873 | 881 |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { | 1480 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { |
| 1473 agent_->DidStopLoading(); | 1481 agent_->DidStopLoading(); |
| 1474 } | 1482 } |
| 1475 | 1483 |
| 1476 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: | 1484 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: |
| 1477 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { | 1485 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { |
| 1478 agent_->LegacyDidStartProvisionalLoad(navigated_frame); | 1486 agent_->LegacyDidStartProvisionalLoad(navigated_frame); |
| 1479 } | 1487 } |
| 1480 | 1488 |
| 1481 } // namespace autofill | 1489 } // namespace autofill |
| OLD | NEW |