// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_PAYMENTS_CORE_PAYMENT_MANIFEST_DOWNLOADER_H_ #define COMPONENTS_PAYMENTS_CORE_PAYMENT_MANIFEST_DOWNLOADER_H_ #include <map> #include <memory> #include <string> #include <vector> #include "base/functional/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "services/network/public/mojom/url_response_head.mojom-forward.h" #include "url/gurl.h" #include "url/origin.h" namespace net { class HttpResponseHeaders; struct RedirectInfo; } // namespace net namespace network { class SharedURLLoaderFactory; class SimpleURLLoader; } // namespace network namespace payments { class CSPChecker; class ErrorLogger; // Called on completed download of a manifest |contents| from |url|, which is // the final URL after following the redirects, if any. // // Download failure results in empty contents. Failure to download the manifest // can happen because of the following reasons: // - HTTP response code is not 200. (204 is also allowed for payment method // manifest.) // // In the case of a payment method manifest download, can also fail when: // - More than three redirects. // - Cross-site redirects. // - HTTP GET on the manifest URL returns empty content and: // - HTTP response headers are absent. // - HTTP response headers do not contain Link headers. // - Link header does not contain rel="payment-method-manifest". // - Link header does not contain a valid URL of the same origin. // - After following the Link header: // - There's a redirect. // - HTTP GET returns empty content. // // In the case of a web app manifest download, can also also fail when: // - There's a redirect. // - HTTP GET on the manifest URL returns empty content. PaymentManifestDownloadCallback; // Downloader of the payment method manifest and web-app manifest based on the // payment method name that is a URL with HTTPS scheme, e.g., // https://bobpay.com. // // The downloader follows up to three redirects for the payment method manifest // request only. Three is enough for known legitimate use cases and seems like a // good upper bound. // // The command line must be initialized to use this class in tests, because it // checks for --unsafely-treat-insecure-origin-as-secure=<origin> flag. For // example: // base::CommandLine::Init(0, nullptr); class PaymentManifestDownloader { … }; } // namespace payments #endif // COMPONENTS_PAYMENTS_CORE_PAYMENT_MANIFEST_DOWNLOADER_H_