Commit ea6a45cd authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Store default password store in prefs

Bug: 1012203
Change-Id: I5f10793d64cc6a5b64908387dab26e722abf275e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1943236Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720608}
parent 30b0d72f
......@@ -21,6 +21,10 @@ class MockPasswordFeatureManager : public PasswordFeatureManager {
MOCK_CONST_METHOD0(IsOptedInForAccountStorage, bool());
MOCK_CONST_METHOD0(ShouldShowAccountStorageOptIn, bool());
MOCK_METHOD1(SetAccountStorageOptIn, void(bool));
MOCK_METHOD1(SetDefaultPasswordStore,
void(const autofill::PasswordForm::Store& store));
MOCK_CONST_METHOD0(GetDefaultPasswordStore, autofill::PasswordForm::Store());
};
} // namespace password_manager
......
......@@ -6,6 +6,7 @@
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FEATURE_MANAGER_H_
#include "base/macros.h"
#include "components/autofill/core/common/password_form.h"
namespace password_manager {
......@@ -36,6 +37,15 @@ class PasswordFeatureManager {
// current signed-in user (unconsented primary account).
virtual void SetAccountStorageOptIn(bool opt_in) = 0;
// Sets the default password store selected by user in prefs. This store is
// used for saving new credentials and adding blacking listing entries.
virtual void SetDefaultPasswordStore(
const autofill::PasswordForm::Store& store) = 0;
// Reads the default password store from pref that was set using
// SetDefaultPasswordStore();
virtual autofill::PasswordForm::Store GetDefaultPasswordStore() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(PasswordFeatureManager);
};
......
......@@ -5,8 +5,12 @@
#include "components/password_manager/core/browser/password_feature_manager_impl.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/sync/driver/sync_service.h"
using autofill::PasswordForm;
namespace password_manager {
PasswordFeatureManagerImpl::PasswordFeatureManagerImpl(
......@@ -54,4 +58,19 @@ void PasswordFeatureManagerImpl::SetAccountStorageOptIn(bool opt_in) {
opt_in);
}
void PasswordFeatureManagerImpl::SetDefaultPasswordStore(
const PasswordForm::Store& store) {
DCHECK(pref_service_);
pref_service_->SetBoolean(prefs::kIsAccountStoreDefault,
store == PasswordForm::Store::kAccountStore);
}
PasswordForm::Store PasswordFeatureManagerImpl::GetDefaultPasswordStore()
const {
DCHECK(pref_service_);
return pref_service_->GetBoolean(prefs::kIsAccountStoreDefault)
? PasswordForm::Store::kAccountStore
: PasswordForm::Store::kProfileStore;
}
} // namespace password_manager
......@@ -32,6 +32,10 @@ class PasswordFeatureManagerImpl : public PasswordFeatureManager {
bool ShouldShowAccountStorageOptIn() const override;
void SetAccountStorageOptIn(bool opt_in) override;
void SetDefaultPasswordStore(
const autofill::PasswordForm::Store& store) override;
autofill::PasswordForm::Store GetDefaultPasswordStore() const override;
private:
PrefService* const pref_service_;
const syncer::SyncService* const sync_service_;
......
......@@ -179,6 +179,7 @@ void PasswordManager::RegisterProfilePrefs(
registry->RegisterDictionaryPref(prefs::kAccountStorageOptedInAccounts);
registry->RegisterBooleanPref(prefs::kIsAccountStoreDefault, true);
#if defined(OS_MACOSX)
registry->RegisterIntegerPref(prefs::kKeychainMigrationStatus,
4 /* MIGRATED_DELETED */);
......
......@@ -44,6 +44,8 @@ const char kSignInPasswordPromoRevive[] =
const char kAccountStorageOptedInAccounts[] =
"profile.password_account_storage_opted_in_accounts";
const char kIsAccountStoreDefault[] = "profile.is_account_store_default";
const char kSyncPasswordHash[] = "profile.sync_password_hash";
const char kSyncPasswordLengthAndHashSalt[] =
......
......@@ -71,6 +71,10 @@ extern const char kSignInPasswordPromoRevive[];
// for passwords (map from hash of Gaia ID to bool).
extern const char kAccountStorageOptedInAccounts[];
// Boolean that is true when the default password store is the Google account
// store, and false when the profile store is the default store.
extern const char kIsAccountStoreDefault[];
// String that represents the sync password hash.
extern const char kSyncPasswordHash[];
......
......@@ -24,6 +24,10 @@ class WebViewPasswordFeatureManager
bool ShouldShowAccountStorageOptIn() const override;
void SetAccountStorageOptIn(bool opt_in) override;
void SetDefaultPasswordStore(
const autofill::PasswordForm::Store& store) override;
autofill::PasswordForm::Store GetDefaultPasswordStore() const override;
private:
DISALLOW_COPY_AND_ASSIGN(WebViewPasswordFeatureManager);
};
......
......@@ -32,4 +32,14 @@ void WebViewPasswordFeatureManager::SetAccountStorageOptIn(bool opt_in) {
NOTREACHED();
}
autofill::PasswordForm::Store
WebViewPasswordFeatureManager::GetDefaultPasswordStore() const {
return autofill::PasswordForm::Store::kProfileStore;
}
void WebViewPasswordFeatureManager::SetDefaultPasswordStore(
const autofill::PasswordForm::Store& store) {
NOTREACHED();
}
} // namespace ios_web_view
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