Commit 720e726e authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[Passwords] Add "Edit password" menu item

This change adds an "Edit password" menu item to the compromised
credential view on Android. Furthermore it adds a corresponding `onEdit`
to PasswordCheckCoordinator.CredentialEventHandler, hooks up the
mediator and adds a test.

Translation Screenshot:
https://storage.cloud.google.com/chromium-translation-screenshots/29fbfcf5121721e305692723d8531f61540e5065

Bug: 1114720
Change-Id: I7166c3c9c16555fad99f4dc37c5865b5b584881f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346248Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796743}
parent a28ec603
......@@ -47,6 +47,12 @@ class PasswordCheckCoordinator implements PasswordCheckComponentUi, LifecycleObs
* Blueprint for a class that handles interactions with credentials.
*/
interface CredentialEventHandler {
/**
* Edits the given Credential in the password store.
* @param credential A {@link CompromisedCredential} to be edited.
*/
void onEdit(CompromisedCredential credential);
/**
* Removes the given Credential from the password store.
* @param credential A {@link CompromisedCredential} to be removed.
......
......@@ -143,6 +143,11 @@ class PasswordCheckMediator
.build()));
}
@Override
public void onEdit(CompromisedCredential credential) {
// TODO(crbug.com/1114720): Implement.
}
@Override
public void onRemove(CompromisedCredential credential) {
mModel.set(DELETION_ORIGIN, credential.getOriginUrl());
......
......@@ -438,11 +438,15 @@ class PasswordCheckViewBinder {
private static ListMenu createCredentialMenu(Context context, CompromisedCredential credential,
PasswordCheckCoordinator.CredentialEventHandler credentialHandler) {
MVCListAdapter.ModelList menuItems = new MVCListAdapter.ModelList();
menuItems.add(BasicListMenu.buildMenuListItem(
R.string.password_check_credential_menu_item_edit_button_caption, 0, 0, true));
menuItems.add(
BasicListMenu.buildMenuListItem(org.chromium.chrome.R.string.remove, 0, 0, true));
ListMenu.Delegate delegate = (listModel) -> {
int textId = listModel.get(ListMenuItemProperties.TITLE_ID);
if (textId == org.chromium.chrome.R.string.remove) {
if (textId == R.string.password_check_credential_menu_item_edit_button_caption) {
credentialHandler.onEdit(credential);
} else if (textId == org.chromium.chrome.R.string.remove) {
credentialHandler.onRemove(credential);
} else {
assert false : "No action defined for " + context.getString(textId);
......
......@@ -246,6 +246,11 @@
Delete password
</message>
<!-- Password Check credential menu item strings -->
<message name="IDS_PASSWORD_CHECK_CREDENTIAL_MENU_ITEM_EDIT_BUTTON_CAPTION" desc="Caption for the menu button allowing to edit a compromised credential.">
Edit password
</message>
<!-- Utility string to show the timestamp -->
<message name="IDS_PASSWORD_CHECK_JUST_NOW" desc="A time label for a check that happened just now. For example 'Checked passwords · Just now'">
Just now
......
......@@ -453,6 +453,22 @@ public class PasswordCheckViewTest {
waitForEvent(mMockHandler).onChangePasswordWithScriptButtonClick(eq(SCRIPTED));
}
@Test
@MediumTest
public void testClickingEditInMoreMenuTriggersHandler() {
runOnUiThreadBlocking(() -> mModel.get(ITEMS).add(buildCredentialItem(ANA)));
waitForListViewToHaveLength(1);
TouchCommon.singleClickView(getCredentialMoreButtonAt(0));
onView(withText(R.string.password_check_credential_menu_item_edit_button_caption))
.inRoot(withDecorView(
not(is(mPasswordCheckView.getActivity().getWindow().getDecorView()))))
.perform(click());
verify(mMockHandler).onEdit(eq(ANA));
}
@Test
@MediumTest
public void testClickingDeleteInMoreMenuTriggersHandler() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment