Chromium Code Reviews| Index: components/payments/content/payment_request_spec.h |
| diff --git a/components/payments/content/payment_request_spec.h b/components/payments/content/payment_request_spec.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9e28c2ffeaf84f8cb06164dc49ed5559ff36e5f9 |
| --- /dev/null |
| +++ b/components/payments/content/payment_request_spec.h |
| @@ -0,0 +1,72 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ |
| +#define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/observer_list.h" |
| +#include "components/payments/content/payment_request.mojom.h" |
| + |
| +namespace payments { |
| + |
| +class PaymentRequestSpec { |
|
please use gerrit instead
2017/03/14 16:35:21
Please add a comment for the purpose of this class
Mathieu
2017/03/14 18:05:39
Done.
|
| + public: |
| + class Observer { |
| + public: |
| + // Called when the provided spec (details, options, method_data) is invalid. |
| + virtual void OnInvalidSpecProvided() = 0; |
| + |
| + protected: |
| + virtual ~Observer() {} |
| + }; |
| + |
| + PaymentRequestSpec( |
| + mojom::PaymentOptionsPtr options, |
| + mojom::PaymentDetailsPtr details, |
| + const std::vector<mojom::PaymentMethodDataPtr>& method_data, |
| + PaymentRequestSpec::Observer* observer); |
| + ~PaymentRequestSpec(); |
| + |
| + void AddObserver(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| + |
| + bool request_shipping() const { return options_->request_shipping; } |
| + bool request_payer_name() const { return options_->request_payer_name; } |
| + bool request_payer_phone() const { return options_->request_payer_phone; } |
| + bool request_payer_email() const { return options_->request_payer_email; } |
| + |
| + const std::vector<std::string>& supported_card_networks() { |
| + return supported_card_networks_; |
| + } |
| + |
| + mojom::PaymentDetails* details() { return details_.get(); } |
|
please use gerrit instead
2017/03/14 16:35:21
From what I understand, details() and options() sh
Mathieu
2017/03/14 18:05:39
Done.
|
| + mojom::PaymentOptions* options() { return options_.get(); } |
| + |
| + private: |
| + // Validates the |method_data| and fills |supported_card_networks_|. |
| + void PopulateValidatedMethodData( |
| + const std::vector<mojom::PaymentMethodDataPtr>& method_data); |
| + |
| + // Will notify all observers that the spec is invalid. |
| + void NotifyOnInvalidSpecProvided(); |
| + |
| + mojom::PaymentOptionsPtr options_; |
| + mojom::PaymentDetailsPtr details_; |
| + |
| + // A list of supported basic card networks, in order that they were specified |
| + // by the merchant. |
| + std::vector<std::string> supported_card_networks_; |
| + |
| + base::ObserverList<Observer> observers_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); |
| +}; |
| + |
| +} // namespace payments |
| + |
| +#endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ |