| 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 #ifndef COMPONENTS_PAYMENTS_CONTENT_UTILITY_PAYMENT_MANIFEST_PARSER_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_UTILITY_PAYMENT_MANIFEST_PARSER_H_ |
| 6 #define COMPONENTS_PAYMENTS_CONTENT_UTILITY_PAYMENT_MANIFEST_PARSER_H_ | 6 #define COMPONENTS_PAYMENTS_CONTENT_UTILITY_PAYMENT_MANIFEST_PARSER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "components/payments/content/payment_manifest_parser.mojom.h" | 12 #include "components/payments/content/payment_manifest_parser.mojom.h" |
| 13 #include "url/gurl.h" |
| 13 | 14 |
| 14 namespace payments { | 15 namespace payments { |
| 15 | 16 |
| 16 // Parser for payment manifests. Should be used only in a utility process. | 17 // Parser for payment method manifests and web app manifests. Should be used |
| 18 // only in a sandboxed utility process. |
| 17 // | 19 // |
| 18 // Example valid manifest structure: | 20 // Example valid payment method manifest structure: |
| 19 // | 21 // |
| 20 // { | 22 // { |
| 21 // "android": [{ | 23 // "default_applications": ["https://bobpay.com/payment-app.json"], |
| 22 // "package": "com.bobpay.app", | 24 // "supported_origins": ["https://alicepay.com"] // Not yet parsed or used. |
| 23 // "version": 1, | 25 // } |
| 24 // "sha256_cert_fingerprints": ["12:34:56:78:90:AB:CD:EF"] | 26 // |
| 27 // Example valid web app manifest structure: |
| 28 // |
| 29 // { |
| 30 // "related_applications": [{ |
| 31 // "platform": "play", |
| 32 // "id": "com.bobpay.app", |
| 33 // "min_version": "1", |
| 34 // "fingerprint": [{ |
| 35 // "type": "sha256_cert", |
| 36 // "value": "91:5C:88:65:FF:C4:E8:20:CF:F7:3E:C8:64:D0:95:F0:06:19:2E:A6" |
| 37 // }] |
| 25 // }] | 38 // }] |
| 26 // } | 39 // } |
| 27 // | 40 // |
| 28 // Spec: | 41 // Spec: |
| 29 // https://docs.google.com/document/d/1izV4uC-tiRJG3JLooqY3YRLU22tYOsLTNq0P_InPJ
eE/edit#heading=h.cjp3jlnl47h5 | 42 // https://docs.google.com/document/d/1izV4uC-tiRJG3JLooqY3YRLU22tYOsLTNq0P_InPJ
eE |
| 30 class PaymentManifestParser : public mojom::PaymentManifestParser { | 43 class PaymentManifestParser : public mojom::PaymentManifestParser { |
| 31 public: | 44 public: |
| 32 static void Create(mojom::PaymentManifestParserRequest request); | 45 static void Create(mojom::PaymentManifestParserRequest request); |
| 33 | 46 |
| 47 static std::vector<GURL> ParsePaymentMethodManifestIntoVector( |
| 48 const std::string& input); |
| 49 |
| 34 // The return value is move-only, so no copying occurs. | 50 // The return value is move-only, so no copying occurs. |
| 35 static std::vector<mojom::PaymentManifestSectionPtr> ParseIntoVector( | 51 static std::vector<mojom::WebAppManifestSectionPtr> |
| 36 const std::string& input); | 52 ParseWebAppManifestIntoVector(const std::string& input); |
| 37 | 53 |
| 38 PaymentManifestParser(); | 54 PaymentManifestParser(); |
| 39 ~PaymentManifestParser() override; | 55 ~PaymentManifestParser() override; |
| 40 | 56 |
| 41 // mojom::PaymentManifestParser | 57 // mojom::PaymentManifestParser |
| 42 void Parse(const std::string& content, | 58 void ParsePaymentMethodManifest( |
| 43 const ParseCallback& callback) override; | 59 const std::string& content, |
| 60 const ParsePaymentMethodManifestCallback& callback) override; |
| 61 void ParseWebAppManifest(const std::string& content, |
| 62 const ParseWebAppManifestCallback& callack) override; |
| 44 | 63 |
| 45 private: | 64 private: |
| 46 DISALLOW_COPY_AND_ASSIGN(PaymentManifestParser); | 65 DISALLOW_COPY_AND_ASSIGN(PaymentManifestParser); |
| 47 }; | 66 }; |
| 48 | 67 |
| 49 } // namespace payments | 68 } // namespace payments |
| 50 | 69 |
| 51 #endif // COMPONENTS_PAYMENTS_CONTENT_UTILITY_PAYMENT_MANIFEST_PARSER_H_ | 70 #endif // COMPONENTS_PAYMENTS_CONTENT_UTILITY_PAYMENT_MANIFEST_PARSER_H_ |
| OLD | NEW |