Commit 95efac15 authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

Migrate password_manager::AffiliationFetchThrottler to NetworkConnectionTracker

This migrates password_manager::AffiliationFetchThrottler from
NetworkChangeManager to NetworkConnectionTracker, which works with the
network service enabled.

Bug: 887058
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I04c2529e24ea0bf85ebb0646127ded2b594306c2
Reviewed-on: https://chromium-review.googlesource.com/1239359Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594783}
parent 9fc69fb7
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
...@@ -117,7 +118,7 @@ void PasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged( ...@@ -117,7 +118,7 @@ void PasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged(
password_store.get(), sync_service, password_store.get(), sync_service,
content::BrowserContext::GetDefaultStoragePartition(profile) content::BrowserContext::GetDefaultStoragePartition(profile)
->GetURLLoaderFactoryForBrowserProcess(), ->GetURLLoaderFactoryForBrowserProcess(),
profile->GetPath()); content::GetNetworkConnectionTracker(), profile->GetPath());
} }
PasswordStoreFactory::PasswordStoreFactory() PasswordStoreFactory::PasswordStoreFactory()
......
...@@ -44,11 +44,12 @@ AffiliationBackend::~AffiliationBackend() { ...@@ -44,11 +44,12 @@ AffiliationBackend::~AffiliationBackend() {
void AffiliationBackend::Initialize( void AffiliationBackend::Initialize(
std::unique_ptr<network::SharedURLLoaderFactoryInfo> std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info, url_loader_factory_info,
network::NetworkConnectionTracker* network_connection_tracker,
const base::FilePath& db_path) { const base::FilePath& db_path) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!throttler_); DCHECK(!throttler_);
throttler_.reset( throttler_.reset(new AffiliationFetchThrottler(
new AffiliationFetchThrottler(this, task_runner_, tick_clock_)); this, task_runner_, network_connection_tracker, tick_clock_));
// TODO(engedy): Currently, when Init() returns false, it always poisons the // TODO(engedy): Currently, when Init() returns false, it always poisons the
// DB, so subsequent operations will silently fail. Consider either fully // DB, so subsequent operations will silently fail. Consider either fully
......
...@@ -33,6 +33,7 @@ class Time; ...@@ -33,6 +33,7 @@ class Time;
} // namespace base } // namespace base
namespace network { namespace network {
class NetworkConnectionTracker;
class SharedURLLoaderFactoryInfo; class SharedURLLoaderFactoryInfo;
} // namespace network } // namespace network
...@@ -71,6 +72,7 @@ class AffiliationBackend : public FacetManagerHost, ...@@ -71,6 +72,7 @@ class AffiliationBackend : public FacetManagerHost,
// affiliation information locally will be opened/created at |db_path|. // affiliation information locally will be opened/created at |db_path|.
void Initialize(std::unique_ptr<network::SharedURLLoaderFactoryInfo> void Initialize(std::unique_ptr<network::SharedURLLoaderFactoryInfo>
url_loader_factory_info, url_loader_factory_info,
network::NetworkConnectionTracker* network_connection_tracker,
const base::FilePath& db_path); const base::FilePath& db_path);
// Implementations for methods of the same name in AffiliationService. They // Implementations for methods of the same name in AffiliationService. They
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_network_connection_tracker.h"
#include "services/network/test/test_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -44,7 +45,11 @@ class MockAffiliationFetchThrottler : public AffiliationFetchThrottler { ...@@ -44,7 +45,11 @@ class MockAffiliationFetchThrottler : public AffiliationFetchThrottler {
public: public:
explicit MockAffiliationFetchThrottler( explicit MockAffiliationFetchThrottler(
AffiliationFetchThrottlerDelegate* delegate) AffiliationFetchThrottlerDelegate* delegate)
: AffiliationFetchThrottler(delegate, nullptr, nullptr), : AffiliationFetchThrottler(
delegate,
nullptr,
network::TestNetworkConnectionTracker::GetInstance(),
nullptr),
signaled_network_request_needed_(false) { signaled_network_request_needed_(false) {
EXPECT_CALL(*this, OnInformOfNetworkRequestComplete(testing::_)).Times(0); EXPECT_CALL(*this, OnInformOfNetworkRequestComplete(testing::_)).Times(0);
} }
...@@ -342,7 +347,9 @@ class AffiliationBackendTest : public testing::Test { ...@@ -342,7 +347,9 @@ class AffiliationBackendTest : public testing::Test {
auto test_shared_loader_factory = auto test_shared_loader_factory =
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&test_url_loader_factory_); &test_url_loader_factory_);
backend_->Initialize(test_shared_loader_factory->Clone(), db_path()); backend_->Initialize(test_shared_loader_factory->Clone(),
network::TestNetworkConnectionTracker::GetInstance(),
db_path());
auto mock_fetch_throttler = auto mock_fetch_throttler =
std::make_unique<MockAffiliationFetchThrottler>(backend_.get()); std::make_unique<MockAffiliationFetchThrottler>(backend_.get());
mock_fetch_throttler_ = mock_fetch_throttler.get(); mock_fetch_throttler_ = mock_fetch_throttler.get();
......
...@@ -52,9 +52,11 @@ const int64_t AffiliationFetchThrottler::kGracePeriodAfterReconnectMs = ...@@ -52,9 +52,11 @@ const int64_t AffiliationFetchThrottler::kGracePeriodAfterReconnectMs =
AffiliationFetchThrottler::AffiliationFetchThrottler( AffiliationFetchThrottler::AffiliationFetchThrottler(
AffiliationFetchThrottlerDelegate* delegate, AffiliationFetchThrottlerDelegate* delegate,
const scoped_refptr<base::SequencedTaskRunner>& task_runner, const scoped_refptr<base::SequencedTaskRunner>& task_runner,
network::NetworkConnectionTracker* network_connection_tracker,
const base::TickClock* tick_clock) const base::TickClock* tick_clock)
: delegate_(delegate), : delegate_(delegate),
task_runner_(task_runner), task_runner_(task_runner),
network_connection_tracker_(network_connection_tracker),
tick_clock_(tick_clock), tick_clock_(tick_clock),
state_(IDLE), state_(IDLE),
has_network_connectivity_(false), has_network_connectivity_(false),
...@@ -64,12 +66,12 @@ AffiliationFetchThrottler::AffiliationFetchThrottler( ...@@ -64,12 +66,12 @@ AffiliationFetchThrottler::AffiliationFetchThrottler(
DCHECK(delegate); DCHECK(delegate);
// Start observing before querying the current connectivity state, so that if // Start observing before querying the current connectivity state, so that if
// the state changes concurrently in-between, it will not go unnoticed. // the state changes concurrently in-between, it will not go unnoticed.
net::NetworkChangeNotifier::AddNetworkChangeObserver(this); network_connection_tracker_->AddNetworkConnectionObserver(this);
has_network_connectivity_ = !net::NetworkChangeNotifier::IsOffline(); has_network_connectivity_ = !network_connection_tracker_->IsOffline();
} }
AffiliationFetchThrottler::~AffiliationFetchThrottler() { AffiliationFetchThrottler::~AffiliationFetchThrottler() {
net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); network_connection_tracker_->RemoveNetworkConnectionObserver(this);
} }
void AffiliationFetchThrottler::SignalNetworkRequestNeeded() { void AffiliationFetchThrottler::SignalNetworkRequestNeeded() {
...@@ -121,11 +123,14 @@ void AffiliationFetchThrottler::OnBackoffDelayExpiredCallback() { ...@@ -121,11 +123,14 @@ void AffiliationFetchThrottler::OnBackoffDelayExpiredCallback() {
state_ = delegate_->OnCanSendNetworkRequest() ? FETCH_IN_FLIGHT : IDLE; state_ = delegate_->OnCanSendNetworkRequest() ? FETCH_IN_FLIGHT : IDLE;
} }
void AffiliationFetchThrottler::OnNetworkChanged( void AffiliationFetchThrottler::OnConnectionChanged(
net::NetworkChangeNotifier::ConnectionType type) { network::mojom::ConnectionType type) {
bool old_has_network_connectivity = has_network_connectivity_; bool old_has_network_connectivity = has_network_connectivity_;
has_network_connectivity_ = // We reread the connection type here instead of relying on |type| because
(type != net::NetworkChangeNotifier::CONNECTION_NONE); // NetworkConnectionTracker will call this function an extra time with
// CONNECTION_NONE whenever the connection changes to an online state, even
// if it was already in a different online state.
has_network_connectivity_ = !network_connection_tracker_->IsOffline();
// Only react when network connectivity has been reestablished. // Only react when network connectivity has been reestablished.
if (!has_network_connectivity_ || old_has_network_connectivity) if (!has_network_connectivity_ || old_has_network_connectivity)
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "net/base/backoff_entry.h" #include "net/base/backoff_entry.h"
#include "net/base/network_change_notifier.h" #include "services/network/public/cpp/network_connection_tracker.h"
namespace base { namespace base {
class TickClock; class TickClock;
...@@ -50,7 +50,7 @@ class AffiliationFetchThrottlerDelegate; ...@@ -50,7 +50,7 @@ class AffiliationFetchThrottlerDelegate;
// periods, so that requests will not be held back for too long after // periods, so that requests will not be held back for too long after
// connectivity is restored. // connectivity is restored.
class AffiliationFetchThrottler class AffiliationFetchThrottler
: public net::NetworkChangeNotifier::NetworkChangeObserver { : public network::NetworkConnectionTracker::NetworkConnectionObserver {
public: public:
// Creates an instance that will use |tick_clock| as its tick source, and will // Creates an instance that will use |tick_clock| as its tick source, and will
// post to |task_runner| to call the |delegate|'s OnSendNetworkRequest(). The // post to |task_runner| to call the |delegate|'s OnSendNetworkRequest(). The
...@@ -58,6 +58,7 @@ class AffiliationFetchThrottler ...@@ -58,6 +58,7 @@ class AffiliationFetchThrottler
AffiliationFetchThrottler( AffiliationFetchThrottler(
AffiliationFetchThrottlerDelegate* delegate, AffiliationFetchThrottlerDelegate* delegate,
const scoped_refptr<base::SequencedTaskRunner>& task_runner, const scoped_refptr<base::SequencedTaskRunner>& task_runner,
network::NetworkConnectionTracker* network_connection_tracker,
const base::TickClock* tick_clock); const base::TickClock* tick_clock);
~AffiliationFetchThrottler() override; ~AffiliationFetchThrottler() override;
...@@ -114,11 +115,11 @@ class AffiliationFetchThrottler ...@@ -114,11 +115,11 @@ class AffiliationFetchThrottler
// Called back when the |exponential_backoff_| delay expires. // Called back when the |exponential_backoff_| delay expires.
void OnBackoffDelayExpiredCallback(); void OnBackoffDelayExpiredCallback();
// net::NetworkChangeNotifier::NetworkChangeObserver: // network::NetworkConnectionTracker::NetworkConnectionObserver:
void OnNetworkChanged( void OnConnectionChanged(network::mojom::ConnectionType type) override;
net::NetworkChangeNotifier::ConnectionType type) override;
scoped_refptr<base::SequencedTaskRunner> task_runner_; scoped_refptr<base::SequencedTaskRunner> task_runner_;
network::NetworkConnectionTracker* network_connection_tracker_;
const base::TickClock* tick_clock_; const base::TickClock* tick_clock_;
State state_; State state_;
bool has_network_connectivity_; bool has_network_connectivity_;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "base/time/tick_clock.h" #include "base/time/tick_clock.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler_delegate.h" #include "components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler_delegate.h"
#include "net/base/network_change_notifier.h" #include "services/network/test/test_network_connection_tracker.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace password_manager { namespace password_manager {
...@@ -64,20 +64,24 @@ class MockAffiliationFetchThrottlerDelegate ...@@ -64,20 +64,24 @@ class MockAffiliationFetchThrottlerDelegate
class AffiliationFetchThrottlerTest : public testing::Test { class AffiliationFetchThrottlerTest : public testing::Test {
public: public:
AffiliationFetchThrottlerTest() AffiliationFetchThrottlerTest()
: network_change_notifier_(net::NetworkChangeNotifier::CreateMock()), : task_runner_(new base::TestMockTimeTaskRunner),
task_runner_(new base::TestMockTimeTaskRunner), mock_delegate_(task_runner_->GetMockTickClock()) {
mock_delegate_(task_runner_->GetMockTickClock()) {} SimulateHasNetworkConnectivity(true);
}
~AffiliationFetchThrottlerTest() override {} ~AffiliationFetchThrottlerTest() override {}
std::unique_ptr<AffiliationFetchThrottler> CreateThrottler() { std::unique_ptr<AffiliationFetchThrottler> CreateThrottler() {
return std::make_unique<AffiliationFetchThrottler>( return std::make_unique<AffiliationFetchThrottler>(
&mock_delegate_, task_runner_, task_runner_->GetMockTickClock()); &mock_delegate_, task_runner_,
network::TestNetworkConnectionTracker::GetInstance(),
task_runner_->GetMockTickClock());
} }
void SimulateHasNetworkConnectivity(bool has_connectivity) { void SimulateHasNetworkConnectivity(bool has_connectivity) {
net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests( network::TestNetworkConnectionTracker::GetInstance()->SetConnectionType(
has_connectivity ? net::NetworkChangeNotifier::CONNECTION_UNKNOWN has_connectivity ? network::mojom::ConnectionType::CONNECTION_ETHERNET
: net::NetworkChangeNotifier::CONNECTION_NONE); : network::mojom::ConnectionType::CONNECTION_NONE);
scoped_task_environment_.RunUntilIdle(); scoped_task_environment_.RunUntilIdle();
} }
...@@ -121,10 +125,9 @@ class AffiliationFetchThrottlerTest : public testing::Test { ...@@ -121,10 +125,9 @@ class AffiliationFetchThrottlerTest : public testing::Test {
} }
private: private:
// Needed because NetworkChangeNotifier uses base::ObserverList, which // Needed because NetworkConnectionTracker uses base::ObserverList, which
// notifies observers on the sequence from which they have registered. // notifies observers on the sequence from which they have registered.
base::test::ScopedTaskEnvironment scoped_task_environment_; base::test::ScopedTaskEnvironment scoped_task_environment_;
std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_;
scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
MockAffiliationFetchThrottlerDelegate mock_delegate_; MockAffiliationFetchThrottlerDelegate mock_delegate_;
......
...@@ -35,6 +35,7 @@ AffiliationService::~AffiliationService() { ...@@ -35,6 +35,7 @@ AffiliationService::~AffiliationService() {
void AffiliationService::Initialize( void AffiliationService::Initialize(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
network::NetworkConnectionTracker* network_connection_tracker,
const base::FilePath& db_path) { const base::FilePath& db_path) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!backend_); DCHECK(!backend_);
...@@ -43,9 +44,10 @@ void AffiliationService::Initialize( ...@@ -43,9 +44,10 @@ void AffiliationService::Initialize(
base::DefaultTickClock::GetInstance()); base::DefaultTickClock::GetInstance());
backend_task_runner_->PostTask( backend_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&AffiliationBackend::Initialize, FROM_HERE,
base::Unretained(backend_), base::BindOnce(&AffiliationBackend::Initialize,
url_loader_factory->Clone(), db_path)); base::Unretained(backend_), url_loader_factory->Clone(),
base::Unretained(network_connection_tracker), db_path));
} }
void AffiliationService::GetAffiliationsAndBranding( void AffiliationService::GetAffiliationsAndBranding(
......
...@@ -21,6 +21,7 @@ class SequencedTaskRunner; ...@@ -21,6 +21,7 @@ class SequencedTaskRunner;
} // namespace base } // namespace base
namespace network { namespace network {
class NetworkConnectionTracker;
class SharedURLLoaderFactory; class SharedURLLoaderFactory;
} // namespace network } // namespace network
...@@ -107,6 +108,7 @@ class AffiliationService : public KeyedService { ...@@ -107,6 +108,7 @@ class AffiliationService : public KeyedService {
// thread corresponding to |backend_task_runner_|. // thread corresponding to |backend_task_runner_|.
void Initialize( void Initialize(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
network::NetworkConnectionTracker* network_connection_tracker,
const base::FilePath& db_path); const base::FilePath& db_path);
// Looks up facets affiliated with the facet identified by |facet_uri| and // Looks up facets affiliated with the facet identified by |facet_uri| and
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "components/password_manager/core/browser/android_affiliation/mock_affiliation_consumer.h" #include "components/password_manager/core/browser/android_affiliation/mock_affiliation_consumer.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_network_connection_tracker.h"
#include "services/network/test/test_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -79,8 +80,13 @@ class AffiliationServiceTest : public testing::Test { ...@@ -79,8 +80,13 @@ class AffiliationServiceTest : public testing::Test {
void SetUp() override { void SetUp() override {
base::FilePath database_path; base::FilePath database_path;
ASSERT_TRUE(CreateTemporaryFile(&database_path)); ASSERT_TRUE(CreateTemporaryFile(&database_path));
network::TestNetworkConnectionTracker* network_connection_tracker =
network::TestNetworkConnectionTracker::GetInstance();
network_connection_tracker->SetConnectionType(
network::mojom::ConnectionType::CONNECTION_ETHERNET);
service_.reset(new AffiliationService(background_task_runner())); service_.reset(new AffiliationService(background_task_runner()));
service_->Initialize(test_shared_loader_factory_, database_path); service_->Initialize(test_shared_loader_factory_,
network_connection_tracker, database_path);
// Note: the background task runner is purposely not pumped here, so that // Note: the background task runner is purposely not pumped here, so that
// the tests also verify that the service can be used synchronously right // the tests also verify that the service can be used synchronously right
// away after having been constructed. // away after having been constructed.
......
...@@ -30,6 +30,7 @@ bool ShouldAffiliationBasedMatchingBeActive(syncer::SyncService* sync_service) { ...@@ -30,6 +30,7 @@ bool ShouldAffiliationBasedMatchingBeActive(syncer::SyncService* sync_service) {
void ActivateAffiliationBasedMatching( void ActivateAffiliationBasedMatching(
PasswordStore* password_store, PasswordStore* password_store,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
network::NetworkConnectionTracker* network_connection_tracker,
const base::FilePath& db_path) { const base::FilePath& db_path) {
// Subsequent instances of the AffiliationService must use the same sequenced // Subsequent instances of the AffiliationService must use the same sequenced
// task runner for their backends. This guarantees that the backend of the // task runner for their backends. This guarantees that the backend of the
...@@ -46,7 +47,8 @@ void ActivateAffiliationBasedMatching( ...@@ -46,7 +47,8 @@ void ActivateAffiliationBasedMatching(
// is owned by the PasswordStore. // is owned by the PasswordStore.
std::unique_ptr<AffiliationService> affiliation_service( std::unique_ptr<AffiliationService> affiliation_service(
new AffiliationService(backend_task_runner)); new AffiliationService(backend_task_runner));
affiliation_service->Initialize(std::move(url_loader_factory), db_path); affiliation_service->Initialize(std::move(url_loader_factory),
network_connection_tracker, db_path);
std::unique_ptr<AffiliatedMatchHelper> affiliated_match_helper( std::unique_ptr<AffiliatedMatchHelper> affiliated_match_helper(
new AffiliatedMatchHelper(password_store, new AffiliatedMatchHelper(password_store,
std::move(affiliation_service))); std::move(affiliation_service)));
...@@ -67,6 +69,7 @@ void ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState( ...@@ -67,6 +69,7 @@ void ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState(
PasswordStore* password_store, PasswordStore* password_store,
syncer::SyncService* sync_service, syncer::SyncService* sync_service,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
network::NetworkConnectionTracker* network_connection_tracker,
const base::FilePath& profile_path) { const base::FilePath& profile_path) {
DCHECK(password_store); DCHECK(password_store);
...@@ -76,9 +79,9 @@ void ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState( ...@@ -76,9 +79,9 @@ void ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState(
password_store->affiliated_match_helper() != nullptr; password_store->affiliated_match_helper() != nullptr;
if (matching_should_be_active && !matching_is_active) { if (matching_should_be_active && !matching_is_active) {
ActivateAffiliationBasedMatching(password_store, ActivateAffiliationBasedMatching(
std::move(url_loader_factory), password_store, std::move(url_loader_factory),
GetAffiliationDatabasePath(profile_path)); network_connection_tracker, GetAffiliationDatabasePath(profile_path));
} else if (!matching_should_be_active && matching_is_active) { } else if (!matching_should_be_active && matching_is_active) {
password_store->SetAffiliatedMatchHelper(nullptr); password_store->SetAffiliatedMatchHelper(nullptr);
} }
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#include "components/sync/model/syncable_service.h" #include "components/sync/model/syncable_service.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
namespace network {
class NetworkConnectionTracker;
} // namespace network
namespace password_manager { namespace password_manager {
// Activates or deactivates affiliation-based matching for |password_store|, // Activates or deactivates affiliation-based matching for |password_store|,
...@@ -28,6 +32,7 @@ void ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState( ...@@ -28,6 +32,7 @@ void ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState(
PasswordStore* password_store, PasswordStore* password_store,
syncer::SyncService* sync_service, syncer::SyncService* sync_service,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
network::NetworkConnectionTracker* network_connection_tracker,
const base::FilePath& profile_path); const base::FilePath& profile_path);
// Creates a LoginDatabase. Looks in |profile_path| for the database file. // Creates a LoginDatabase. Looks in |profile_path| for the database file.
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "components/password_manager/core/browser/password_store_default.h" #include "components/password_manager/core/browser/password_store_default.h"
#include "components/password_manager/core/browser/password_store_factory_util.h" #include "components/password_manager/core/browser/password_store_factory_util.h"
#include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service.h"
#include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/sync/glue/sync_start_util.h" #include "ios/chrome/browser/sync/glue/sync_start_util.h"
...@@ -60,6 +61,7 @@ void IOSChromePasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged( ...@@ -60,6 +61,7 @@ void IOSChromePasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged(
password_manager::ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState( password_manager::ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState(
password_store.get(), sync_service, password_store.get(), sync_service,
browser_state->GetSharedURLLoaderFactory(), browser_state->GetSharedURLLoaderFactory(),
GetApplicationContext()->GetNetworkConnectionTracker(),
browser_state->GetStatePath()); browser_state->GetStatePath());
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "components/password_manager/core/browser/login_database.h" #include "components/password_manager/core/browser/login_database.h"
#include "components/password_manager/core/browser/password_store_default.h" #include "components/password_manager/core/browser/password_store_default.h"
#include "components/password_manager/core/browser/password_store_factory_util.h" #include "components/password_manager/core/browser/password_store_factory_util.h"
#include "ios/web_view/internal/app/application_context.h"
#import "ios/web_view/internal/sync/web_view_profile_sync_service_factory.h" #import "ios/web_view/internal/sync/web_view_profile_sync_service_factory.h"
#include "ios/web_view/internal/web_view_browser_state.h" #include "ios/web_view/internal/web_view_browser_state.h"
#include "ios/web_view/internal/webdata_services/web_view_web_data_service_wrapper_factory.h" #include "ios/web_view/internal/webdata_services/web_view_web_data_service_wrapper_factory.h"
...@@ -63,6 +64,7 @@ void WebViewPasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged( ...@@ -63,6 +64,7 @@ void WebViewPasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged(
password_manager::ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState( password_manager::ToggleAffiliationBasedMatchingBasedOnPasswordSyncedState(
password_store.get(), sync_service, password_store.get(), sync_service,
browser_state->GetSharedURLLoaderFactory(), browser_state->GetSharedURLLoaderFactory(),
ApplicationContext::GetInstance()->GetNetworkConnectionTracker(),
browser_state->GetStatePath()); browser_state->GetStatePath());
} }
......
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