| 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" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 template <> | 39 template <> |
| 40 struct TypeConverter<PaymentAppManifestPtr, blink::PaymentAppManifest> { | 40 struct TypeConverter<PaymentAppManifestPtr, blink::PaymentAppManifest> { |
| 41 static PaymentAppManifestPtr Convert(const blink::PaymentAppManifest& input) { | 41 static PaymentAppManifestPtr Convert(const blink::PaymentAppManifest& input) { |
| 42 PaymentAppManifestPtr output = PaymentAppManifest::New(); | 42 PaymentAppManifestPtr output = PaymentAppManifest::New(); |
| 43 output->name = input.hasName() ? input.name() : WTF::emptyString(); | 43 output->name = input.hasName() ? input.name() : WTF::emptyString(); |
| 44 output->icon = input.hasIcon() ? input.icon() : WTF::String(); | 44 output->icon = input.hasIcon() ? input.icon() : WTF::String(); |
| 45 if (input.hasOptions()) { | 45 if (input.hasOptions()) { |
| 46 for (size_t i = 0; i < input.options().size(); ++i) { | 46 for (size_t i = 0; i < input.options().size(); ++i) { |
| 47 output->options.append(PaymentAppOption::From(input.options()[i])); | 47 output->options.push_back(PaymentAppOption::From(input.options()[i])); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 return output; | 50 return output; |
| 51 } | 51 } |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 template <> | 54 template <> |
| 55 struct TypeConverter<blink::PaymentAppManifest, PaymentAppManifestPtr> { | 55 struct TypeConverter<blink::PaymentAppManifest, PaymentAppManifestPtr> { |
| 56 static blink::PaymentAppManifest Convert(const PaymentAppManifestPtr& input) { | 56 static blink::PaymentAppManifest Convert(const PaymentAppManifestPtr& input) { |
| 57 blink::PaymentAppManifest output; | 57 blink::PaymentAppManifest output; |
| 58 output.setName(input->name); | 58 output.setName(input->name); |
| 59 output.setIcon(input->icon); | 59 output.setIcon(input->icon); |
| 60 blink::HeapVector<blink::PaymentAppOption> options; | 60 blink::HeapVector<blink::PaymentAppOption> options; |
| 61 for (const auto& option : input->options) { | 61 for (const auto& option : input->options) { |
| 62 options.append(mojo::ConvertTo<blink::PaymentAppOption>(option)); | 62 options.push_back(mojo::ConvertTo<blink::PaymentAppOption>(option)); |
| 63 } | 63 } |
| 64 output.setOptions(options); | 64 output.setOptions(options); |
| 65 return output; | 65 return output; |
| 66 } | 66 } |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 template <> | 69 template <> |
| 70 struct TypeConverter<blink::PaymentAppOption, PaymentAppOptionPtr> { | 70 struct TypeConverter<blink::PaymentAppOption, PaymentAppOptionPtr> { |
| 71 static blink::PaymentAppOption Convert(const PaymentAppOptionPtr& input) { | 71 static blink::PaymentAppOption Convert(const PaymentAppOptionPtr& input) { |
| 72 blink::PaymentAppOption output; | 72 blink::PaymentAppOption output; |
| 73 output.setName(input->name); | 73 output.setName(input->name); |
| 74 output.setIcon(input->icon); | 74 output.setIcon(input->icon); |
| 75 output.setId(input->id); | 75 output.setId(input->id); |
| 76 Vector<WTF::String> enabledMethods; | 76 Vector<WTF::String> enabledMethods; |
| 77 for (const auto& method : input->enabled_methods) { | 77 for (const auto& method : input->enabled_methods) { |
| 78 enabledMethods.append(method); | 78 enabledMethods.push_back(method); |
| 79 } | 79 } |
| 80 output.setEnabledMethods(enabledMethods); | 80 output.setEnabledMethods(enabledMethods); |
| 81 return output; | 81 return output; |
| 82 } | 82 } |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace mojo | 85 } // namespace mojo |
| 86 | 86 |
| 87 namespace blink { | 87 namespace blink { |
| 88 | 88 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 195 |
| 196 void PaymentAppManager::onServiceConnectionError() { | 196 void PaymentAppManager::onServiceConnectionError() { |
| 197 if (!Platform::current()) { | 197 if (!Platform::current()) { |
| 198 return; | 198 return; |
| 199 } | 199 } |
| 200 | 200 |
| 201 m_manager.reset(); | 201 m_manager.reset(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace blink | 204 } // namespace blink |
| OLD | NEW |