Commit 21d87b8e authored by gogerald's avatar gogerald Committed by Commit Bot

[Payments] Do not override native payment app Ids

Bug: 763417
Change-Id: Ia02e2e00f2e6a315ae16ee8de852e756a79c0de6
Reviewed-on: https://chromium-review.googlesource.com/891978Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532981}
parent 4c3b80a5
...@@ -178,13 +178,29 @@ void ManifestVerifier::OnWebDataServiceRequestDone( ...@@ -178,13 +178,29 @@ void ManifestVerifier::OnWebDataServiceRequestDone(
GURL method_manifest_url = it->second; GURL method_manifest_url = it->second;
cache_request_handles_.erase(it); cache_request_handles_.erase(it);
const std::vector<std::string>& supported_origin_strings = const std::vector<std::string>& cached_strings =
(static_cast<const WDResult<std::vector<std::string>>*>(result.get())) (static_cast<const WDResult<std::vector<std::string>>*>(result.get()))
->GetValue(); ->GetValue();
bool all_origins_supported = std::find(supported_origin_strings.begin(),
supported_origin_strings.end(), bool all_origins_supported = false;
kAllOriginsSupportedIndicator) != std::vector<std::string> native_app_ids;
supported_origin_strings.end(); std::vector<std::string> supported_origin_strings;
for (const auto& origin_or_id : cached_strings) {
// The string could be "*", origin or native payment app package Id on
// Android.
if (origin_or_id == kAllOriginsSupportedIndicator) {
all_origins_supported = true;
continue;
}
if (base::IsStringUTF8(origin_or_id) && GURL(origin_or_id).is_valid()) {
supported_origin_strings.emplace_back(origin_or_id);
} else {
native_app_ids.emplace_back(origin_or_id);
}
}
cached_supported_native_app_ids_[method_manifest_url] = native_app_ids;
EnableMethodManifestUrlForSupportedApps( EnableMethodManifestUrlForSupportedApps(
method_manifest_url, supported_origin_strings, all_origins_supported, method_manifest_url, supported_origin_strings, all_origins_supported,
manifest_url_to_app_origins_map_[method_manifest_url], &apps_, manifest_url_to_app_origins_map_[method_manifest_url], &apps_,
...@@ -256,6 +272,15 @@ void ManifestVerifier::OnPaymentMethodManifestParsed( ...@@ -256,6 +272,15 @@ void ManifestVerifier::OnPaymentMethodManifestParsed(
if (all_origins_supported) if (all_origins_supported)
supported_origin_strings.emplace_back(kAllOriginsSupportedIndicator); supported_origin_strings.emplace_back(kAllOriginsSupportedIndicator);
// Keep Android native payment app Ids in cache.
std::map<GURL, std::vector<std::string>>::const_iterator it =
cached_supported_native_app_ids_.find(method_manifest_url);
if (it != cached_supported_native_app_ids_.end()) {
supported_origin_strings.insert(supported_origin_strings.end(),
it->second.begin(), it->second.end());
}
cache_->AddPaymentMethodManifest(method_manifest_url.spec(), cache_->AddPaymentMethodManifest(method_manifest_url.spec(),
supported_origin_strings); supported_origin_strings);
......
...@@ -134,6 +134,12 @@ class ManifestVerifier final : public WebDataServiceConsumer { ...@@ -134,6 +134,12 @@ class ManifestVerifier final : public WebDataServiceConsumer {
// used. // used.
std::set<GURL> cached_manifest_urls_; std::set<GURL> cached_manifest_urls_;
// The mapping of payment method names to cached native payment app Ids.
// Note that the supported native payment app Ids have been cached for a
// payment method in the same cache in PaymentManifestVerifier.java. Do not
// override them since we do not refresh them in this class.
std::map<GURL, std::vector<std::string>> cached_supported_native_app_ids_;
// The number of manifests that have not been verified yet. A manifest can be // The number of manifests that have not been verified yet. A manifest can be
// either be retrieved from cache or downloaded for verification. Once this // either be retrieved from cache or downloaded for verification. Once this
// number reaches 0, the verification callback is invoked. // number reaches 0, the verification callback is invoked.
......
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