Commit 95be80a1 authored by edchin's avatar edchin Committed by Commit Bot

[ios][PhishGuard] Compile password reuse detection files

Design doc: go/bling-phishguard

This CL compiles these files in iOS:

password_reuse_detection_manager.h/cc
password_reuse_detector.h/cc
password_reuse_detector_consumer.h/cc
password_store_signin_notifier.h/cc
password_reuse_detector_unittest.cc
password_reuse_detection_manager_unittest.cc

This CL constitutes the minimum changes necessary to compile the above
files, and successfully pass the unittests.

There should be no runtime changes in iOS or other platforms in this CL.

Bug: 1147962
Change-Id: I2eda6d2032dbcd6c80f9516aa19216e1a9da7ab6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533401Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826775}
parent 6778c4ba
...@@ -177,6 +177,12 @@ static_library("browser") { ...@@ -177,6 +177,12 @@ static_library("browser") {
"password_manager_util.h", "password_manager_util.h",
"password_requirements_service.cc", "password_requirements_service.cc",
"password_requirements_service.h", "password_requirements_service.h",
"password_reuse_detection_manager.cc",
"password_reuse_detection_manager.h",
"password_reuse_detector.cc",
"password_reuse_detector.h",
"password_reuse_detector_consumer.cc",
"password_reuse_detector_consumer.h",
"password_save_manager.h", "password_save_manager.h",
"password_save_manager_impl.cc", "password_save_manager_impl.cc",
"password_save_manager_impl.h", "password_save_manager_impl.h",
...@@ -191,6 +197,8 @@ static_library("browser") { ...@@ -191,6 +197,8 @@ static_library("browser") {
"password_store_default.h", "password_store_default.h",
"password_store_factory_util.cc", "password_store_factory_util.cc",
"password_store_factory_util.h", "password_store_factory_util.h",
"password_store_signin_notifier.cc",
"password_store_signin_notifier.h",
"password_store_sync.cc", "password_store_sync.cc",
"password_store_sync.h", "password_store_sync.h",
"password_sync_util.cc", "password_sync_util.cc",
...@@ -256,19 +264,6 @@ static_library("browser") { ...@@ -256,19 +264,6 @@ static_library("browser") {
all_dependent_configs = [ ":password_reuse_detection_config" ] all_dependent_configs = [ ":password_reuse_detection_config" ]
if (password_reuse_detection_support) {
sources += [
"password_reuse_detection_manager.cc",
"password_reuse_detection_manager.h",
"password_reuse_detector.cc",
"password_reuse_detector.h",
"password_reuse_detector_consumer.cc",
"password_reuse_detector_consumer.h",
"password_store_signin_notifier.cc",
"password_store_signin_notifier.h",
]
}
public_deps = [ public_deps = [
":password_form", ":password_form",
"//base", "//base",
...@@ -525,6 +520,7 @@ static_library("test_support") { ...@@ -525,6 +520,7 @@ static_library("test_support") {
public_deps = [ public_deps = [
":browser", ":browser",
":hash_password_manager", ":hash_password_manager",
":password_hash_data",
"//base/test:test_support", "//base/test:test_support",
"//components/autofill/core/browser:test_support", "//components/autofill/core/browser:test_support",
"//components/keyed_service/core", "//components/keyed_service/core",
...@@ -652,6 +648,8 @@ source_set("unit_tests") { ...@@ -652,6 +648,8 @@ source_set("unit_tests") {
"password_manager_unittest.cc", "password_manager_unittest.cc",
"password_manager_util_unittest.cc", "password_manager_util_unittest.cc",
"password_requirements_service_unittest.cc", "password_requirements_service_unittest.cc",
"password_reuse_detection_manager_unittest.cc",
"password_reuse_detector_unittest.cc",
"password_save_manager_impl_unittest.cc", "password_save_manager_impl_unittest.cc",
"password_store_default_unittest.cc", "password_store_default_unittest.cc",
"password_store_origin_unittest.h", "password_store_origin_unittest.h",
...@@ -690,12 +688,6 @@ source_set("unit_tests") { ...@@ -690,12 +688,6 @@ source_set("unit_tests") {
} else { } else {
sources += [ "http_credentials_cleaner_unittest.cc" ] sources += [ "http_credentials_cleaner_unittest.cc" ]
} }
if (password_reuse_detection_support) {
sources += [
"password_reuse_detection_manager_unittest.cc",
"password_reuse_detector_unittest.cc",
]
}
if (is_win || is_mac || is_linux || is_chromeos) { if (is_win || is_mac || is_linux || is_chromeos) {
sources += [ "hash_password_manager_unittest.cc" ] sources += [ "hash_password_manager_unittest.cc" ]
......
...@@ -102,7 +102,6 @@ class MockPasswordStore : public PasswordStore { ...@@ -102,7 +102,6 @@ class MockPasswordStore : public PasswordStore {
MOCK_CONST_METHOD0(IsAbleToSavePasswords, bool()); MOCK_CONST_METHOD0(IsAbleToSavePasswords, bool());
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
MOCK_METHOD3(CheckReuse, MOCK_METHOD3(CheckReuse,
void(const base::string16&, void(const base::string16&,
const std::string&, const std::string&,
...@@ -117,7 +116,7 @@ class MockPasswordStore : public PasswordStore { ...@@ -117,7 +116,7 @@ class MockPasswordStore : public PasswordStore {
MOCK_METHOD1(ClearGaiaPasswordHash, void(const std::string&)); MOCK_METHOD1(ClearGaiaPasswordHash, void(const std::string&));
MOCK_METHOD0(ClearAllGaiaPasswordHash, void()); MOCK_METHOD0(ClearAllGaiaPasswordHash, void());
MOCK_METHOD0(ClearAllEnterprisePasswordHash, void()); MOCK_METHOD0(ClearAllEnterprisePasswordHash, void());
#endif
MOCK_METHOD0(BeginTransaction, bool()); MOCK_METHOD0(BeginTransaction, bool());
MOCK_METHOD0(RollbackTransaction, void()); MOCK_METHOD0(RollbackTransaction, void());
MOCK_METHOD0(CommitTransaction, bool()); MOCK_METHOD0(CommitTransaction, bool());
......
...@@ -59,11 +59,9 @@ class Origin; ...@@ -59,11 +59,9 @@ class Origin;
class GURL; class GURL;
#if defined(ON_FOCUS_PING_ENABLED)
namespace safe_browsing { namespace safe_browsing {
class PasswordProtectionService; class PasswordProtectionService;
} }
#endif
namespace password_manager { namespace password_manager {
...@@ -327,11 +325,9 @@ class PasswordManagerClient { ...@@ -327,11 +325,9 @@ class PasswordManagerClient {
// Returns the current best guess as to the page's display language. // Returns the current best guess as to the page's display language.
virtual std::string GetPageLanguage() const; virtual std::string GetPageLanguage() const;
#if defined(ON_FOCUS_PING_ENABLED) || defined(PASSWORD_REUSE_DETECTION_ENABLED)
// Return the PasswordProtectionService associated with this instance. // Return the PasswordProtectionService associated with this instance.
virtual safe_browsing::PasswordProtectionService* virtual safe_browsing::PasswordProtectionService*
GetPasswordProtectionService() const = 0; GetPasswordProtectionService() const = 0;
#endif
#if defined(ON_FOCUS_PING_ENABLED) #if defined(ON_FOCUS_PING_ENABLED)
// Checks the safe browsing reputation of the webpage when the // Checks the safe browsing reputation of the webpage when the
...@@ -341,7 +337,6 @@ class PasswordManagerClient { ...@@ -341,7 +337,6 @@ class PasswordManagerClient {
const GURL& frame_url) = 0; const GURL& frame_url) = 0;
#endif #endif
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
// Checks the safe browsing reputation of the webpage where password reuse // Checks the safe browsing reputation of the webpage where password reuse
// happens. This is called by the PasswordReuseDetectionManager when a // happens. This is called by the PasswordReuseDetectionManager when a
// protected password is typed on the wrong domain. This may trigger a // protected password is typed on the wrong domain. This may trigger a
...@@ -354,7 +349,6 @@ class PasswordManagerClient { ...@@ -354,7 +349,6 @@ class PasswordManagerClient {
const std::string& username, const std::string& username,
const std::vector<MatchingReusedCredential>& matching_reused_credentials, const std::vector<MatchingReusedCredential>& matching_reused_credentials,
bool password_field_exists) = 0; bool password_field_exists) = 0;
#endif
#if defined(PASSWORD_REUSE_WARNING_ENABLED) #if defined(PASSWORD_REUSE_WARNING_ENABLED)
// Records a Chrome Sync event that GAIA password reuse was detected. // Records a Chrome Sync event that GAIA password reuse was detected.
......
...@@ -298,7 +298,6 @@ void LogGenerationDialogChoice(GenerationDialogChoice choice, ...@@ -298,7 +298,6 @@ void LogGenerationDialogChoice(GenerationDialogChoice choice,
}; };
} // namespace metrics_util } // namespace metrics_util
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
void LogGaiaPasswordHashChange(GaiaPasswordHashChange event, void LogGaiaPasswordHashChange(GaiaPasswordHashChange event,
bool is_sync_password) { bool is_sync_password) {
if (is_sync_password) { if (is_sync_password) {
...@@ -346,7 +345,6 @@ void LogProtectedPasswordHashCounts(size_t gaia_hash_count, ...@@ -346,7 +345,6 @@ void LogProtectedPasswordHashCounts(size_t gaia_hash_count,
} }
void LogProtectedPasswordReuse(PasswordType reused_password_type) {} void LogProtectedPasswordReuse(PasswordType reused_password_type) {}
#endif
void LogPasswordEditResult(IsUsernameChanged username_changed, void LogPasswordEditResult(IsUsernameChanged username_changed,
IsPasswordChanged password_changed) { IsPasswordChanged password_changed) {
......
...@@ -262,7 +262,6 @@ enum class DeleteCorruptedPasswordsResult { ...@@ -262,7 +262,6 @@ enum class DeleteCorruptedPasswordsResult {
kMaxValue = kEncryptionUnavailable, kMaxValue = kEncryptionUnavailable,
}; };
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
enum class GaiaPasswordHashChange { enum class GaiaPasswordHashChange {
// These values are persisted to logs. Entries should not be renumbered and // These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused. // numeric values should never be reused.
...@@ -297,7 +296,6 @@ enum class IsSyncPasswordHashSaved { ...@@ -297,7 +296,6 @@ enum class IsSyncPasswordHashSaved {
IS_SYNC_PASSWORD_HASH_SAVED_COUNT = 3, IS_SYNC_PASSWORD_HASH_SAVED_COUNT = 3,
kMaxValue = IS_SYNC_PASSWORD_HASH_SAVED_COUNT, kMaxValue = IS_SYNC_PASSWORD_HASH_SAVED_COUNT,
}; };
#endif
// These values are persisted to logs. Entries should not be renumbered and // These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused. // numeric values should never be reused.
...@@ -631,7 +629,6 @@ void LogGenerationDialogChoice( ...@@ -631,7 +629,6 @@ void LogGenerationDialogChoice(
GenerationDialogChoice choice, GenerationDialogChoice choice,
autofill::password_generation::PasswordGenerationType type); autofill::password_generation::PasswordGenerationType type);
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
// Log a save gaia password change event. // Log a save gaia password change event.
void LogGaiaPasswordHashChange(GaiaPasswordHashChange event, void LogGaiaPasswordHashChange(GaiaPasswordHashChange event,
bool is_sync_password); bool is_sync_password);
...@@ -647,8 +644,6 @@ void LogProtectedPasswordHashCounts(size_t gaia_hash_count, ...@@ -647,8 +644,6 @@ void LogProtectedPasswordHashCounts(size_t gaia_hash_count,
bool does_primary_account_exists, bool does_primary_account_exists,
bool is_signed_in); bool is_signed_in);
#endif
// Log the result of the password edit action. // Log the result of the password edit action.
void LogPasswordEditResult(IsUsernameChanged password_changed, void LogPasswordEditResult(IsUsernameChanged password_changed,
IsPasswordChanged username_changed); IsPasswordChanged username_changed);
......
...@@ -120,7 +120,6 @@ MockPasswordStoreObserver::MockPasswordStoreObserver() = default; ...@@ -120,7 +120,6 @@ MockPasswordStoreObserver::MockPasswordStoreObserver() = default;
MockPasswordStoreObserver::~MockPasswordStoreObserver() = default; MockPasswordStoreObserver::~MockPasswordStoreObserver() = default;
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
MockPasswordReuseDetectorConsumer::MockPasswordReuseDetectorConsumer() = MockPasswordReuseDetectorConsumer::MockPasswordReuseDetectorConsumer() =
default; default;
...@@ -158,6 +157,4 @@ void PasswordHashDataMatcher::DescribeNegationTo(::std::ostream* os) const { ...@@ -158,6 +157,4 @@ void PasswordHashDataMatcher::DescribeNegationTo(::std::ostream* os) const {
return ::testing::MakeMatcher(new PasswordHashDataMatcher(expected)); return ::testing::MakeMatcher(new PasswordHashDataMatcher(expected));
} }
#endif
} // namespace password_manager } // namespace password_manager
...@@ -12,15 +12,12 @@ ...@@ -12,15 +12,12 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "components/password_manager/core/browser/origin_credential_store.h" #include "components/password_manager/core/browser/origin_credential_store.h"
#include "components/password_manager/core/browser/password_form.h" #include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_hash_data.h"
#include "components/password_manager/core/browser/password_reuse_detector_consumer.h"
#include "components/password_manager/core/browser/password_store.h" #include "components/password_manager/core/browser/password_store.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "url/gurl.h" #include "url/gurl.h"
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
#include "components/password_manager/core/browser/password_hash_data.h" // nogncheck
#include "components/password_manager/core/browser/password_reuse_detector_consumer.h" // nogncheck
#endif
namespace password_manager { namespace password_manager {
// This template allows creating methods with signature conforming to // This template allows creating methods with signature conforming to
...@@ -110,7 +107,6 @@ class MockPasswordStoreObserver : public PasswordStore::Observer { ...@@ -110,7 +107,6 @@ class MockPasswordStoreObserver : public PasswordStore::Observer {
MOCK_METHOD1(OnLoginsChanged, void(const PasswordStoreChangeList& changes)); MOCK_METHOD1(OnLoginsChanged, void(const PasswordStoreChangeList& changes));
}; };
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
class MockPasswordReuseDetectorConsumer : public PasswordReuseDetectorConsumer { class MockPasswordReuseDetectorConsumer : public PasswordReuseDetectorConsumer {
public: public:
MockPasswordReuseDetectorConsumer(); MockPasswordReuseDetectorConsumer();
...@@ -145,7 +141,6 @@ class PasswordHashDataMatcher ...@@ -145,7 +141,6 @@ class PasswordHashDataMatcher
::testing::Matcher<base::Optional<PasswordHashData>> Matches( ::testing::Matcher<base::Optional<PasswordHashData>> Matches(
base::Optional<PasswordHashData> expected); base::Optional<PasswordHashData> expected);
#endif
} // namespace password_manager } // namespace password_manager
......
...@@ -168,7 +168,6 @@ void PasswordReuseDetectionManager::OnReuseCheckDone( ...@@ -168,7 +168,6 @@ void PasswordReuseDetectionManager::OnReuseCheckDone(
client_->LogPasswordReuseDetectedEvent(); client_->LogPasswordReuseDetectedEvent();
#endif #endif
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
std::string username = reused_protected_password_hash.has_value() std::string username = reused_protected_password_hash.has_value()
? reused_protected_password_hash->username ? reused_protected_password_hash->username
: ""; : "";
...@@ -177,7 +176,7 @@ void PasswordReuseDetectionManager::OnReuseCheckDone( ...@@ -177,7 +176,7 @@ void PasswordReuseDetectionManager::OnReuseCheckDone(
reused_password_type, username, reused_password_type, username,
std::move(all_matching_reused_credentials_).extract(), std::move(all_matching_reused_credentials_).extract(),
password_field_detected); password_field_detected);
#endif
all_matching_reused_credentials_.clear(); all_matching_reused_credentials_.clear();
} }
......
...@@ -40,12 +40,9 @@ ...@@ -40,12 +40,9 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/sync/model_impl/client_tag_based_model_type_processor.h" #include "components/sync/model_impl/client_tag_based_model_type_processor.h"
#include "components/sync/model_impl/proxy_model_type_controller_delegate.h" #include "components/sync/model_impl/proxy_model_type_controller_delegate.h"
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/password_manager/core/browser/password_store_signin_notifier.h" #include "components/password_manager/core/browser/password_store_signin_notifier.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h" #include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#endif
namespace password_manager { namespace password_manager {
...@@ -92,7 +89,6 @@ void PasswordStore::DatabaseCompromisedCredentialsObserver:: ...@@ -92,7 +89,6 @@ void PasswordStore::DatabaseCompromisedCredentialsObserver::
OnCompromisedCredentialsChanged(); OnCompromisedCredentialsChanged();
} }
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
PasswordStore::CheckReuseRequest::CheckReuseRequest( PasswordStore::CheckReuseRequest::CheckReuseRequest(
PasswordReuseDetectorConsumer* consumer) PasswordReuseDetectorConsumer* consumer)
: origin_task_runner_(base::SequencedTaskRunnerHandle::Get()), : origin_task_runner_(base::SequencedTaskRunnerHandle::Get()),
...@@ -116,7 +112,6 @@ void PasswordStore::CheckReuseRequest::OnReuseCheckDone( ...@@ -116,7 +112,6 @@ void PasswordStore::CheckReuseRequest::OnReuseCheckDone(
matching_reused_credentials, saved_passwords)); matching_reused_credentials, saved_passwords));
TRACE_EVENT_NESTABLE_ASYNC_END0("passwords", "CheckReuseRequest", this); TRACE_EVENT_NESTABLE_ASYNC_END0("passwords", "CheckReuseRequest", this);
} }
#endif
PasswordStore::FormDigest::FormDigest(PasswordForm::Scheme new_scheme, PasswordStore::FormDigest::FormDigest(PasswordForm::Scheme new_scheme,
const std::string& new_signon_realm, const std::string& new_signon_realm,
...@@ -552,7 +547,6 @@ void PasswordStore::SetSyncTaskTimeoutForTest(base::TimeDelta timeout) { ...@@ -552,7 +547,6 @@ void PasswordStore::SetSyncTaskTimeoutForTest(base::TimeDelta timeout) {
sync_task_timeout_ = timeout; sync_task_timeout_ = timeout;
} }
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
void PasswordStore::CheckReuse(const base::string16& input, void PasswordStore::CheckReuse(const base::string16& input,
const std::string& domain, const std::string& domain,
PasswordReuseDetectorConsumer* consumer) { PasswordReuseDetectorConsumer* consumer) {
...@@ -560,9 +554,7 @@ void PasswordStore::CheckReuse(const base::string16& input, ...@@ -560,9 +554,7 @@ void PasswordStore::CheckReuse(const base::string16& input,
std::make_unique<CheckReuseRequest>(consumer), std::make_unique<CheckReuseRequest>(consumer),
input, domain)); input, domain));
} }
#endif
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
void PasswordStore::PreparePasswordHashData(const std::string& sync_username, void PasswordStore::PreparePasswordHashData(const std::string& sync_username,
const bool is_signed_in) { const bool is_signed_in) {
SchedulePasswordHashUpdate(/*should_log_metrics=*/true, SchedulePasswordHashUpdate(/*should_log_metrics=*/true,
...@@ -677,8 +669,6 @@ void PasswordStore::ScheduleEnterprisePasswordURLUpdate() { ...@@ -677,8 +669,6 @@ void PasswordStore::ScheduleEnterprisePasswordURLUpdate() {
std::move(enterprise_change_password_url))); std::move(enterprise_change_password_url)));
} }
#endif
PasswordStore::~PasswordStore() { PasswordStore::~PasswordStore() {
DCHECK(shutdown_called_); DCHECK(shutdown_called_);
// PasswordSyncBridge should delete on the same sequence where it was created. // PasswordSyncBridge should delete on the same sequence where it was created.
...@@ -819,7 +809,6 @@ void PasswordStore::NotifyUnsyncedCredentialsWillBeDeleted( ...@@ -819,7 +809,6 @@ void PasswordStore::NotifyUnsyncedCredentialsWillBeDeleted(
} }
} }
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
void PasswordStore::CheckReuseImpl(std::unique_ptr<CheckReuseRequest> request, void PasswordStore::CheckReuseImpl(std::unique_ptr<CheckReuseRequest> request,
const base::string16& input, const base::string16& input,
const std::string& domain) { const std::string& domain) {
...@@ -893,8 +882,6 @@ void PasswordStore::ClearAllNonGmailPasswordHashImpl() { ...@@ -893,8 +882,6 @@ void PasswordStore::ClearAllNonGmailPasswordHashImpl() {
reuse_detector_->ClearAllNonGmailPasswordHash(); reuse_detector_->ClearAllNonGmailPasswordHash();
} }
#endif
void PasswordStore::OnInitCompleted(bool success) { void PasswordStore::OnInitCompleted(bool success) {
DCHECK(main_task_runner_->RunsTasksInCurrentSequence()); DCHECK(main_task_runner_->RunsTasksInCurrentSequence());
init_status_ = success ? InitStatus::kSuccess : InitStatus::kFailure; init_status_ = success ? InitStatus::kSuccess : InitStatus::kFailure;
......
...@@ -26,13 +26,10 @@ ...@@ -26,13 +26,10 @@
#include "components/password_manager/core/browser/compromised_credentials_table.h" #include "components/password_manager/core/browser/compromised_credentials_table.h"
#include "components/password_manager/core/browser/password_store_change.h" #include "components/password_manager/core/browser/password_store_change.h"
#include "components/password_manager/core/browser/password_store_sync.h" #include "components/password_manager/core/browser/password_store_sync.h"
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
#include "components/password_manager/core/browser/hash_password_manager.h" #include "components/password_manager/core/browser/hash_password_manager.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/password_reuse_detector.h" #include "components/password_manager/core/browser/password_reuse_detector.h"
#include "components/password_manager/core/browser/password_reuse_detector_consumer.h" #include "components/password_manager/core/browser/password_reuse_detector_consumer.h"
#endif
class PrefService; class PrefService;
...@@ -54,9 +51,7 @@ struct PasswordForm; ...@@ -54,9 +51,7 @@ struct PasswordForm;
using IsAccountStore = util::StrongAlias<class IsAccountStoreTag, bool>; using IsAccountStore = util::StrongAlias<class IsAccountStoreTag, bool>;
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
using metrics_util::GaiaPasswordHashChange; using metrics_util::GaiaPasswordHashChange;
#endif
class AffiliatedMatchHelper; class AffiliatedMatchHelper;
class PasswordStoreConsumer; class PasswordStoreConsumer;
...@@ -67,9 +62,7 @@ struct FieldInfo; ...@@ -67,9 +62,7 @@ struct FieldInfo;
struct InteractionsStats; struct InteractionsStats;
struct CompromisedCredentials; struct CompromisedCredentials;
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
using PasswordHashDataList = base::Optional<std::vector<PasswordHashData>>; using PasswordHashDataList = base::Optional<std::vector<PasswordHashData>>;
#endif
// Interface for storing form passwords in a platform-specific secure way. // Interface for storing form passwords in a platform-specific secure way.
// The login request/manipulation API is not threadsafe and must be used // The login request/manipulation API is not threadsafe and must be used
...@@ -380,7 +373,6 @@ class PasswordStore : protected PasswordStoreSync, ...@@ -380,7 +373,6 @@ class PasswordStore : protected PasswordStoreSync,
void SetSyncTaskTimeoutForTest(base::TimeDelta timeout); void SetSyncTaskTimeoutForTest(base::TimeDelta timeout);
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
// Immediately called after |Init()| to retrieve password hash data for // Immediately called after |Init()| to retrieve password hash data for
// reuse detection. // reuse detection.
void PreparePasswordHashData(const std::string& sync_username, void PreparePasswordHashData(const std::string& sync_username,
...@@ -449,12 +441,9 @@ class PasswordStore : protected PasswordStoreSync, ...@@ -449,12 +441,9 @@ class PasswordStore : protected PasswordStoreSync,
// These URLs are used in enterprise password reuse detection. // These URLs are used in enterprise password reuse detection.
void ScheduleEnterprisePasswordURLUpdate(); void ScheduleEnterprisePasswordURLUpdate();
#endif
protected: protected:
friend class base::RefCountedThreadSafe<PasswordStore>; friend class base::RefCountedThreadSafe<PasswordStore>;
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
// Represents a single CheckReuse() request. Implements functionality to // Represents a single CheckReuse() request. Implements functionality to
// listen to reuse events and propagate them to |consumer| on the sequence on // listen to reuse events and propagate them to |consumer| on the sequence on
// which CheckReuseRequest is created. // which CheckReuseRequest is created.
...@@ -479,7 +468,6 @@ class PasswordStore : protected PasswordStoreSync, ...@@ -479,7 +468,6 @@ class PasswordStore : protected PasswordStoreSync,
DISALLOW_COPY_AND_ASSIGN(CheckReuseRequest); DISALLOW_COPY_AND_ASSIGN(CheckReuseRequest);
}; };
#endif
// Status of PasswordStore::Init(). // Status of PasswordStore::Init().
enum class InitStatus { enum class InitStatus {
...@@ -629,7 +617,6 @@ class PasswordStore : protected PasswordStoreSync, ...@@ -629,7 +617,6 @@ class PasswordStore : protected PasswordStoreSync,
void InvokeAndNotifyAboutCompromisedPasswordsChange( void InvokeAndNotifyAboutCompromisedPasswordsChange(
base::OnceCallback<bool()> callback); base::OnceCallback<bool()> callback);
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
// Saves |username| and a hash of |password| for password reuse checking. // Saves |username| and a hash of |password| for password reuse checking.
// |is_gaia_password| indicates if it is a Gaia account. |event| is used for // |is_gaia_password| indicates if it is a Gaia account. |event| is used for
// metric logging. |is_primary_account| is whether account belong to the // metric logging. |is_primary_account| is whether account belong to the
...@@ -672,7 +659,6 @@ class PasswordStore : protected PasswordStoreSync, ...@@ -672,7 +659,6 @@ class PasswordStore : protected PasswordStoreSync,
// Synchronous implementation of ClearAllNonGmailPasswordHash(). // Synchronous implementation of ClearAllNonGmailPasswordHash().
void ClearAllNonGmailPasswordHashImpl(); void ClearAllNonGmailPasswordHashImpl();
#endif
scoped_refptr<base::SequencedTaskRunner> main_task_runner() const { scoped_refptr<base::SequencedTaskRunner> main_task_runner() const {
return main_task_runner_; return main_task_runner_;
...@@ -895,14 +881,13 @@ class PasswordStore : protected PasswordStoreSync, ...@@ -895,14 +881,13 @@ class PasswordStore : protected PasswordStoreSync,
std::unique_ptr<AffiliatedMatchHelper> affiliated_match_helper_; std::unique_ptr<AffiliatedMatchHelper> affiliated_match_helper_;
PrefService* prefs_ = nullptr; PrefService* prefs_ = nullptr;
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
// PasswordReuseDetector can be only destroyed on the background sequence. It // PasswordReuseDetector can be only destroyed on the background sequence. It
// can't be owned by PasswordStore because PasswordStore can be destroyed on // can't be owned by PasswordStore because PasswordStore can be destroyed on
// the UI thread and DestroyOnBackgroundThread isn't guaranteed to be called. // the UI thread and DestroyOnBackgroundThread isn't guaranteed to be called.
PasswordReuseDetector* reuse_detector_ = nullptr; PasswordReuseDetector* reuse_detector_ = nullptr;
std::unique_ptr<PasswordStoreSigninNotifier> notifier_; std::unique_ptr<PasswordStoreSigninNotifier> notifier_;
HashPasswordManager hash_password_manager_; HashPasswordManager hash_password_manager_;
#endif
std::unique_ptr<UnsyncedCredentialsDeletionNotifier> deletion_notifier_; std::unique_ptr<UnsyncedCredentialsDeletionNotifier> deletion_notifier_;
......
...@@ -98,12 +98,10 @@ StubPasswordManagerClient::GetPasswordFeatureManager() { ...@@ -98,12 +98,10 @@ StubPasswordManagerClient::GetPasswordFeatureManager() {
return &password_feature_manager_; return &password_feature_manager_;
} }
#if defined(ON_FOCUS_PING_ENABLED) || defined(PASSWORD_REUSE_DETECTION_ENABLED)
safe_browsing::PasswordProtectionService* safe_browsing::PasswordProtectionService*
StubPasswordManagerClient::GetPasswordProtectionService() const { StubPasswordManagerClient::GetPasswordProtectionService() const {
return nullptr; return nullptr;
} }
#endif
#if defined(ON_FOCUS_PING_ENABLED) #if defined(ON_FOCUS_PING_ENABLED)
void StubPasswordManagerClient::CheckSafeBrowsingReputation( void StubPasswordManagerClient::CheckSafeBrowsingReputation(
...@@ -111,13 +109,11 @@ void StubPasswordManagerClient::CheckSafeBrowsingReputation( ...@@ -111,13 +109,11 @@ void StubPasswordManagerClient::CheckSafeBrowsingReputation(
const GURL& frame_url) {} const GURL& frame_url) {}
#endif #endif
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
void StubPasswordManagerClient::CheckProtectedPasswordEntry( void StubPasswordManagerClient::CheckProtectedPasswordEntry(
metrics_util::PasswordType reused_password_type, metrics_util::PasswordType reused_password_type,
const std::string& username, const std::string& username,
const std::vector<MatchingReusedCredential>& matching_reused_credentials, const std::vector<MatchingReusedCredential>& matching_reused_credentials,
bool password_field_exists) {} bool password_field_exists) {}
#endif
#if defined(PASSWORD_REUSE_WARNING_ENABLED) #if defined(PASSWORD_REUSE_WARNING_ENABLED)
void StubPasswordManagerClient::LogPasswordReuseDetectedEvent() {} void StubPasswordManagerClient::LogPasswordReuseDetectedEvent() {}
......
...@@ -64,23 +64,19 @@ class StubPasswordManagerClient : public PasswordManagerClient { ...@@ -64,23 +64,19 @@ class StubPasswordManagerClient : public PasswordManagerClient {
MockPasswordFeatureManager* GetPasswordFeatureManager(); MockPasswordFeatureManager* GetPasswordFeatureManager();
bool IsAutofillAssistantUIVisible() const override; bool IsAutofillAssistantUIVisible() const override;
#if defined(ON_FOCUS_PING_ENABLED) || defined(PASSWORD_REUSE_DETECTION_ENABLED)
safe_browsing::PasswordProtectionService* GetPasswordProtectionService() safe_browsing::PasswordProtectionService* GetPasswordProtectionService()
const override; const override;
#endif
#if defined(ON_FOCUS_PING_ENABLED) #if defined(ON_FOCUS_PING_ENABLED)
void CheckSafeBrowsingReputation(const GURL& form_action, void CheckSafeBrowsingReputation(const GURL& form_action,
const GURL& frame_url) override; const GURL& frame_url) override;
#endif #endif
#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
void CheckProtectedPasswordEntry( void CheckProtectedPasswordEntry(
metrics_util::PasswordType reused_password_type, metrics_util::PasswordType reused_password_type,
const std::string& username, const std::string& username,
const std::vector<MatchingReusedCredential>& matching_reused_credentials, const std::vector<MatchingReusedCredential>& matching_reused_credentials,
bool password_field_exists) override; bool password_field_exists) override;
#endif
#if defined(PASSWORD_REUSE_WARNING_ENABLED) #if defined(PASSWORD_REUSE_WARNING_ENABLED)
void LogPasswordReuseDetectedEvent() override; void LogPasswordReuseDetectedEvent() override;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#import "components/password_manager/core/browser/password_manager_client.h" #import "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_client_helper.h" #include "components/password_manager/core/browser/password_manager_client_helper.h"
#include "components/password_manager/core/browser/password_manager_metrics_recorder.h" #include "components/password_manager/core/browser/password_manager_metrics_recorder.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/sync_credentials_filter.h" #include "components/password_manager/core/browser/sync_credentials_filter.h"
#include "components/password_manager/ios/password_manager_client_bridge.h" #include "components/password_manager/ios/password_manager_client_bridge.h"
#include "components/prefs/pref_member.h" #include "components/prefs/pref_member.h"
...@@ -117,6 +118,16 @@ class IOSChromePasswordManagerClient ...@@ -117,6 +118,16 @@ class IOSChromePasswordManagerClient
password_manager::FieldInfoManager* GetFieldInfoManager() const override; password_manager::FieldInfoManager* GetFieldInfoManager() const override;
bool IsAutofillAssistantUIVisible() const override; bool IsAutofillAssistantUIVisible() const override;
safe_browsing::PasswordProtectionService* GetPasswordProtectionService()
const override;
void CheckProtectedPasswordEntry(
password_manager::metrics_util::PasswordType reused_password_type,
const std::string& username,
const std::vector<password_manager::MatchingReusedCredential>&
matching_reused_credentials,
bool password_field_exists) override;
private: private:
__weak id<IOSChromePasswordManagerClientBridge> bridge_; __weak id<IOSChromePasswordManagerClientBridge> bridge_;
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
using password_manager::metrics_util::PasswordType;
using password_manager::PasswordFormManagerForUI; using password_manager::PasswordFormManagerForUI;
using password_manager::PasswordManagerMetricsRecorder; using password_manager::PasswordManagerMetricsRecorder;
using password_manager::PasswordStore; using password_manager::PasswordStore;
...@@ -298,3 +299,20 @@ IOSChromePasswordManagerClient::GetFieldInfoManager() const { ...@@ -298,3 +299,20 @@ IOSChromePasswordManagerClient::GetFieldInfoManager() const {
bool IOSChromePasswordManagerClient::IsAutofillAssistantUIVisible() const { bool IOSChromePasswordManagerClient::IsAutofillAssistantUIVisible() const {
return false; return false;
} }
safe_browsing::PasswordProtectionService*
IOSChromePasswordManagerClient::GetPasswordProtectionService() const {
// TODO(crbug.com/1147967): This is no-op until the password protection
// service is enabled.
return nullptr;
}
void IOSChromePasswordManagerClient::CheckProtectedPasswordEntry(
PasswordType password_type,
const std::string& username,
const std::vector<password_manager::MatchingReusedCredential>&
matching_reused_credentials,
bool password_field_exists) {
// TODO(crbug.com/1147967): This is no-op until the password protection
// service is enabled.
}
...@@ -119,6 +119,16 @@ class WebViewPasswordManagerClient ...@@ -119,6 +119,16 @@ class WebViewPasswordManagerClient
void set_bridge(id<PasswordManagerClientBridge> bridge) { bridge_ = bridge; } void set_bridge(id<PasswordManagerClientBridge> bridge) { bridge_ = bridge; }
const syncer::SyncService* GetSyncService(); const syncer::SyncService* GetSyncService();
safe_browsing::PasswordProtectionService* GetPasswordProtectionService()
const override;
void CheckProtectedPasswordEntry(
password_manager::metrics_util::PasswordType reused_password_type,
const std::string& username,
const std::vector<password_manager::MatchingReusedCredential>&
matching_reused_credentials,
bool password_field_exists) override;
private: private:
__weak id<PasswordManagerClientBridge> bridge_; __weak id<PasswordManagerClientBridge> bridge_;
......
...@@ -292,4 +292,19 @@ const syncer::SyncService* WebViewPasswordManagerClient::GetSyncService() { ...@@ -292,4 +292,19 @@ const syncer::SyncService* WebViewPasswordManagerClient::GetSyncService() {
return sync_service_; return sync_service_;
} }
safe_browsing::PasswordProtectionService*
WebViewPasswordManagerClient::GetPasswordProtectionService() const {
// TODO(crbug.com/1148229): Enable PhishGuard in web_view.
return nullptr;
}
void WebViewPasswordManagerClient::CheckProtectedPasswordEntry(
password_manager::metrics_util::PasswordType password_type,
const std::string& username,
const std::vector<password_manager::MatchingReusedCredential>&
matching_reused_credentials,
bool password_field_exists) {
// TODO(crbug.com/1147967): Enable PhishGuard in web_view.
}
} // namespace ios_web_view } // 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