Skip to content

Commit

Permalink
[UPMCleanup] Remove usesUnifiedPasswordManagerUi helper
Browse files Browse the repository at this point in the history
The feature is launched, so this helper always returns true.

Bug: 1439191
Change-Id: I7f4e27d3a71ecdcbcb74248b62d0c48ec74b9fca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4753420
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Ioana Pandele <ioanap@chromium.org>
Reviewed-by: Anna Tsvirchkova <atsvirchkova@google.com>
Reviewed-by: Martin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1187734}
  • Loading branch information
Ioana Pandele authored and Chromium LUCI CQ committed Aug 24, 2023
1 parent dddcd30 commit 692a116
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// found in the LICENSE file.
package org.chromium.chrome.browser.password_manager;

import static org.chromium.chrome.browser.password_manager.PasswordManagerHelper.usesUnifiedPasswordManagerUI;

import android.app.PendingIntent;

import androidx.annotation.Nullable;
Expand Down Expand Up @@ -64,8 +62,6 @@ static int getApiErrorCode(Exception exception) {
}

static void handleResolvableApiException(ResolvableApiException exception) {
if (!usesUnifiedPasswordManagerUI()) return;

// No special resolution for the authentication errors is needed since the user has already
// been prompted to reauthenticate by Google services and Sync in Chrome.
if (exception.getStatusCode() == ChromeSyncStatusCode.AUTH_ERROR_RESOLVABLE) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package org.chromium.chrome.browser.password_manager;

import static org.chromium.chrome.browser.flags.ChromeFeatureList.PASSKEY_MANAGEMENT_USING_ACCOUNT_SETTINGS_ANDROID;
import static org.chromium.chrome.browser.flags.ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID;

import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
Expand Down Expand Up @@ -206,8 +205,7 @@ public static boolean canUseUpm() {
Profile profile = Profile.getLastUsedRegularProfile();
SyncService syncService = SyncServiceFactory.getForProfile(profile);
PrefService prefService = UserPrefs.get(profile);
return PasswordManagerHelper.usesUnifiedPasswordManagerUI() && syncService != null
&& hasChosenToSyncPasswords(syncService)
return syncService != null && hasChosenToSyncPasswords(syncService)
&& !prefService.getBoolean(
Pref.UNENROLLED_FROM_GOOGLE_MOBILE_SERVICES_DUE_TO_ERRORS)
&& PasswordManagerBackendSupportHelper.getInstance().isBackendPresent();
Expand All @@ -224,8 +222,7 @@ && hasChosenToSyncPasswords(syncService)
* @return True if the AccountSettings intent is available for use, false otherwise.
*/
public static boolean canUseAccountSettings() {
return PasswordManagerHelper.usesUnifiedPasswordManagerUI()
&& ChromeFeatureList.isEnabled(PASSKEY_MANAGEMENT_USING_ACCOUNT_SETTINGS_ANDROID)
return ChromeFeatureList.isEnabled(PASSKEY_MANAGEMENT_USING_ACCOUNT_SETTINGS_ANDROID)
&& PasswordManagerBackendSupportHelper.getInstance().isBackendPresent();
}

Expand Down Expand Up @@ -375,30 +372,9 @@ public static boolean isSyncingPasswordsWithNoCustomPassphrase(SyncService syncS
return true;
}

public static boolean usesUnifiedPasswordManagerUI() {
if (!ChromeFeatureList.isEnabled(UNIFIED_PASSWORD_MANAGER_ANDROID)) return false;
@UpmExperimentVariation
int variation = ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
UNIFIED_PASSWORD_MANAGER_ANDROID, UPM_VARIATION_FEATURE_PARAM,
UpmExperimentVariation.ENABLE_FOR_SYNCING_USERS);
switch (variation) {
case UpmExperimentVariation.ENABLE_FOR_SYNCING_USERS:
case UpmExperimentVariation.ENABLE_FOR_ALL_USERS:
return true;
case UpmExperimentVariation.SHADOW_SYNCING_USERS:
case UpmExperimentVariation.ENABLE_ONLY_BACKEND_FOR_SYNCING_USERS:
return false;
}
assert false : "Whether to use UI is undefined for variation: " + variation;
return false;
}

// TODO(http://crbug.com/1371422): Remove method and manage eviction from native code
// as this is covered by chrome://password-manager-internals page.
public static void resetUpmUnenrollment() {
// Exit early if Chrome doesn't need UPM UI. Assumes the unenroll pref isn't included in
// the usesUnifiedPasswordManagementUI check.
if (!PasswordManagerHelper.usesUnifiedPasswordManagerUI()) return;
PrefService prefs = UserPrefs.get(Profile.getLastUsedRegularProfile());

// Exit early if the user is not unenrolled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@

import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.base.test.util.Batch;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.password_manager.PasswordStoreAndroidBackend.BackendException;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures;

/**
* Tests for the utility methods used by various parts of the password manager backend (e.g.
Expand All @@ -38,7 +36,6 @@
@RunWith(BaseRobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@Batch(Batch.PER_CLASS)
@EnableFeatures(ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID)
public class PasswordManagerAndroidBackendUtilTest {
@Rule
public TestRule mProcessor = new Features.JUnitProcessor();
Expand Down

0 comments on commit 692a116

Please sign in to comment.