forked from crosswalk-project/chromium-crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not prompt and/or create copies when Android logins are filled int…
…o websites. Presently, when logins from Android apps are filled into the corresponding websites and are used for a successful login, the user is prompted to save a new credential, and ultimately a copy of the credential, keyed by the web site, gets saved to the password store. This is a very confusing UX, and also results in duplicate logins being created. Later, these can lead to an out-of-date password stored for the Android app if the Web password is ever updated in the future. Instead, in this scenario, do not prompt at all, do not save any new credentials, but simply update the usage count of the existing Android credential in-place while leaving the other meta-attributes untouched. BUG=540609 Review URL: https://codereview.chromium.org/1571813002 Cr-Commit-Position: refs/heads/master@{#368421}
- Loading branch information
engedy
authored and
Commit bot
committed
Jan 8, 2016
1 parent
ee9ee48
commit 90098fd
Showing
3 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1321,25 +1321,56 @@ TEST_F(PasswordFormManagerTest, AndroidCredentialsAreAutofilled) { | |
EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_)); | ||
|
||
// Although Android-based credentials are treated similarly to PSL-matched | ||
// credentials in most respects, they should be autofilled as opposed to be | ||
// credentials in some respects, they should be autofilled as opposed to be | ||
// filled on username-select. | ||
ScopedVector<PasswordForm> simulated_results; | ||
simulated_results.push_back(new PasswordForm()); | ||
simulated_results[0]->signon_realm = "android://[email protected]"; | ||
simulated_results[0]->origin = observed_form()->origin; | ||
simulated_results[0]->username_value = saved_match()->username_value; | ||
simulated_results[0]->password_value = saved_match()->password_value; | ||
|
||
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore(); | ||
PasswordForm android_login; | ||
android_login.signon_realm = "android://[email protected]"; | ||
android_login.origin = GURL("android://[email protected]/"); | ||
android_login.is_affiliation_based_match = true; | ||
android_login.username_value = saved_match()->username_value; | ||
android_login.password_value = saved_match()->password_value; | ||
android_login.preferred = false; | ||
android_login.times_used = 42; | ||
|
||
autofill::PasswordFormFillData fill_data; | ||
EXPECT_CALL(*client()->mock_driver(), FillPasswordForm(_)) | ||
.WillOnce(SaveArg<0>(&fill_data)); | ||
|
||
ScopedVector<PasswordForm> simulated_results; | ||
simulated_results.push_back(new PasswordForm(android_login)); | ||
form_manager()->SimulateFetchMatchingLoginsFromPasswordStore(); | ||
form_manager()->OnGetPasswordStoreResults(std::move(simulated_results)); | ||
EXPECT_TRUE(fill_data.additional_logins.empty()); | ||
EXPECT_FALSE(fill_data.wait_for_username); | ||
EXPECT_EQ(1u, form_manager()->best_matches().size()); | ||
|
||
// When the user submits the filled form, no copy of the credential should be | ||
// created, instead the usage counter of the original credential should be | ||
// incremented in-place, as if it were a regular credential for that website. | ||
PasswordForm credential(*observed_form()); | ||
credential.username_value = android_login.username_value; | ||
credential.password_value = android_login.password_value; | ||
credential.preferred = true; | ||
form_manager()->ProvisionallySave( | ||
credential, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); | ||
EXPECT_FALSE(form_manager()->IsNewLogin()); | ||
|
||
PasswordForm updated_credential; | ||
EXPECT_CALL(*mock_store(), UpdateLogin(_)) | ||
.WillOnce(testing::SaveArg<0>(&updated_credential)); | ||
EXPECT_CALL(*mock_store(), UpdateLoginWithPrimaryKey(_, _)).Times(0); | ||
EXPECT_CALL(*mock_store(), AddLogin(_)).Times(0); | ||
form_manager()->Save(); | ||
Mock::VerifyAndClearExpectations(mock_store()); | ||
|
||
EXPECT_EQ(android_login.username_value, updated_credential.username_value); | ||
EXPECT_EQ(android_login.password_value, updated_credential.password_value); | ||
EXPECT_EQ(android_login.times_used + 1, updated_credential.times_used); | ||
EXPECT_TRUE(updated_credential.preferred); | ||
EXPECT_EQ(GURL(), updated_credential.action); | ||
EXPECT_EQ(base::string16(), updated_credential.username_element); | ||
EXPECT_EQ(base::string16(), updated_credential.password_element); | ||
EXPECT_EQ(base::string16(), updated_credential.submit_element); | ||
} | ||
|
||
// Credentials saved through Android apps should always be shown in the drop- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters