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

Side by Side Diff: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 2528683002: PaymentApp: Blink side of payment request event dispatching in service worker. (Closed)
Patch Set: test Created 4 years 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 27 matching lines...) Expand all
38 #include "core/dom/MessagePort.h" 38 #include "core/dom/MessagePort.h"
39 #include "core/inspector/ConsoleMessage.h" 39 #include "core/inspector/ConsoleMessage.h"
40 #include "core/origin_trials/OriginTrials.h" 40 #include "core/origin_trials/OriginTrials.h"
41 #include "core/workers/WorkerGlobalScope.h" 41 #include "core/workers/WorkerGlobalScope.h"
42 #include "core/workers/WorkerThread.h" 42 #include "core/workers/WorkerThread.h"
43 #include "modules/background_sync/SyncEvent.h" 43 #include "modules/background_sync/SyncEvent.h"
44 #include "modules/fetch/Headers.h" 44 #include "modules/fetch/Headers.h"
45 #include "modules/notifications/Notification.h" 45 #include "modules/notifications/Notification.h"
46 #include "modules/notifications/NotificationEvent.h" 46 #include "modules/notifications/NotificationEvent.h"
47 #include "modules/notifications/NotificationEventInit.h" 47 #include "modules/notifications/NotificationEventInit.h"
48 #include "modules/payments/PaymentAppRequestData.h"
49 #include "modules/payments/PaymentAppRequestDataConversion.h"
50 #include "modules/payments/PaymentRequestEvent.h"
48 #include "modules/push_messaging/PushEvent.h" 51 #include "modules/push_messaging/PushEvent.h"
49 #include "modules/push_messaging/PushMessageData.h" 52 #include "modules/push_messaging/PushMessageData.h"
50 #include "modules/serviceworkers/ExtendableEvent.h" 53 #include "modules/serviceworkers/ExtendableEvent.h"
51 #include "modules/serviceworkers/ExtendableMessageEvent.h" 54 #include "modules/serviceworkers/ExtendableMessageEvent.h"
52 #include "modules/serviceworkers/FetchEvent.h" 55 #include "modules/serviceworkers/FetchEvent.h"
53 #include "modules/serviceworkers/ForeignFetchEvent.h" 56 #include "modules/serviceworkers/ForeignFetchEvent.h"
54 #include "modules/serviceworkers/InstallEvent.h" 57 #include "modules/serviceworkers/InstallEvent.h"
55 #include "modules/serviceworkers/ServiceWorkerClient.h" 58 #include "modules/serviceworkers/ServiceWorkerClient.h"
56 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 59 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
57 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" 60 #include "modules/serviceworkers/ServiceWorkerWindowClient.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 WTF::currentTime()); 322 WTF::currentTime());
320 return; 323 return;
321 } 324 }
322 WaitUntilObserver* observer = WaitUntilObserver::create( 325 WaitUntilObserver* observer = WaitUntilObserver::create(
323 workerGlobalScope(), WaitUntilObserver::Sync, eventID); 326 workerGlobalScope(), WaitUntilObserver::Sync, eventID);
324 Event* event = SyncEvent::create(EventTypeNames::sync, tag, 327 Event* event = SyncEvent::create(EventTypeNames::sync, tag,
325 lastChance == IsLastChance, observer); 328 lastChance == IsLastChance, observer);
326 workerGlobalScope()->dispatchExtendableEvent(event, observer); 329 workerGlobalScope()->dispatchExtendableEvent(event, observer);
327 } 330 }
328 331
332 void ServiceWorkerGlobalScopeProxy::dispatchPaymentRequestEvent(
333 int eventID,
334 const WebPaymentAppRequestData& webData) {
335 ScriptState::Scope scope(
336 workerGlobalScope()->scriptController()->getScriptState());
337 WaitUntilObserver* observer = WaitUntilObserver::create(
338 workerGlobalScope(), WaitUntilObserver::PaymentRequest, eventID);
339 Event* event = PaymentRequestEvent::create(
340 EventTypeNames::paymentrequest,
341 PaymentAppRequestDataConversion::toPaymentAppRequestData(
342 workerGlobalScope()->scriptController()->getScriptState(), webData),
343 observer);
344 workerGlobalScope()->dispatchExtendableEvent(event, observer);
345 }
346
329 bool ServiceWorkerGlobalScopeProxy::hasFetchEventHandler() { 347 bool ServiceWorkerGlobalScopeProxy::hasFetchEventHandler() {
330 DCHECK(m_workerGlobalScope); 348 DCHECK(m_workerGlobalScope);
331 return m_workerGlobalScope->hasEventListeners(EventTypeNames::fetch); 349 return m_workerGlobalScope->hasEventListeners(EventTypeNames::fetch);
332 } 350 }
333 351
334 void ServiceWorkerGlobalScopeProxy::reportException( 352 void ServiceWorkerGlobalScopeProxy::reportException(
335 const String& errorMessage, 353 const String& errorMessage,
336 std::unique_ptr<SourceLocation> location, 354 std::unique_ptr<SourceLocation> location,
337 int exceptionId) { 355 int exceptionId) {
338 client().reportException(errorMessage, location->lineNumber(), 356 client().reportException(errorMessage, location->lineNumber(),
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 return *m_document; 453 return *m_document;
436 } 454 }
437 455
438 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() 456 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope()
439 const { 457 const {
440 DCHECK(m_workerGlobalScope); 458 DCHECK(m_workerGlobalScope);
441 return m_workerGlobalScope; 459 return m_workerGlobalScope;
442 } 460 }
443 461
444 } // namespace blink 462 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698