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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 const WriteManifestCallback& callback, | 57 const WriteManifestCallback& callback, |
58 ServiceWorkerStatusCode status, | 58 ServiceWorkerStatusCode status, |
59 scoped_refptr<ServiceWorkerRegistration> registration) { | 59 scoped_refptr<ServiceWorkerRegistration> registration) { |
60 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 60 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
61 if (status != SERVICE_WORKER_OK) { | 61 if (status != SERVICE_WORKER_OK) { |
62 callback.Run(payments::mojom::PaymentAppManifestError::NO_ACTIVE_WORKER); | 62 callback.Run(payments::mojom::PaymentAppManifestError::NO_ACTIVE_WORKER); |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 PaymentAppManifestProto manifest_proto; | 66 PaymentAppManifestProto manifest_proto; |
67 manifest_proto.set_label(manifest->label); | 67 manifest_proto.set_name(manifest->name); |
68 if (manifest->icon) | 68 if (manifest->icon) |
69 manifest_proto.set_icon(manifest->icon.value()); | 69 manifest_proto.set_icon(manifest->icon.value()); |
70 | 70 |
71 for (const auto& option : manifest->options) { | 71 for (const auto& option : manifest->options) { |
72 PaymentAppOptionProto* option_proto = manifest_proto.add_options(); | 72 PaymentAppOptionProto* option_proto = manifest_proto.add_options(); |
73 option_proto->set_label(option->label); | 73 option_proto->set_name(option->name); |
74 if (option->icon) | 74 if (option->icon) |
75 option_proto->set_icon(option->icon.value()); | 75 option_proto->set_icon(option->icon.value()); |
76 option_proto->set_id(option->id); | 76 option_proto->set_id(option->id); |
77 for (const auto& method : option->enabled_methods) { | 77 for (const auto& method : option->enabled_methods) { |
78 option_proto->add_enabled_methods(method); | 78 option_proto->add_enabled_methods(method); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 std::string serialized; | 82 std::string serialized; |
83 bool success = manifest_proto.SerializeToString(&serialized); | 83 bool success = manifest_proto.SerializeToString(&serialized); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 bool success = manifest_proto.ParseFromString(data[0]); | 131 bool success = manifest_proto.ParseFromString(data[0]); |
132 if (!success) { | 132 if (!success) { |
133 callback.Run(payments::mojom::PaymentAppManifest::New(), | 133 callback.Run(payments::mojom::PaymentAppManifest::New(), |
134 payments::mojom::PaymentAppManifestError:: | 134 payments::mojom::PaymentAppManifestError:: |
135 MANIFEST_STORAGE_OPERATION_FAILED); | 135 MANIFEST_STORAGE_OPERATION_FAILED); |
136 return; | 136 return; |
137 } | 137 } |
138 | 138 |
139 payments::mojom::PaymentAppManifestPtr manifest = | 139 payments::mojom::PaymentAppManifestPtr manifest = |
140 payments::mojom::PaymentAppManifest::New(); | 140 payments::mojom::PaymentAppManifest::New(); |
141 manifest->label = manifest_proto.label(); | 141 manifest->name = manifest_proto.name(); |
142 if (manifest_proto.has_icon()) | 142 if (manifest_proto.has_icon()) |
143 manifest->icon = manifest_proto.icon(); | 143 manifest->icon = manifest_proto.icon(); |
144 for (const auto& option_proto : manifest_proto.options()) { | 144 for (const auto& option_proto : manifest_proto.options()) { |
145 payments::mojom::PaymentAppOptionPtr option = | 145 payments::mojom::PaymentAppOptionPtr option = |
146 payments::mojom::PaymentAppOption::New(); | 146 payments::mojom::PaymentAppOption::New(); |
147 option->label = option_proto.label(); | 147 option->name = option_proto.name(); |
148 if (option_proto.has_icon()) | 148 if (option_proto.has_icon()) |
149 option->icon = option_proto.icon(); | 149 option->icon = option_proto.icon(); |
150 option->id = option_proto.id(); | 150 option->id = option_proto.id(); |
151 for (const auto& method : option_proto.enabled_methods()) | 151 for (const auto& method : option_proto.enabled_methods()) |
152 option->enabled_methods.push_back(method); | 152 option->enabled_methods.push_back(method); |
153 manifest->options.push_back(std::move(option)); | 153 manifest->options.push_back(std::move(option)); |
154 } | 154 } |
155 | 155 |
156 callback.Run(std::move(manifest), | 156 callback.Run(std::move(manifest), |
157 payments::mojom::PaymentAppManifestError::NONE); | 157 payments::mojom::PaymentAppManifestError::NONE); |
158 } | 158 } |
159 | 159 |
160 } // namespace content | 160 } // namespace content |
OLD | NEW |