OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/payments/PaymentAppManager.h" | 5 #include "modules/payments/PaymentAppManager.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "modules/payments/PaymentAppManifest.h" | 10 #include "modules/payments/PaymentAppManifest.h" |
11 #include "modules/payments/PaymentAppOption.h" | 11 #include "modules/payments/PaymentAppOption.h" |
12 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 12 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
13 #include "platform/mojo/MojoHelper.h" | 13 #include "platform/mojo/MojoHelper.h" |
14 #include "public/platform/InterfaceProvider.h" | 14 #include "public/platform/InterfaceProvider.h" |
15 #include "public/platform/Platform.h" | 15 #include "public/platform/Platform.h" |
16 | 16 |
17 namespace mojo { | 17 namespace mojo { |
18 | 18 |
19 using payments::mojom::blink::PaymentAppManifest; | 19 using payments::mojom::blink::PaymentAppManifest; |
20 using payments::mojom::blink::PaymentAppManifestPtr; | 20 using payments::mojom::blink::PaymentAppManifestPtr; |
21 using payments::mojom::blink::PaymentAppOption; | 21 using payments::mojom::blink::PaymentAppOption; |
22 using payments::mojom::blink::PaymentAppOptionPtr; | 22 using payments::mojom::blink::PaymentAppOptionPtr; |
23 | 23 |
24 template <> | 24 template <> |
25 struct TypeConverter<PaymentAppOptionPtr, blink::PaymentAppOption> { | 25 struct TypeConverter<PaymentAppOptionPtr, blink::PaymentAppOption> { |
26 static PaymentAppOptionPtr Convert(const blink::PaymentAppOption& input) { | 26 static PaymentAppOptionPtr Convert(const blink::PaymentAppOption& input) { |
27 PaymentAppOptionPtr output = PaymentAppOption::New(); | 27 PaymentAppOptionPtr output = PaymentAppOption::New(); |
28 output->label = input.hasLabel() ? input.label() : WTF::emptyString(); | 28 output->name = input.hasName() ? input.name() : WTF::emptyString(); |
29 output->icon = input.hasIcon() ? input.icon() : WTF::String(); | 29 output->icon = input.hasIcon() ? input.icon() : WTF::String(); |
30 output->id = input.hasId() ? input.id() : WTF::emptyString(); | 30 output->id = input.hasId() ? input.id() : WTF::emptyString(); |
31 output->enabled_methods = WTF::Vector<WTF::String>(input.enabledMethods()); | 31 output->enabled_methods = WTF::Vector<WTF::String>(input.enabledMethods()); |
32 return output; | 32 return output; |
33 } | 33 } |
34 }; | 34 }; |
35 | 35 |
36 template <> | 36 template <> |
37 struct TypeConverter<PaymentAppManifestPtr, blink::PaymentAppManifest> { | 37 struct TypeConverter<PaymentAppManifestPtr, blink::PaymentAppManifest> { |
38 static PaymentAppManifestPtr Convert(const blink::PaymentAppManifest& input) { | 38 static PaymentAppManifestPtr Convert(const blink::PaymentAppManifest& input) { |
39 PaymentAppManifestPtr output = PaymentAppManifest::New(); | 39 PaymentAppManifestPtr output = PaymentAppManifest::New(); |
40 output->label = input.hasLabel() ? input.label() : WTF::emptyString(); | 40 output->name = input.hasName() ? input.name() : WTF::emptyString(); |
41 output->icon = input.hasIcon() ? input.icon() : WTF::String(); | 41 output->icon = input.hasIcon() ? input.icon() : WTF::String(); |
42 if (input.hasOptions()) { | 42 if (input.hasOptions()) { |
43 for (size_t i = 0; i < input.options().size(); ++i) { | 43 for (size_t i = 0; i < input.options().size(); ++i) { |
44 output->options.append(PaymentAppOption::From(input.options()[i])); | 44 output->options.append(PaymentAppOption::From(input.options()[i])); |
45 } | 45 } |
46 } | 46 } |
47 return output; | 47 return output; |
48 } | 48 } |
49 }; | 49 }; |
50 | 50 |
51 template <> | 51 template <> |
52 struct TypeConverter<blink::PaymentAppManifest, PaymentAppManifestPtr> { | 52 struct TypeConverter<blink::PaymentAppManifest, PaymentAppManifestPtr> { |
53 static blink::PaymentAppManifest Convert(const PaymentAppManifestPtr& input) { | 53 static blink::PaymentAppManifest Convert(const PaymentAppManifestPtr& input) { |
54 blink::PaymentAppManifest output; | 54 blink::PaymentAppManifest output; |
55 output.setLabel(input->label); | 55 output.setName(input->name); |
56 output.setIcon(input->icon); | 56 output.setIcon(input->icon); |
57 blink::HeapVector<blink::PaymentAppOption> options; | 57 blink::HeapVector<blink::PaymentAppOption> options; |
58 for (const auto& option : input->options) { | 58 for (const auto& option : input->options) { |
59 options.append(mojo::ConvertTo<blink::PaymentAppOption>(option)); | 59 options.append(mojo::ConvertTo<blink::PaymentAppOption>(option)); |
60 } | 60 } |
61 output.setOptions(options); | 61 output.setOptions(options); |
62 return output; | 62 return output; |
63 } | 63 } |
64 }; | 64 }; |
65 | 65 |
66 template <> | 66 template <> |
67 struct TypeConverter<blink::PaymentAppOption, PaymentAppOptionPtr> { | 67 struct TypeConverter<blink::PaymentAppOption, PaymentAppOptionPtr> { |
68 static blink::PaymentAppOption Convert(const PaymentAppOptionPtr& input) { | 68 static blink::PaymentAppOption Convert(const PaymentAppOptionPtr& input) { |
69 blink::PaymentAppOption output; | 69 blink::PaymentAppOption output; |
70 output.setLabel(input->label); | 70 output.setName(input->name); |
71 output.setIcon(input->icon); | 71 output.setIcon(input->icon); |
72 output.setId(input->id); | 72 output.setId(input->id); |
73 Vector<WTF::String> enabledMethods; | 73 Vector<WTF::String> enabledMethods; |
74 for (const auto& method : input->enabled_methods) { | 74 for (const auto& method : input->enabled_methods) { |
75 enabledMethods.append(method); | 75 enabledMethods.append(method); |
76 } | 76 } |
77 output.setEnabledMethods(enabledMethods); | 77 output.setEnabledMethods(enabledMethods); |
78 return output; | 78 return output; |
79 } | 79 } |
80 }; | 80 }; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 void PaymentAppManager::onServiceConnectionError() { | 193 void PaymentAppManager::onServiceConnectionError() { |
194 if (!Platform::current()) { | 194 if (!Platform::current()) { |
195 return; | 195 return; |
196 } | 196 } |
197 | 197 |
198 m_manager.reset(); | 198 m_manager.reset(); |
199 } | 199 } |
200 | 200 |
201 } // namespace blink | 201 } // namespace blink |
OLD | NEW |