| 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 "content/browser/payments/payment_app_database.h" | 5 #include "content/browser/payments/payment_app_database.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/optional.h" | 10 #include "base/optional.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 payments::mojom::PaymentAppManifestPtr DeserializePaymentAppManifest( | 22 payments::mojom::PaymentAppManifestPtr DeserializePaymentAppManifest( |
| 23 const std::string& input) { | 23 const std::string& input) { |
| 24 PaymentAppManifestProto manifest_proto; | 24 PaymentAppManifestProto manifest_proto; |
| 25 bool success = manifest_proto.ParseFromString(input); | 25 bool success = manifest_proto.ParseFromString(input); |
| 26 if (!success) | 26 if (!success) |
| 27 return nullptr; | 27 return nullptr; |
| 28 | 28 |
| 29 payments::mojom::PaymentAppManifestPtr manifest = | 29 payments::mojom::PaymentAppManifestPtr manifest = |
| 30 payments::mojom::PaymentAppManifest::New(); | 30 payments::mojom::PaymentAppManifest::New(); |
| 31 | 31 |
| 32 manifest->label = manifest_proto.label(); | 32 manifest->name = manifest_proto.name(); |
| 33 if (manifest_proto.has_icon()) | 33 if (manifest_proto.has_icon()) |
| 34 manifest->icon = manifest_proto.icon(); | 34 manifest->icon = manifest_proto.icon(); |
| 35 for (const auto& option_proto : manifest_proto.options()) { | 35 for (const auto& option_proto : manifest_proto.options()) { |
| 36 payments::mojom::PaymentAppOptionPtr option = | 36 payments::mojom::PaymentAppOptionPtr option = |
| 37 payments::mojom::PaymentAppOption::New(); | 37 payments::mojom::PaymentAppOption::New(); |
| 38 option->label = option_proto.label(); | 38 option->name = option_proto.name(); |
| 39 if (option_proto.has_icon()) | 39 if (option_proto.has_icon()) |
| 40 option->icon = option_proto.icon(); | 40 option->icon = option_proto.icon(); |
| 41 option->id = option_proto.id(); | 41 option->id = option_proto.id(); |
| 42 for (const auto& method : option_proto.enabled_methods()) | 42 for (const auto& method : option_proto.enabled_methods()) |
| 43 option->enabled_methods.push_back(method); | 43 option->enabled_methods.push_back(method); |
| 44 manifest->options.push_back(std::move(option)); | 44 manifest->options.push_back(std::move(option)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 return manifest; | 47 return manifest; |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool SerializePaymentAppManifest( | 50 bool SerializePaymentAppManifest( |
| 51 payments::mojom::PaymentAppManifestPtr manifest, | 51 payments::mojom::PaymentAppManifestPtr manifest, |
| 52 std::string* output) { | 52 std::string* output) { |
| 53 DCHECK(manifest); | 53 DCHECK(manifest); |
| 54 | 54 |
| 55 PaymentAppManifestProto manifest_proto; | 55 PaymentAppManifestProto manifest_proto; |
| 56 manifest_proto.set_label(manifest->label); | 56 manifest_proto.set_name(manifest->name); |
| 57 if (manifest->icon) | 57 if (manifest->icon) |
| 58 manifest_proto.set_icon(manifest->icon.value()); | 58 manifest_proto.set_icon(manifest->icon.value()); |
| 59 | 59 |
| 60 for (const auto& option : manifest->options) { | 60 for (const auto& option : manifest->options) { |
| 61 PaymentAppOptionProto* option_proto = manifest_proto.add_options(); | 61 PaymentAppOptionProto* option_proto = manifest_proto.add_options(); |
| 62 option_proto->set_label(option->label); | 62 option_proto->set_name(option->name); |
| 63 if (option->icon) | 63 if (option->icon) |
| 64 option_proto->set_icon(option->icon.value()); | 64 option_proto->set_icon(option->icon.value()); |
| 65 option_proto->set_id(option->id); | 65 option_proto->set_id(option->id); |
| 66 for (const auto& method : option->enabled_methods) { | 66 for (const auto& method : option->enabled_methods) { |
| 67 option_proto->add_enabled_methods(method); | 67 option_proto->add_enabled_methods(method); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 return manifest_proto.SerializeToString(output); | 71 return manifest_proto.SerializeToString(output); |
| 72 } | 72 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 payments::mojom::PaymentAppManifestError:: | 169 payments::mojom::PaymentAppManifestError:: |
| 170 MANIFEST_STORAGE_OPERATION_FAILED); | 170 MANIFEST_STORAGE_OPERATION_FAILED); |
| 171 return; | 171 return; |
| 172 } | 172 } |
| 173 | 173 |
| 174 callback.Run(std::move(manifest), | 174 callback.Run(std::move(manifest), |
| 175 payments::mojom::PaymentAppManifestError::NONE); | 175 payments::mojom::PaymentAppManifestError::NONE); |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace content | 178 } // namespace content |
| OLD | NEW |