OLD | NEW |
---|---|
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" |
11 #include "bindings/core/v8/ScriptPromiseResolver.h" | 11 #include "bindings/core/v8/ScriptPromiseResolver.h" |
12 #include "bindings/core/v8/V8BindingForCore.h" | 12 #include "bindings/core/v8/V8BindingForCore.h" |
13 #include "core/dom/DOMException.h" | 13 #include "core/dom/DOMException.h" |
14 #include "core/inspector/ConsoleMessage.h" | |
14 #include "modules/payments/PaymentInstrument.h" | 15 #include "modules/payments/PaymentInstrument.h" |
15 #include "modules/payments/PaymentManager.h" | 16 #include "modules/payments/PaymentManager.h" |
16 #include "platform/wtf/Vector.h" | 17 #include "platform/wtf/Vector.h" |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 namespace { | 20 namespace { |
20 | 21 |
21 static const char kPaymentManagerUnavailable[] = "Payment manager unavailable"; | 22 static const char kPaymentManagerUnavailable[] = "Payment manager unavailable"; |
22 | 23 |
23 bool rejectError(ScriptPromiseResolver* resolver, | 24 bool rejectError(ScriptPromiseResolver* resolver, |
(...skipping 15 matching lines...) Expand all Loading... | |
39 return true; | 40 return true; |
40 case payments::mojom::blink::PaymentHandlerStatus::STORAGE_OPERATION_FAILED: | 41 case payments::mojom::blink::PaymentHandlerStatus::STORAGE_OPERATION_FAILED: |
41 resolver->Reject(DOMException::Create(kInvalidStateError, | 42 resolver->Reject(DOMException::Create(kInvalidStateError, |
42 "Storage operation is failed")); | 43 "Storage operation is failed")); |
43 return true; | 44 return true; |
44 case payments::mojom::blink::PaymentHandlerStatus:: | 45 case payments::mojom::blink::PaymentHandlerStatus:: |
45 FETCH_INSTRUMENT_ICON_FAILED: | 46 FETCH_INSTRUMENT_ICON_FAILED: |
46 resolver->Reject(DOMException::Create( | 47 resolver->Reject(DOMException::Create( |
47 kNotFoundError, "Fetch or decode instrument icon failed")); | 48 kNotFoundError, "Fetch or decode instrument icon failed")); |
48 return true; | 49 return true; |
50 case payments::mojom::blink::PaymentHandlerStatus:: | |
51 FETCH_PAYMENT_APP_INFO_FAILED: | |
52 // FETCH_PAYMENT_APP_INFO_FAILED indicates everything works well except | |
53 // fetching payment app's manifest. The alternative value for the payment | |
54 // app will be used in this case, so only show warnning message instead of | |
55 // reject the promise. | |
56 ExecutionContext* context = | |
57 ExecutionContext::From(resolver->GetScriptState()); | |
58 context->AddConsoleMessage( | |
59 ConsoleMessage::Create(kJSMessageSource, kWarningMessageLevel, | |
60 "Fetch payment app's info (manifest or the " | |
61 "field in the manifest) failed.")); | |
please use gerrit instead
2017/06/30 15:43:30
A couple of comments:
1) Payment app is not the t
gogerald1
2017/06/30 16:25:09
Done.
| |
62 return false; | |
49 } | 63 } |
50 NOTREACHED(); | 64 NOTREACHED(); |
51 return false; | 65 return false; |
52 } | 66 } |
53 | 67 |
54 } // namespace | 68 } // namespace |
55 | 69 |
56 PaymentInstruments::PaymentInstruments( | 70 PaymentInstruments::PaymentInstruments( |
57 const payments::mojom::blink::PaymentManagerPtr& manager) | 71 const payments::mojom::blink::PaymentManagerPtr& manager) |
58 : manager_(manager) {} | 72 : manager_(manager) {} |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 void PaymentInstruments::onClearPaymentInstruments( | 298 void PaymentInstruments::onClearPaymentInstruments( |
285 ScriptPromiseResolver* resolver, | 299 ScriptPromiseResolver* resolver, |
286 payments::mojom::blink::PaymentHandlerStatus status) { | 300 payments::mojom::blink::PaymentHandlerStatus status) { |
287 DCHECK(resolver); | 301 DCHECK(resolver); |
288 if (rejectError(resolver, status)) | 302 if (rejectError(resolver, status)) |
289 return; | 303 return; |
290 resolver->Resolve(); | 304 resolver->Resolve(); |
291 } | 305 } |
292 | 306 |
293 } // namespace blink | 307 } // namespace blink |
OLD | NEW |