OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/common/service_worker/service_worker_type_converters.h" | 5 #include "content/common/service_worker/service_worker_type_converters.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace mojo { | 9 namespace mojo { |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... | |
22 } else if (status == blink::mojom::ServiceWorkerEventStatus::ABORTED) { | 22 } else if (status == blink::mojom::ServiceWorkerEventStatus::ABORTED) { |
23 status_code = content::SERVICE_WORKER_ERROR_ABORT; | 23 status_code = content::SERVICE_WORKER_ERROR_ABORT; |
24 } else { | 24 } else { |
25 // We received an unexpected value back. This can theoretically happen as | 25 // We received an unexpected value back. This can theoretically happen as |
26 // mojo doesn't validate enum values. | 26 // mojo doesn't validate enum values. |
27 status_code = content::SERVICE_WORKER_ERROR_IPC_FAILED; | 27 status_code = content::SERVICE_WORKER_ERROR_IPC_FAILED; |
28 } | 28 } |
29 return status_code; | 29 return status_code; |
30 } | 30 } |
31 | 31 |
32 blink::WebPaymentAppRequestData | |
33 TypeConverter<blink::WebPaymentAppRequestData, | |
34 payments::mojom::PaymentAppRequestDataPtr>:: | |
35 Convert(const payments::mojom::PaymentAppRequestDataPtr& input) { | |
36 blink::WebPaymentAppRequestData output; | |
37 | |
38 output.origin = blink::WebString::fromUTF8(input->origin.spec()); | |
39 | |
40 output.methodData = | |
41 blink::WebVector<blink::WebPaymentMethodData>(input->methodData.size()); | |
42 for (size_t i = 0; i < input->methodData.size(); i++) { | |
43 output.methodData[i] = mojo::ConvertTo<blink::WebPaymentMethodData>( | |
44 std::move(input->methodData[i])); | |
45 } | |
46 | |
47 output.total = mojo::ConvertTo<blink::WebPaymentItem>(input->total); | |
48 | |
49 output.modifiers = blink::WebVector<blink::WebPaymentDetailsModifier>( | |
50 input->modifiers.size()); | |
51 for (size_t i = 0; i < input->modifiers.size(); i++) { | |
52 output.modifiers[i] = | |
53 mojo::ConvertTo<blink::WebPaymentDetailsModifier>(input->modifiers[i]); | |
54 } | |
55 | |
56 output.optionId = blink::WebString::fromUTF8(input->optionId); | |
57 | |
58 return output; | |
59 } | |
60 | |
61 blink::WebPaymentMethodData | |
62 TypeConverter<blink::WebPaymentMethodData, | |
63 payments::mojom::PaymentMethodDataPtr>:: | |
64 Convert(const payments::mojom::PaymentMethodDataPtr& input) { | |
65 blink::WebPaymentMethodData output; | |
66 | |
67 output.supportedMethods = | |
68 blink::WebVector<blink::WebString>(input->supported_methods.size()); | |
69 for (size_t i = 0; i < input->supported_methods.size(); i++) { | |
70 output.supportedMethods[i] = | |
71 blink::WebString::fromUTF8(input->supported_methods[i]); | |
72 } | |
73 | |
74 output.stringifiedData = blink::WebString::fromUTF8(input->stringified_data); | |
75 | |
76 return output; | |
77 } | |
78 | |
79 blink::WebPaymentItem | |
80 TypeConverter<blink::WebPaymentItem, payments::mojom::PaymentItemPtr>::Convert( | |
81 const payments::mojom::PaymentItemPtr& input) { | |
82 blink::WebPaymentItem output; | |
83 output.label = blink::WebString::fromUTF8(input->label); | |
84 output.amount = | |
85 mojo::ConvertTo<blink::WebPaymentCurrencyAmount>(input->amount); | |
86 output.pending = input->pending; | |
87 return output; | |
88 } | |
89 | |
90 blink::WebPaymentCurrencyAmount | |
91 TypeConverter<blink::WebPaymentCurrencyAmount, | |
92 payments::mojom::PaymentCurrencyAmountPtr>:: | |
93 Convert(const payments::mojom::PaymentCurrencyAmountPtr& input) { | |
94 blink::WebPaymentCurrencyAmount output; | |
95 output.currency = blink::WebString::fromUTF8(input->currency); | |
96 output.value = blink::WebString::fromUTF8(input->value); | |
97 output.currencySystem = blink::WebString::fromUTF8(input->value); | |
tommyt
2017/01/23 09:35:18
input->currency_system is an optional value, so th
zino
2017/02/01 09:24:48
As you know, this is already resolved in the follo
tommyt
2017/02/01 09:42:00
Good, but you still need to change "input->value"
zino
2017/02/01 10:07:05
Done.
Great review!
| |
98 return output; | |
99 } | |
100 | |
101 blink::WebPaymentDetailsModifier | |
102 TypeConverter<blink::WebPaymentDetailsModifier, | |
103 payments::mojom::PaymentDetailsModifierPtr>:: | |
104 Convert(const payments::mojom::PaymentDetailsModifierPtr& input) { | |
105 blink::WebPaymentDetailsModifier output; | |
106 | |
107 output.supportedMethods = blink::WebVector<blink::WebString>( | |
108 input->method_data->supported_methods.size()); | |
109 for (size_t i = 0; i < input->method_data->supported_methods.size(); i++) { | |
110 output.supportedMethods[i] = | |
111 blink::WebString::fromUTF8(input->method_data->supported_methods[i]); | |
112 } | |
113 | |
114 output.total = mojo::ConvertTo<blink::WebPaymentItem>(input->total); | |
115 | |
116 output.additionalDisplayItems = blink::WebVector<blink::WebPaymentItem>( | |
117 input->additional_display_items.size()); | |
118 for (size_t i = 0; i < input->additional_display_items.size(); i++) { | |
119 output.additionalDisplayItems[i] = mojo::ConvertTo<blink::WebPaymentItem>( | |
120 input->additional_display_items[i]); | |
121 } | |
122 | |
123 output.stringifiedData = | |
124 blink::WebString::fromUTF8(input->method_data->stringified_data); | |
125 | |
126 return output; | |
127 } | |
128 | |
32 } // namespace | 129 } // namespace |
OLD | NEW |