Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ | |
| 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/observer_list.h" | |
| 13 #include "components/payments/content/payment_request.mojom.h" | |
| 14 | |
| 15 namespace payments { | |
| 16 | |
| 17 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.
| |
| 18 public: | |
| 19 class Observer { | |
| 20 public: | |
| 21 // Called when the provided spec (details, options, method_data) is invalid. | |
| 22 virtual void OnInvalidSpecProvided() = 0; | |
| 23 | |
| 24 protected: | |
| 25 virtual ~Observer() {} | |
| 26 }; | |
| 27 | |
| 28 PaymentRequestSpec( | |
| 29 mojom::PaymentOptionsPtr options, | |
| 30 mojom::PaymentDetailsPtr details, | |
| 31 const std::vector<mojom::PaymentMethodDataPtr>& method_data, | |
| 32 PaymentRequestSpec::Observer* observer); | |
| 33 ~PaymentRequestSpec(); | |
| 34 | |
| 35 void AddObserver(Observer* observer); | |
| 36 void RemoveObserver(Observer* observer); | |
| 37 | |
| 38 bool request_shipping() const { return options_->request_shipping; } | |
| 39 bool request_payer_name() const { return options_->request_payer_name; } | |
| 40 bool request_payer_phone() const { return options_->request_payer_phone; } | |
| 41 bool request_payer_email() const { return options_->request_payer_email; } | |
| 42 | |
| 43 const std::vector<std::string>& supported_card_networks() { | |
| 44 return supported_card_networks_; | |
| 45 } | |
| 46 | |
| 47 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.
| |
| 48 mojom::PaymentOptions* options() { return options_.get(); } | |
| 49 | |
| 50 private: | |
| 51 // Validates the |method_data| and fills |supported_card_networks_|. | |
| 52 void PopulateValidatedMethodData( | |
| 53 const std::vector<mojom::PaymentMethodDataPtr>& method_data); | |
| 54 | |
| 55 // Will notify all observers that the spec is invalid. | |
| 56 void NotifyOnInvalidSpecProvided(); | |
| 57 | |
| 58 mojom::PaymentOptionsPtr options_; | |
| 59 mojom::PaymentDetailsPtr details_; | |
| 60 | |
| 61 // A list of supported basic card networks, in order that they were specified | |
| 62 // by the merchant. | |
| 63 std::vector<std::string> supported_card_networks_; | |
| 64 | |
| 65 base::ObserverList<Observer> observers_; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); | |
| 68 }; | |
| 69 | |
| 70 } // namespace payments | |
| 71 | |
| 72 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ | |
| OLD | NEW |