Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Unified Diff: components/payments/content/payment_request.cc

Issue 2859613002: Disable web payments API on blob: and data: schemes. (Closed)
Patch Set: Fix up Android test Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/payments/content/payment_request.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/payments/content/payment_request.cc
diff --git a/components/payments/content/payment_request.cc b/components/payments/content/payment_request.cc
index 68da7ff714a86963414c53c99fe4d04bb5fcbb54..7c9b49ab02588ffbd778570d6772efe4f126174a 100644
--- a/components/payments/content/payment_request.cc
+++ b/components/payments/content/payment_request.cc
@@ -48,17 +48,28 @@ void PaymentRequest::Init(mojom::PaymentRequestClientPtr client,
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
client_ = std::move(client);
- if (!OriginSecurityChecker::IsOriginSecure(
- delegate_->GetLastCommittedURL())) {
+ const GURL last_committed_url = delegate_->GetLastCommittedURL();
+ if (!OriginSecurityChecker::IsOriginSecure(last_committed_url)) {
LOG(ERROR) << "Not in a secure origin";
OnConnectionTerminated();
return;
}
- if (OriginSecurityChecker::IsSchemeCryptographic(
- delegate_->GetLastCommittedURL()) &&
- !delegate_->IsSslCertificateValid()) {
+ bool allowed_origin =
+ OriginSecurityChecker::IsSchemeCryptographic(last_committed_url) ||
+ OriginSecurityChecker::IsOriginLocalhostOrFile(last_committed_url);
+ if (!allowed_origin) {
+ LOG(ERROR) << "Only localhost, file://, and cryptographic scheme origins "
+ "allowed";
+ }
+
+ bool invalid_ssl =
+ OriginSecurityChecker::IsSchemeCryptographic(last_committed_url) &&
+ !delegate_->IsSslCertificateValid();
+ if (invalid_ssl)
LOG(ERROR) << "SSL certificate is not valid";
+
+ if (!allowed_origin || invalid_ssl) {
// Don't show UI. Resolve .canMakepayment() with "false". Reject .show()
// with "NotSupportedError".
spec_ = base::MakeUnique<PaymentRequestSpec>(
@@ -190,6 +201,8 @@ void PaymentRequest::UserCancelled() {
// We close all bindings and ask to be destroyed.
client_.reset();
binding_.Close();
+ if (observer_for_testing_)
+ observer_for_testing_->OnConnectionTerminated();
manager_->DestroyRequest(this);
}
@@ -202,6 +215,8 @@ void PaymentRequest::OnConnectionTerminated() {
client_.reset();
binding_.Close();
delegate_->CloseDialog();
+ if (observer_for_testing_)
+ observer_for_testing_->OnConnectionTerminated();
manager_->DestroyRequest(this);
}
« no previous file with comments | « components/payments/content/payment_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698