-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial implementation of Web Payments feature #143
base: wolvic
Are you sure you want to change the base?
Conversation
@@ -363,6 +363,10 @@ blink::mojom::PermissionStatus WolvicPermissionManager::GetPermissionStatus( | |||
blink::PermissionType permission, | |||
const GURL& requesting_origin, | |||
const GURL& embedding_origin) { | |||
if (permission == blink::PermissionType::PAYMENT_HANDLER) { | |||
return blink::mojom::PermissionStatus::GRANTED; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think we should still ask for this permission anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, I guess, but bear in mind that Chrome Desktop doesn't do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a matter of fact, the Chromium code that handles the web payment method manifest downloading expect the permission to be GRANTED by default. I don't think we can ask the user about this.
This patch adds onCreateNewPaymentHandler method in WebContentsObserver to deliver the payment handler's WebContents to Wolvic side.
The PaymentUiService should not re-use the WindowAndroid instance from the original WebContents and, instead, must create a new one for the main activity. Additionally, this change also implements the close() method, so that we can properly destroy the newly created WebContent instance for the payment handler.
We need to detect when the user dismiss the Payment Handler UI so that we can close properly the ongoing Payment Request. For now observing the the destruction of the PaymentHandler's WebContent instance is the only way we have to detect this situation.
This new class can be used to create instance of Tabs that can handle PaymentHandler work-flow. The Client interface provides an API to control the window's life-cycle.
c2a4ce7
to
11df912
Compare
…Client interface Now that the WolvicPaymentUiService implements the PaymentRequestUI.Client interface we can use it to control the PaymentHandler window's life-cycle. In order to do this, we need to create the PaymentRequestUI instance in Chromium, and getting it in Wolvic from the WebContents received in the onCreateNewPaymentHandler. The current design didn't allow to call the WebContentImpl::getOrSetUSerData method, becuase it'd require the PaymentRequestUI to have a sinple consrtuctor with just one WebContents parameter. Additionally, this WebContents instance might be already initialized, which is not the case of our current design. So the solution to implement the PaymentRequestUI::getFromContents was to add a new public method in the WebContentsImpl class to directly set userData as an already created object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR provides a very basic implementation of the Payment Request API and the minimum viable logic for the Payment Handlers.
In the latter case, it provides support just to launch a new tab that loads a service worker provided by the payment request.
A new modal window will be launched to load the service worker. This window is controlled by the WolvicPaymentUiService class, which will handle the service-worker result of the generate the payment request response.
A new ServiceTabLauncher class is implemented in Wolvic in order to launch this kind of modal dialogs.
Finally, this PR adds a new method in the WebContentsObserver to notify Wolvic when the new payment-handler WebContent instance is ready to be loaded in the modal window.