| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/payments/content/payment_manifest_downloader.h" | 5 #include "components/payments/content/payment_manifest_downloader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 Delegate* delegate) | 35 Delegate* delegate) |
| 36 : context_(context), | 36 : context_(context), |
| 37 method_name_(method_name), | 37 method_name_(method_name), |
| 38 delegate_(delegate), | 38 delegate_(delegate), |
| 39 is_downloading_http_link_header_(true) { | 39 is_downloading_http_link_header_(true) { |
| 40 DCHECK(IsValidManifestUrl(method_name_)); | 40 DCHECK(IsValidManifestUrl(method_name_)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 PaymentManifestDownloader::~PaymentManifestDownloader() {} | 43 PaymentManifestDownloader::~PaymentManifestDownloader() {} |
| 44 | 44 |
| 45 void PaymentManifestDownloader::Download() { | 45 void PaymentManifestDownloader::DownloadPaymentMethodManifest() { |
| 46 DCHECK(!fetcher_); |
| 47 is_downloading_http_link_header_ = true; |
| 46 InitiateDownload(method_name_, net::URLFetcher::HEAD); | 48 InitiateDownload(method_name_, net::URLFetcher::HEAD); |
| 47 } | 49 } |
| 48 | 50 |
| 51 void PaymentManifestDownloader::DownloadWebAppManifest() { |
| 52 DCHECK(!fetcher_); |
| 53 is_downloading_http_link_header_ = false; |
| 54 InitiateDownload(method_name_, net::URLFetcher::GET); |
| 55 } |
| 56 |
| 49 void PaymentManifestDownloader::InitiateDownload( | 57 void PaymentManifestDownloader::InitiateDownload( |
| 50 const GURL& url, | 58 const GURL& url, |
| 51 net::URLFetcher::RequestType request_type) { | 59 net::URLFetcher::RequestType request_type) { |
| 52 if (!IsValidManifestUrl(url)) { | 60 if (!IsValidManifestUrl(url)) { |
| 53 delegate_->OnManifestDownloadFailure(); | 61 delegate_->OnManifestDownloadFailure(); |
| 54 return; | 62 return; |
| 55 } | 63 } |
| 56 | 64 |
| 57 fetcher_ = net::URLFetcher::Create(0 /* id */, url, request_type, this); | 65 fetcher_ = net::URLFetcher::Create(0 /* id */, url, request_type, this); |
| 58 data_use_measurement::DataUseUserData::AttachToFetcher( | 66 data_use_measurement::DataUseUserData::AttachToFetcher( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (source->GetResponseAsString(&content) && !content.empty()) { | 119 if (source->GetResponseAsString(&content) && !content.empty()) { |
| 112 delegate_->OnManifestDownloadSuccess(content); | 120 delegate_->OnManifestDownloadSuccess(content); |
| 113 return; | 121 return; |
| 114 } | 122 } |
| 115 } | 123 } |
| 116 | 124 |
| 117 delegate_->OnManifestDownloadFailure(); | 125 delegate_->OnManifestDownloadFailure(); |
| 118 } | 126 } |
| 119 | 127 |
| 120 } // namespace payments | 128 } // namespace payments |
| OLD | NEW |