blob: ac5ae0c91933b6b02beb25a57b6907518097b1aa [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.password_manager;
import android.content.Context;
import android.os.Bundle;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.browser.settings.SettingsLauncher;
/** A helper class for showing PasswordSettings. */
public class PasswordManagerHelper {
// Key for the argument with which PasswordsSettings will be launched. The value for
// this argument should be part of the ManagePasswordsReferrer enum, which contains
// all points of entry to the passwords settings.
public static final String MANAGE_PASSWORDS_REFERRER = "manage-passwords-referrer";
// |PasswordSettings| full class name to open the fragment. Will be changed to
// |PasswordSettings.class.getName()| once it's modularized.
private static final String PASSWORD_SETTINGS_CLASS =
"org.chromium.chrome.browser.password_manager.settings.PasswordSettings";
/**
* Launches the password settings in or the Google Password Manager if available.
* @param context used to show the UI to manage passwords.
*/
public static void showPasswordSettings(Context context, @ManagePasswordsReferrer int referrer,
SettingsLauncher settingsLauncher) {
RecordHistogram.recordEnumeratedHistogram("PasswordManager.ManagePasswordsReferrer",
referrer, ManagePasswordsReferrer.MAX_VALUE + 1);
Bundle fragmentArgs = new Bundle();
fragmentArgs.putInt(MANAGE_PASSWORDS_REFERRER, referrer);
context.startActivity(settingsLauncher.createSettingsActivityIntent(
context, PASSWORD_SETTINGS_CLASS, fragmentArgs));
}
}