Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #import "ios/chrome/browser/passwords/password_controller.h" | 5 #import "ios/chrome/browser/passwords/password_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 | 684 |
| 685 // Determine which password is the main one, and which is | 685 // Determine which password is the main one, and which is |
| 686 // an old password (e.g on a "make new password" form), if any. | 686 // an old password (e.g on a "make new password" form), if any. |
| 687 // TODO(crbug.com/564578): Make this compatible with other platforms. | 687 // TODO(crbug.com/564578): Make this compatible with other platforms. |
| 688 switch (passwordCount) { | 688 switch (passwordCount) { |
| 689 case 1: | 689 case 1: |
| 690 form->password_element = elements[0]; | 690 form->password_element = elements[0]; |
| 691 form->password_value = values[0]; | 691 form->password_value = values[0]; |
| 692 break; | 692 break; |
| 693 case 2: { | 693 case 2: { |
| 694 if (values[0] == values[1]) { | 694 if (values[0] == values[1]) { |
|
dvadym
2016/07/05 15:42:18
Could you please add check if values are empty as
Jackie Quinn
2016/07/06 07:39:28
Done.
| |
| 695 // Treat two identical passwords as a single password. | 695 // Treat two identical passwords as a single password new password, with |
| 696 // confirmation. This can be either be a sign-up form or a password | |
| 697 // change form that does not ask for a new password. | |
| 698 form->new_password_element = elements[0]; | |
| 699 form->new_password_value = values[0]; | |
| 700 } else { | |
| 701 // Assume first is old password, second is new (no choice but to guess). | |
| 696 form->password_element = elements[0]; | 702 form->password_element = elements[0]; |
| 697 form->password_value = values[0]; | 703 form->password_value = values[0]; |
| 698 } else { | 704 form->new_password_element = elements[1]; |
| 699 // Assume first is old password, second is new (no choice but to guess). | 705 form->new_password_value = values[1]; |
| 700 form->new_password_element = elements[0]; | |
| 701 form->new_password_value = values[0]; | |
| 702 form->password_element = elements[1]; | |
| 703 form->password_value = values[1]; | |
| 704 } | 706 } |
| 705 break; | 707 break; |
| 706 default: | 708 default: |
| 707 if (values[0] == values[1] && values[0] == values[2]) { | 709 if (values[0] == values[1] && values[0] == values[2]) { |
| 708 // All three passwords the same? Just treat as one and hope. | 710 // All three passwords the same? This does not make sense, do not |
|
dvadym
2016/07/05 15:42:18
Could you please add check if values are empty as
Jackie Quinn
2016/07/06 07:39:28
Done.
| |
| 711 // add the password element. | |
| 712 break; | |
| 713 } else if (values[0] == values[1]) { | |
| 714 // First two the same and the third different implies that the old | |
| 715 // password is the duplicated one. | |
| 709 form->password_element = elements[0]; | 716 form->password_element = elements[0]; |
| 710 form->password_value = values[0]; | 717 form->password_value = values[0]; |
| 711 } else if (values[0] == values[1]) { | 718 form->new_password_element = elements[2]; |
| 712 // Two the same and one different -> old password is the duplicated | 719 form->new_password_value = values[2]; |
| 713 // one. | |
| 714 form->new_password_element = elements[0]; | |
| 715 form->new_password_value = values[0]; | |
| 716 form->password_element = elements[2]; | |
| 717 form->password_value = values[2]; | |
| 718 } else if (values[1] == values[2]) { | 720 } else if (values[1] == values[2]) { |
| 719 // Two the same and one different -> new password is the duplicated | 721 // Two the same and one different -> new password is the duplicated |
| 720 // one. | 722 // one. |
| 721 form->new_password_element = elements[0]; | 723 form->password_element = elements[0]; |
| 722 form->new_password_value = values[0]; | 724 form->password_value = values[0]; |
| 723 form->password_element = elements[1]; | 725 form->new_password_element = elements[1]; |
| 724 form->password_value = values[1]; | 726 form->new_password_value = values[1]; |
| 725 } else { | 727 } else { |
| 726 // Three different passwords, or first and last match with middle | 728 // Three different passwords, or first and last match with middle |
| 727 // different. No idea which is which, so no luck. | 729 // different. No idea which is which, so no luck. |
| 728 } | 730 } |
| 729 break; | 731 break; |
| 730 } | 732 } |
| 731 } | 733 } |
| 732 | 734 |
| 733 // Fill in as much data about the fields as is required for password | 735 // Fill in as much data about the fields as is required for password |
| 734 // generation. | 736 // generation. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 823 | 825 |
| 824 - (PasswordManager*)passwordManager { | 826 - (PasswordManager*)passwordManager { |
| 825 return passwordManager_.get(); | 827 return passwordManager_.get(); |
| 826 } | 828 } |
| 827 | 829 |
| 828 - (JsPasswordManager*)passwordJsManager { | 830 - (JsPasswordManager*)passwordJsManager { |
| 829 return passwordJsManager_; | 831 return passwordJsManager_; |
| 830 } | 832 } |
| 831 | 833 |
| 832 @end | 834 @end |
| OLD | NEW |