Commit e8a28ed3 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

PasswordManager: Introduce enum PasswordAccountStorageUserState

The PasswordAccountStorageUserState covers the sign-in state and
account storage opt-in state of the current user. It will be used for
metrics (but is not used yet in this CL).

Bug: 1063852
Change-Id: I85a0e5f310e6b766f8fcc7986c1170cdb9580bc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2149358
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759630}
parent 5767abca
...@@ -574,4 +574,36 @@ void ClearAccountStorageSettingsForAllUsers(PrefService* pref_service) { ...@@ -574,4 +574,36 @@ void ClearAccountStorageSettingsForAllUsers(PrefService* pref_service) {
password_manager::prefs::kAccountStoragePerAccountSettings); password_manager::prefs::kAccountStoragePerAccountSettings);
} }
PasswordAccountStorageUserState ComputePasswordAccountStorageUserState(
const PrefService* pref_service,
const syncer::SyncService* sync_service) {
if (sync_service->IsSyncFeatureEnabled())
return PasswordAccountStorageUserState::kSyncUser;
if (sync_service->HasDisableReason(
syncer::SyncService::DisableReason::DISABLE_REASON_NOT_SIGNED_IN)) {
// Signed out. Check if any account storage opt-in exists.
return ShouldShowAccountStorageReSignin(pref_service, sync_service)
? PasswordAccountStorageUserState::kSignedOutAccountStoreUser
: PasswordAccountStorageUserState::kSignedOutUser;
}
bool saving_locally = GetDefaultPasswordStore(pref_service, sync_service) ==
PasswordForm::Store::kProfileStore;
// Signed in. Check for account storage opt-in.
if (IsOptedInForAccountStorage(pref_service, sync_service)) {
// Signed in and opted in. Check default storage location.
return saving_locally
? PasswordAccountStorageUserState::
kSignedInAccountStoreUserSavingLocally
: PasswordAccountStorageUserState::kSignedInAccountStoreUser;
}
// Signed in but not opted in. Check default storage location.
return saving_locally
? PasswordAccountStorageUserState::kSignedInUserSavingLocally
: PasswordAccountStorageUserState::kSignedInUser;
}
} // namespace password_manager_util } // namespace password_manager_util
...@@ -204,6 +204,32 @@ void SetDefaultPasswordStore(PrefService* pref_service, ...@@ -204,6 +204,32 @@ void SetDefaultPasswordStore(PrefService* pref_service,
// |pref_service| must not be null. // |pref_service| must not be null.
void ClearAccountStorageSettingsForAllUsers(PrefService* pref_service); void ClearAccountStorageSettingsForAllUsers(PrefService* pref_service);
// Represents the state of the user wrt. sign-in and account-scoped storage.
// Used for metrics.
enum class PasswordAccountStorageUserState {
// Signed-out user (and no account storage opt-in exists).
kSignedOutUser,
// Signed-out user, but an account storage opt-in exists.
kSignedOutAccountStoreUser,
// Signed-in user, not opted in to the account storage (but will save
// passwords to the account storage by default).
kSignedInUser,
// Signed-in user, not opted in to the account storage, and has explicitly
// chosen to save passwords only on the device.
kSignedInUserSavingLocally,
// Signed-in user, opted in to the account storage, and saving passwords to
// the account storage..
kSignedInAccountStoreUser,
// Signed-in user and opted in to the account storage, but has chosen to save
// passwords only on the device.
kSignedInAccountStoreUserSavingLocally,
// Syncing user.
kSyncUser,
};
PasswordAccountStorageUserState ComputePasswordAccountStorageUserState(
const PrefService* pref_service,
const syncer::SyncService* sync_service);
} // namespace password_manager_util } // namespace password_manager_util
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_UTIL_H_ #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_UTIL_H_
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