Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp

Issue 2858773002: Revert of PaymentHandler: Implement PaymentInstruments.keys(). (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/PaymentInstruments.h" 5 #include "modules/payments/PaymentInstruments.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/ScriptPromise.h" 10 #include "bindings/core/v8/ScriptPromise.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); 82 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
83 ScriptPromise promise = resolver->Promise(); 83 ScriptPromise promise = resolver->Promise();
84 84
85 manager_->GetPaymentInstrument( 85 manager_->GetPaymentInstrument(
86 instrument_key, ConvertToBaseCallback(WTF::Bind( 86 instrument_key, ConvertToBaseCallback(WTF::Bind(
87 &PaymentInstruments::onGetPaymentInstrument, 87 &PaymentInstruments::onGetPaymentInstrument,
88 WrapPersistent(this), WrapPersistent(resolver)))); 88 WrapPersistent(this), WrapPersistent(resolver))));
89 return promise; 89 return promise;
90 } 90 }
91 91
92 ScriptPromise PaymentInstruments::keys(ScriptState* script_state) { 92 ScriptPromise PaymentInstruments::keys() {
93 if (!manager_.is_bound()) { 93 NOTIMPLEMENTED();
94 return ScriptPromise::RejectWithDOMException( 94 return ScriptPromise();
95 script_state,
96 DOMException::Create(kInvalidStateError, kPaymentManagerUnavailable));
97 }
98
99 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
100 ScriptPromise promise = resolver->Promise();
101
102 manager_->KeysOfPaymentInstruments(ConvertToBaseCallback(
103 WTF::Bind(&PaymentInstruments::onKeysOfPaymentInstruments,
104 WrapPersistent(this), WrapPersistent(resolver))));
105 return promise;
106 } 95 }
107 96
108 ScriptPromise PaymentInstruments::has(ScriptState* script_state, 97 ScriptPromise PaymentInstruments::has(ScriptState* script_state,
109 const String& instrument_key) { 98 const String& instrument_key) {
110 if (!manager_.is_bound()) { 99 if (!manager_.is_bound()) {
111 return ScriptPromise::RejectWithDOMException( 100 return ScriptPromise::RejectWithDOMException(
112 script_state, 101 script_state,
113 DOMException::Create(kInvalidStateError, kPaymentManagerUnavailable)); 102 DOMException::Create(kInvalidStateError, kPaymentManagerUnavailable));
114 } 103 }
115 104
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 stored_instrument->stringified_capabilities, 190 stored_instrument->stringified_capabilities,
202 exception_state))); 191 exception_state)));
203 if (exception_state.HadException()) { 192 if (exception_state.HadException()) {
204 exception_state.Reject(resolver); 193 exception_state.Reject(resolver);
205 return; 194 return;
206 } 195 }
207 } 196 }
208 resolver->Resolve(instrument); 197 resolver->Resolve(instrument);
209 } 198 }
210 199
211 void PaymentInstruments::onKeysOfPaymentInstruments(
212 ScriptPromiseResolver* resolver,
213 const Vector<String>& keys,
214 payments::mojom::blink::PaymentHandlerStatus status) {
215 DCHECK(resolver);
216 if (rejectError(resolver, status))
217 return;
218 resolver->Resolve(keys);
219 }
220
221 void PaymentInstruments::onHasPaymentInstrument( 200 void PaymentInstruments::onHasPaymentInstrument(
222 ScriptPromiseResolver* resolver, 201 ScriptPromiseResolver* resolver,
223 payments::mojom::blink::PaymentHandlerStatus status) { 202 payments::mojom::blink::PaymentHandlerStatus status) {
224 DCHECK(resolver); 203 DCHECK(resolver);
225 resolver->Resolve(status == 204 resolver->Resolve(status ==
226 payments::mojom::blink::PaymentHandlerStatus::SUCCESS); 205 payments::mojom::blink::PaymentHandlerStatus::SUCCESS);
227 } 206 }
228 207
229 void PaymentInstruments::onSetPaymentInstrument( 208 void PaymentInstruments::onSetPaymentInstrument(
230 ScriptPromiseResolver* resolver, 209 ScriptPromiseResolver* resolver,
231 payments::mojom::blink::PaymentHandlerStatus status) { 210 payments::mojom::blink::PaymentHandlerStatus status) {
232 DCHECK(resolver); 211 DCHECK(resolver);
233 if (rejectError(resolver, status)) 212 if (rejectError(resolver, status))
234 return; 213 return;
235 resolver->Resolve(); 214 resolver->Resolve();
236 } 215 }
237 216
238 } // namespace blink 217 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698