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

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

Issue 2958333002: [Payments] Implement web payment app manifest (Closed)
Patch Set: rename and comments Created 3 years, 5 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"
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
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 handler's name and/or icon from its web app manifest.
54 // The origin or name will be used to label this payment handler in
55 // UI in this case, so only show warnning message instead of reject the
56 // promise.
57 ExecutionContext* context =
58 ExecutionContext::From(resolver->GetScriptState());
59 context->AddConsoleMessage(ConsoleMessage::Create(
60 kJSMessageSource, kWarningMessageLevel,
61 "Unable to fetch payment handler's name and icon from its web app "
62 "manifest. User may not recognize this payment handler in UI, "
63 "because it will be labeled only by its origin."));
64 return false;
49 } 65 }
50 NOTREACHED(); 66 NOTREACHED();
51 return false; 67 return false;
52 } 68 }
53 69
54 } // namespace 70 } // namespace
55 71
56 PaymentInstruments::PaymentInstruments( 72 PaymentInstruments::PaymentInstruments(
57 const payments::mojom::blink::PaymentManagerPtr& manager) 73 const payments::mojom::blink::PaymentManagerPtr& manager)
58 : manager_(manager) {} 74 : manager_(manager) {}
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 void PaymentInstruments::onClearPaymentInstruments( 300 void PaymentInstruments::onClearPaymentInstruments(
285 ScriptPromiseResolver* resolver, 301 ScriptPromiseResolver* resolver,
286 payments::mojom::blink::PaymentHandlerStatus status) { 302 payments::mojom::blink::PaymentHandlerStatus status) {
287 DCHECK(resolver); 303 DCHECK(resolver);
288 if (rejectError(resolver, status)) 304 if (rejectError(resolver, status))
289 return; 305 return;
290 resolver->Resolve(); 306 resolver->Resolve();
291 } 307 }
292 308
293 } // namespace blink 309 } // namespace blink
OLDNEW
« no previous file with comments | « content/test/data/payments/payment_app_invocation.html ('k') | third_party/WebKit/Source/modules/payments/PaymentManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698