Commit 4ad192a6 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[Passwords] Add stubs for native Password Checkup on Android

This change adds stubs for integrating the native Password Checkup on
Android for the Leak Detection feature.

Bug: 986317
Change-Id: Idf57d8a812ee11e6d862dbd68ecb54ea58aff738
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1773221Reviewed-by: default avatarIoana Pandele <ioanap@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691036}
parent 96609f37
......@@ -16,4 +16,15 @@ public interface GooglePasswordManagerUIProvider {
* @return Whether showing the Google Password Manager UI was possible or not.
**/
boolean showGooglePasswordManager(Activity activity);
/**
* Launches the Password Checkup if possible.
*
* @param activity The activity from which to launch the Password Checkup.
* @return Whether launching the Password Checkup was possible or not.
**/
// TODO(crbug.com/986317): Drop the default action once the method is implemented downstream.
default boolean launchPasswordCheckup(Activity activity) {
return false;
}
}
......@@ -7,6 +7,7 @@ import android.content.Intent;
import android.net.Uri;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.ui.base.WindowAndroid;
......@@ -16,9 +17,18 @@ import org.chromium.ui.base.WindowAndroid;
public class PasswordCheckupLauncher {
@CalledByNative
private static void launchCheckup(String checkupUrl, WindowAndroid windowAndroid) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(checkupUrl));
ChromeActivity activity = (ChromeActivity) windowAndroid.getActivity().get();
if (tryLaunchingNativePasswordCheckup(activity)) return;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(checkupUrl));
intent.setPackage(activity.getPackageName());
activity.startActivity(intent);
}
private static boolean tryLaunchingNativePasswordCheckup(ChromeActivity activity) {
GooglePasswordManagerUIProvider googlePasswordManagerUIProvider =
AppHooks.get().createGooglePasswordManagerUIProvider();
if (googlePasswordManagerUIProvider == null) return false;
// TODO(crbug.com/986317): Add check for minimum Google Play Services version.
return googlePasswordManagerUIProvider.launchPasswordCheckup(activity);
}
}
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