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

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

Issue 2586203003: PaymentApp: Remove scope_url parameter from Get/SetManifest methods. (Closed)
Patch Set: rebased Created 3 years, 12 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
« no previous file with comments | « content/browser/payments/payment_app_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "modules/payments/PaymentAppManager.h" 5 #include "modules/payments/PaymentAppManager.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "modules/payments/PaymentAppManifest.h" 10 #include "modules/payments/PaymentAppManifest.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (!m_manager) { 94 if (!m_manager) {
95 return ScriptPromise::rejectWithDOMException( 95 return ScriptPromise::rejectWithDOMException(
96 scriptState, DOMException::create(InvalidStateError, 96 scriptState, DOMException::create(InvalidStateError,
97 "Payment app manager unavailable.")); 97 "Payment app manager unavailable."));
98 } 98 }
99 99
100 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 100 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
101 ScriptPromise promise = resolver->promise(); 101 ScriptPromise promise = resolver->promise();
102 102
103 m_manager->SetManifest( 103 m_manager->SetManifest(
104 m_registration->scope(),
105 payments::mojom::blink::PaymentAppManifest::From(manifest), 104 payments::mojom::blink::PaymentAppManifest::From(manifest),
106 convertToBaseCallback(WTF::bind(&PaymentAppManager::onSetManifest, 105 convertToBaseCallback(WTF::bind(&PaymentAppManager::onSetManifest,
107 wrapPersistent(this), 106 wrapPersistent(this),
108 wrapPersistent(resolver)))); 107 wrapPersistent(resolver))));
109 108
110 return promise; 109 return promise;
111 } 110 }
112 111
113 ScriptPromise PaymentAppManager::getManifest(ScriptState* scriptState) { 112 ScriptPromise PaymentAppManager::getManifest(ScriptState* scriptState) {
114 if (!m_manager) { 113 if (!m_manager) {
115 return ScriptPromise::rejectWithDOMException( 114 return ScriptPromise::rejectWithDOMException(
116 scriptState, DOMException::create(InvalidStateError, 115 scriptState, DOMException::create(InvalidStateError,
117 "Payment app manager unavailable.")); 116 "Payment app manager unavailable."));
118 } 117 }
119 118
120 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 119 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
121 ScriptPromise promise = resolver->promise(); 120 ScriptPromise promise = resolver->promise();
122 121
123 m_manager->GetManifest(m_registration->scope(), 122 m_manager->GetManifest(convertToBaseCallback(
124 convertToBaseCallback(WTF::bind( 123 WTF::bind(&PaymentAppManager::onGetManifest, wrapPersistent(this),
125 &PaymentAppManager::onGetManifest, 124 wrapPersistent(resolver))));
126 wrapPersistent(this), wrapPersistent(resolver))));
127 125
128 return promise; 126 return promise;
129 } 127 }
130 128
131 DEFINE_TRACE(PaymentAppManager) { 129 DEFINE_TRACE(PaymentAppManager) {
132 visitor->trace(m_registration); 130 visitor->trace(m_registration);
133 } 131 }
134 132
135 PaymentAppManager::PaymentAppManager(ServiceWorkerRegistration* registration) 133 PaymentAppManager::PaymentAppManager(ServiceWorkerRegistration* registration)
136 : m_registration(registration) { 134 : m_registration(registration) {
137 DCHECK(registration); 135 DCHECK(registration);
138 Platform::current()->interfaceProvider()->getInterface( 136 Platform::current()->interfaceProvider()->getInterface(
139 mojo::GetProxy(&m_manager)); 137 mojo::GetProxy(&m_manager));
140 138
141 m_manager.set_connection_error_handler(convertToBaseCallback(WTF::bind( 139 m_manager.set_connection_error_handler(convertToBaseCallback(WTF::bind(
142 &PaymentAppManager::onServiceConnectionError, wrapWeakPersistent(this)))); 140 &PaymentAppManager::onServiceConnectionError, wrapWeakPersistent(this))));
141
142 m_manager->Init(m_registration->scope());
143 } 143 }
144 144
145 void PaymentAppManager::onSetManifest( 145 void PaymentAppManager::onSetManifest(
146 ScriptPromiseResolver* resolver, 146 ScriptPromiseResolver* resolver,
147 payments::mojom::blink::PaymentAppManifestError error) { 147 payments::mojom::blink::PaymentAppManifestError error) {
148 DCHECK(resolver); 148 DCHECK(resolver);
149 switch (error) { 149 switch (error) {
150 case payments::mojom::blink::PaymentAppManifestError::NONE: 150 case payments::mojom::blink::PaymentAppManifestError::NONE:
151 resolver->resolve(); 151 resolver->resolve();
152 break; 152 break;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 void PaymentAppManager::onServiceConnectionError() { 193 void PaymentAppManager::onServiceConnectionError() {
194 if (!Platform::current()) { 194 if (!Platform::current()) {
195 return; 195 return;
196 } 196 }
197 197
198 m_manager.reset(); 198 m_manager.reset();
199 } 199 }
200 200
201 } // namespace blink 201 } // namespace blink
OLDNEW
« no previous file with comments | « content/browser/payments/payment_app_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698