Commit 75105e41 authored by Nela Kaczmarek's avatar Nela Kaczmarek Committed by Commit Bot

[Passwords] Affiliation Service - change SchemeHostPort to GURL type for...

[Passwords] Affiliation Service - change SchemeHostPort to GURL type for parameters in public methods.

Changes type of parameters in public methods of Affiliation Service from SchemeHostPort to GURL. This change makes AffiliationService compliant with the public interface of ChangePasswordUrlService.

Bug: 1108279
Change-Id: I2b59560f991176ac94ac9a57cc2db5577bd72ab6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379717Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Nela Kaczmarek <nelakaczmarek@google.com>
Cr-Commit-Position: refs/heads/master@{#803171}
parent 6a89ade8
...@@ -11,24 +11,18 @@ ...@@ -11,24 +11,18 @@
class GURL; class GURL;
namespace url {
class SchemeHostPort;
}
namespace password_manager { namespace password_manager {
class AffiliationService : public KeyedService { class AffiliationService : public KeyedService {
public: public:
// Prefetches change password URLs for sites requested. // Prefetches change password URLs for sites requested.
virtual void PrefetchChangePasswordURLs( virtual void PrefetchChangePasswordURLs(const std::vector<GURL>& urls) = 0;
const std::vector<url::SchemeHostPort>& tuple_origins) = 0;
// Clears the result of URLs fetch. // Clears the result of URLs fetch.
virtual void Clear() = 0; virtual void Clear() = 0;
// Returns a URL with change password form for a site requested. // Returns a URL with change password form for a site requested.
virtual GURL GetChangePasswordURL( virtual GURL GetChangePasswordURL(const GURL& url) const = 0;
const url::SchemeHostPort& scheme_host_port) const = 0;
}; };
} // namespace password_manager } // namespace password_manager
......
...@@ -54,10 +54,9 @@ AffiliationServiceImpl::AffiliationServiceImpl( ...@@ -54,10 +54,9 @@ AffiliationServiceImpl::AffiliationServiceImpl(
AffiliationServiceImpl::~AffiliationServiceImpl() = default; AffiliationServiceImpl::~AffiliationServiceImpl() = default;
void AffiliationServiceImpl::PrefetchChangePasswordURLs( void AffiliationServiceImpl::PrefetchChangePasswordURLs(
const std::vector<url::SchemeHostPort>& tuple_origins) { const std::vector<GURL>& urls) {
if (ShouldAffiliationBasedMatchingBeActive(sync_service_)) { if (ShouldAffiliationBasedMatchingBeActive(sync_service_)) {
RequestFacetsAffiliations( RequestFacetsAffiliations(ConvertMissingURLsToFacets(urls),
ConvertMissingSchemeHostPortsToFacets(tuple_origins),
{.change_password_info = true}); {.change_password_info = true});
} }
} }
...@@ -67,9 +66,8 @@ void AffiliationServiceImpl::Clear() { ...@@ -67,9 +66,8 @@ void AffiliationServiceImpl::Clear() {
change_password_urls_.clear(); change_password_urls_.clear();
} }
GURL AffiliationServiceImpl::GetChangePasswordURL( GURL AffiliationServiceImpl::GetChangePasswordURL(const GURL& url) const {
const url::SchemeHostPort& tuple) const { auto it = change_password_urls_.find(url::SchemeHostPort(url));
auto it = change_password_urls_.find(tuple);
return it != change_password_urls_.end() ? it->second : GURL(); return it != change_password_urls_.end() ? it->second : GURL();
} }
...@@ -99,14 +97,16 @@ void AffiliationServiceImpl::OnMalformedResponse() { ...@@ -99,14 +97,16 @@ void AffiliationServiceImpl::OnMalformedResponse() {
requested_tuple_origins_.clear(); requested_tuple_origins_.clear();
} }
std::vector<FacetURI> std::vector<FacetURI> AffiliationServiceImpl::ConvertMissingURLsToFacets(
AffiliationServiceImpl::ConvertMissingSchemeHostPortsToFacets( const std::vector<GURL>& urls) {
const std::vector<url::SchemeHostPort>& tuple_origins) {
std::vector<FacetURI> facets; std::vector<FacetURI> facets;
for (const auto& tuple : tuple_origins) { for (const auto& url : urls) {
if (tuple.IsValid() && !base::Contains(change_password_urls_, tuple)) { if (url.is_valid()) {
requested_tuple_origins_.push_back(tuple); url::SchemeHostPort scheme_host_port(url);
facets.push_back(FacetURI::FromCanonicalSpec(tuple.Serialize())); if (!base::Contains(change_password_urls_, scheme_host_port)) {
requested_tuple_origins_.push_back(std::move(scheme_host_port));
facets.push_back(FacetURI::FromCanonicalSpec(url.spec()));
}
} }
} }
return facets; return facets;
...@@ -117,8 +117,10 @@ AffiliationServiceImpl::ConvertMissingSchemeHostPortsToFacets( ...@@ -117,8 +117,10 @@ AffiliationServiceImpl::ConvertMissingSchemeHostPortsToFacets(
void AffiliationServiceImpl::RequestFacetsAffiliations( void AffiliationServiceImpl::RequestFacetsAffiliations(
const std::vector<FacetURI>& facets, const std::vector<FacetURI>& facets,
const AffiliationFetcherInterface::RequestInfo request_info) { const AffiliationFetcherInterface::RequestInfo request_info) {
if (!facets.empty()) {
fetcher_ = AffiliationFetcher::Create(url_loader_factory_, this); fetcher_ = AffiliationFetcher::Create(url_loader_factory_, this);
fetcher_->StartRequest(facets, request_info); fetcher_->StartRequest(facets, request_info);
}
} }
} // namespace password_manager } // namespace password_manager
...@@ -23,6 +23,10 @@ namespace syncer { ...@@ -23,6 +23,10 @@ namespace syncer {
class SyncService; class SyncService;
} }
namespace url {
class SchemeHostPort;
}
namespace password_manager { namespace password_manager {
class AffiliationServiceImpl : public AffiliationService, class AffiliationServiceImpl : public AffiliationService,
...@@ -36,16 +40,14 @@ class AffiliationServiceImpl : public AffiliationService, ...@@ -36,16 +40,14 @@ class AffiliationServiceImpl : public AffiliationService,
// Prefetches change password URLs and saves them to |change_password_urls_| // Prefetches change password URLs and saves them to |change_password_urls_|
// map. The verification if affiliation based matching is enabled must be // map. The verification if affiliation based matching is enabled must be
// performed. // performed.
void PrefetchChangePasswordURLs( void PrefetchChangePasswordURLs(const std::vector<GURL>& urls) override;
const std::vector<url::SchemeHostPort>& tuple_origins) override;
// Clears the |change_password_urls_| map and cancels prefetch if still // Clears the |change_password_urls_| map and cancels prefetch if still
// running. // running.
void Clear() override; void Clear() override;
// In case no valid URL was found, a method returns an empty URL. // In case no valid URL was found, a method returns an empty URL.
GURL GetChangePasswordURL( GURL GetChangePasswordURL(const GURL& url) const override;
const url::SchemeHostPort& scheme_host_port) const override;
AffiliationFetcherInterface* GetFetcherForTesting() { return fetcher_.get(); } AffiliationFetcherInterface* GetFetcherForTesting() { return fetcher_.get(); }
...@@ -56,10 +58,10 @@ class AffiliationServiceImpl : public AffiliationService, ...@@ -56,10 +58,10 @@ class AffiliationServiceImpl : public AffiliationService,
void OnFetchFailed() override; void OnFetchFailed() override;
void OnMalformedResponse() override; void OnMalformedResponse() override;
// Converts new |tuple_origins| to facets and inserts them to the // Converts new |urls| to facets and inserts them to the
// |change_password_urls_|. // |change_password_urls_|.
std::vector<FacetURI> ConvertMissingSchemeHostPortsToFacets( std::vector<FacetURI> ConvertMissingURLsToFacets(
const std::vector<url::SchemeHostPort>& tuple_origins); const std::vector<GURL>& urls);
// Calls Affiliation Fetcher and starts a request for |facets| affiliations. // Calls Affiliation Fetcher and starts a request for |facets| affiliations.
void RequestFacetsAffiliations( void RequestFacetsAffiliations(
......
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