Commit f8b3f701 authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

[Android password settings] Fix reauth explanation

If the user tries to view or copy passwords in Chrome on Android, the
settings page asks them to reauthenticate. The explanation on the
reauthentication screen is currently confusing, telling the user that
they need to reauthenticate to "continue setting up [their] phone".

This CL changes that message to mirror better the user's original
intention, mentioning copying or viewing as appropriate.

The change has no test. While the instrumentation tests are able to trigger the
reauthentication screen, there seems to be no way to read UI elements on that,
because it is being rendered by Android and not by Chrome.

Bug: 788749
Change-Id: I06c25c837606aa427cb5cb6db39e8e3fbeb5aa07
Reviewed-on: https://chromium-review.googlesource.com/796630
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520197}
parent c398e285
......@@ -365,8 +365,18 @@ public class PasswordEntryEditor extends Fragment {
PASSWORD_ACTION_BOUNDARY);
}
private void displayReauthenticationFragment() {
/**
* Initiates the reauthentication prompt with a given description.
*
* @param descriptionId The resource ID of the string to be displayed to explain the reason for
* the reauthentication.
*/
private void displayReauthenticationFragment(int descriptionId) {
Fragment passwordReauthentication = new PasswordReauthenticationFragment();
Bundle args = new Bundle();
args.putInt(PasswordReauthenticationFragment.DESCRIPTION_ID, descriptionId);
passwordReauthentication.setArguments(args);
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(
......@@ -391,7 +401,7 @@ public class PasswordEntryEditor extends Fragment {
copyPassword();
} else {
mCopyButtonPressed = true;
displayReauthenticationFragment();
displayReauthenticationFragment(R.string.lockscreen_description_copy);
}
}
});
......@@ -412,7 +422,7 @@ public class PasswordEntryEditor extends Fragment {
displayPassword();
} else {
mViewButtonPressed = true;
displayReauthenticationFragment();
displayReauthenticationFragment(R.string.lockscreen_description_view);
}
}
});
......
......@@ -14,10 +14,12 @@ import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import org.chromium.chrome.R;
/** Show the lock screen confirmation and lock the screen. */
public class PasswordReauthenticationFragment extends Fragment {
// The key for the description argument, which is used to retrieve an explanation of the
// reauthentication prompt to the user.
public static final String DESCRIPTION_ID = "description";
protected static final int CONFIRM_DEVICE_CREDENTIAL_REQUEST_CODE = 2;
private boolean mPreventLockDevice;
......@@ -59,8 +61,13 @@ public class PasswordReauthenticationFragment extends Fragment {
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
KeyguardManager keyguardManager =
(KeyguardManager) getActivity().getSystemService(Context.KEYGUARD_SERVICE);
Intent intent = keyguardManager.createConfirmDeviceCredentialIntent(
null /* title */, getString(R.string.lockscreen_description) /* description */);
final int resourceId = getArguments().getInt(DESCRIPTION_ID, 0);
// Forgetting to set the DESCRIPTION_ID is an error on the callsite.
assert resourceId != 0;
// Set title to null to use the system default title which is adapted to the particular type
// of device lock which the user set up.
Intent intent =
keyguardManager.createConfirmDeviceCredentialIntent(null, getString(resourceId));
if (intent != null) {
startActivityForResult(intent, CONFIRM_DEVICE_CREDENTIAL_REQUEST_CODE);
return;
......
......@@ -484,8 +484,11 @@ CHAR-LIMIT guidelines:
</message>
<!-- Lock Screen Fragment -->
<message name="IDS_LOCKSCREEN_DESCRIPTION" desc='Text on lockscreen explaining to user that they need to unlock the device to continue setup.'>
Unlock to continue setting up your phone
<message name="IDS_LOCKSCREEN_DESCRIPTION_COPY" desc="When a user attempts to copy a password for a particular website into clipboard in Chrome's settings, Chrome launches a lock screen to verify the user's identity and displays the following explanation.">
Unlock to copy your password
</message>
<message name="IDS_LOCKSCREEN_DESCRIPTION_VIEW" desc="When a user attempts to view a password for a particular website in Chrome's settings, Chrome launches a lock screen to verify the user's identity and displays the following explanation.">
Unlock to view your password
</message>
<!-- Languages preferences -->
......
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