Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Architecture #4

Open
sidvishnoi opened this issue Feb 22, 2021 · 0 comments
Open

Architecture #4

sidvishnoi opened this issue Feb 22, 2021 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@sidvishnoi
Copy link
Owner

sidvishnoi commented Feb 22, 2021

Similar to Favicon loading in browser/actors/LinkHandlerChild.jsm, we make use of the JSWindowActor APIs.

browser/actors/WebMonetizationChild.jsm interacts with the document to run the observable mechanics. It is responsible to find the valid monetization element (at any time), running the fetch and process steps and communicating with browser/actors/WebMonetizationParent.jsm.

The MonetizationService in browser/actors/WebMonetizationParent.jsm is responsible for managing and communicating the monetization state across all documents. The WebMonetizationParent can also control the browser UI and manage payment history.

WebMonetizationParent and MonetizationService also communicate start/stop/pause/resume events to the browser extensions with "webmonetization" permission. They're also listen to "completePayment" and "refresh" requests from the extension. All event management is done via the Services.io message passing API.

The extension uses "completePayment(sessionId, amount)" to notify the browser for a completed payment, and the browser in turn dispatches MonetizationProgressEvent to window.monetization for the relevant document. The document can listen to the MonetizationProgressEvent as window.monetization.addEventListener("progress", ev).

The extension can also request a refresh(sessionId) when it deems necessary (primarily on expiration of previous SPSP response). The browser then runs the fetch and process steps for the document/activeEl corresponding to sessionId, stops payments for sessionId (by dispatching a stop(sessionId) to the extension), and starts a new payment (by dispatching a start(newSessionId, newSpspResponse) to the extension). The call to refresh(sessionId) resolves with a newSessionId.

monetization-src CSP directive

See 6ad0f18

MonetizationProgressEvent and Window.Monetization interface

WebIDL interfaces

Implementation

Extension API

@sidvishnoi sidvishnoi added the documentation Improvements or additions to documentation label Feb 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant