Commit cd94cfda authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Commit Bot

Access PaymentAppProvider with paymentRequestWebContents

Change:
* Fixed the issue of not being able to launch payment handler twice.
The cause is that when PaymentHandler UI is opened and closed, the
payment handler's PaymentAppProvider was used, instead of the
merchant's.
* Changed PaymentAppProvider to make it one per merchant's WebContents,
not one per payment handler's WebContents.
* Rename WebContents PaymentHandler's codebase to make it better
distinguish between the merchant's and the paymentHandler's.
* Move PaymentAppProvider::SetOpenedWindow() from
service_worker_client_utils into PaymentRequestImpl -->
ServiceWorkerPaymentAppBridge.

Bug: 1131874

Change-Id: I831fec0f3cce0d19abf49d23ccf1e61689afe33a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2434101Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarLiquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811554}
parent 4b732658
......@@ -708,6 +708,10 @@ public class PaymentRequestImpl
WebContents paymentHandlerWebContents = mPaymentUIsManager.showPaymentHandlerUI(
url, mComponentPaymentRequestImpl.isOffTheRecord());
if (paymentHandlerWebContents != null) {
ServiceWorkerPaymentAppBridge.onOpeningPaymentAppWindow(
/*paymentRequestWebContents=*/mWebContents,
/*paymentHandlerWebContents=*/paymentHandlerWebContents);
// UKM for payment app origin should get recorded only when the origin of the invoked
// payment app is shown to the user.
mJourneyLogger.setPaymentAppUkmSourceId(mInvokedPaymentApp.getUkmSourceId());
......
......@@ -110,18 +110,20 @@ public class ServiceWorkerPaymentAppBridge {
@Override
public void onDidFinishNavigation(Tab tab, NavigationHandle navigationHandle) {
// Notify closing payment app window so as to abort payment if unsecure.
WebContents webContents = tab.getWebContents();
if (!SslValidityChecker.isValidPageInPaymentHandlerWindow(webContents)) {
onClosingPaymentAppWindowForInsecureNavigation(webContents);
WebContents paymentRequestWebContents = tab.getWebContents();
if (!SslValidityChecker.isValidPageInPaymentHandlerWindow(
paymentRequestWebContents)) {
onClosingPaymentAppWindowForInsecureNavigation(paymentRequestWebContents);
}
}
@Override
public void onSSLStateUpdated(Tab tab) {
// Notify closing payment app window so as to abort payment if unsecure.
WebContents webContents = tab.getWebContents();
if (!SslValidityChecker.isValidPageInPaymentHandlerWindow(webContents)) {
onClosingPaymentAppWindowForInsecureNavigation(webContents);
WebContents paymentRequestWebContents = tab.getWebContents();
if (!SslValidityChecker.isValidPageInPaymentHandlerWindow(
paymentRequestWebContents)) {
onClosingPaymentAppWindowForInsecureNavigation(paymentRequestWebContents);
}
}
});
......@@ -130,23 +132,39 @@ public class ServiceWorkerPaymentAppBridge {
/**
* Notify closing the opened payment app window for insecure navigation.
*
* @param webContents The web contents in the opened window.
* @param paymentRequestWebContents The web contents in the opened window.
*/
public static void onClosingPaymentAppWindowForInsecureNavigation(WebContents webContents) {
if (webContents.isDestroyed()) return;
ServiceWorkerPaymentAppBridgeJni.get().onClosingPaymentAppWindow(
webContents, PaymentEventResponseType.PAYMENT_HANDLER_INSECURE_NAVIGATION);
public static void onClosingPaymentAppWindowForInsecureNavigation(
WebContents paymentRequestWebContents) {
if (paymentRequestWebContents.isDestroyed()) return;
ServiceWorkerPaymentAppBridgeJni.get().onClosingPaymentAppWindow(paymentRequestWebContents,
PaymentEventResponseType.PAYMENT_HANDLER_INSECURE_NAVIGATION);
}
/**
* Notify closing the opened payment app window.
*
* @param webContents The web contents in the opened window. Can be null.
* @param paymentRequestWebContents The web contents in the opened window. Can be null.
*/
public static void onClosingPaymentAppWindow(@Nullable WebContents webContents) {
if (webContents == null || webContents.isDestroyed()) return;
public static void onClosingPaymentAppWindow(@Nullable WebContents paymentRequestWebContents) {
if (paymentRequestWebContents == null || paymentRequestWebContents.isDestroyed()) return;
ServiceWorkerPaymentAppBridgeJni.get().onClosingPaymentAppWindow(
webContents, PaymentEventResponseType.PAYMENT_HANDLER_WINDOW_CLOSING);
paymentRequestWebContents, PaymentEventResponseType.PAYMENT_HANDLER_WINDOW_CLOSING);
}
/**
* Called when payment handler's window is being opened.
*
* @param paymentRequestWebContents The web contents of the merchant's frame, cannot be null.
* @param paymentHandlerWebContents The web contents of the payment handler, cannot be null.
*/
public static void onOpeningPaymentAppWindow(
WebContents paymentRequestWebContents, WebContents paymentHandlerWebContents) {
if (paymentHandlerWebContents == null || paymentHandlerWebContents.isDestroyed()) return;
if (paymentRequestWebContents == null || paymentRequestWebContents.isDestroyed()) return;
ServiceWorkerPaymentAppBridgeJni.get().onOpeningPaymentAppWindow(
/*paymentRequestWebContents=*/paymentRequestWebContents,
/*paymentHandlerWebContents=*/paymentHandlerWebContents);
}
/**
......@@ -189,7 +207,9 @@ public class ServiceWorkerPaymentAppBridge {
interface Natives {
void hasServiceWorkerPaymentApps(HasServiceWorkerPaymentAppsCallback callback);
void getServiceWorkerPaymentAppsInfo(GetServiceWorkerPaymentAppsInfoCallback callback);
void onClosingPaymentAppWindow(WebContents webContents, int reason);
void onClosingPaymentAppWindow(WebContents paymentRequestWebContents, int reason);
void onOpeningPaymentAppWindow(
WebContents paymentRequestWebContents, WebContents paymentHandlerWebContents);
long getSourceIdForPaymentAppFromScope(GURL swScope);
}
}
......@@ -79,8 +79,10 @@ public class PaymentHandlerCoordinator {
PropertyModel model = new PropertyModel.Builder(PaymentHandlerProperties.ALL_KEYS).build();
PaymentHandlerMediator mediator = new PaymentHandlerMediator(model, this::hide,
mPaymentHandlerWebContents, uiObserver, activity.getActivityTab().getView(),
mToolbarCoordinator.getToolbarHeightPx(), activity.getLifecycleDispatcher(),
/*paymentRequestWebContents=*/paymentRequestWebContents,
/*paymentHandlerWebContents*/ mPaymentHandlerWebContents, uiObserver,
activity.getActivityTab().getView(), mToolbarCoordinator.getToolbarHeightPx(),
activity.getLifecycleDispatcher(),
BottomSheetControllerProvider.from(activity.getWindowAndroid()));
activity.getWindow().getDecorView().addOnLayoutChangeListener(mediator);
BottomSheetController bottomSheetController =
......
......@@ -46,11 +46,8 @@ import java.lang.annotation.RetentionPolicy;
private final PropertyModel mModel;
// Whenever invoked, invoked outside of the WebContentsObserver callbacks.
private final Runnable mHider;
// Postfixes with "Ref" to distinguish from mWebContent in WebContentsObserver. Although
// referencing the same object, mWebContentsRef is preferable to WebContents here because
// mWebContents (a weak ref) requires null checks, while mWebContentsRef is guaranteed to be not
// null.
private final WebContents mWebContentsRef;
private final WebContents mPaymentRequestWebContents;
private final WebContents mPaymentHandlerWebContents;
private final PaymentHandlerUiObserver mPaymentHandlerUiObserver;
// Used to postpone execution of a callback to avoid destroy objects (e.g., WebContents) in
// their own methods.
......@@ -82,7 +79,8 @@ import java.lang.annotation.RetentionPolicy;
* payment handler component.
* @param hider The callback to clean up {@link PaymentHandlerCoordinator} when the sheet is
* hidden.
* @param webContents The web-contents that loads the payment app.
* @param paymentRequestWebContents The WebContents of the merchant's frame.
* @param paymentHandlerWebContents The WebContents of the payment handler.
* @param observer The {@link PaymentHandlerUiObserver} that observes this Payment Handler UI.
* @param tabView The view of the main tab.
* @param toolbarViewHeightPx The height of the toolbar view in px.
......@@ -91,14 +89,16 @@ import java.lang.annotation.RetentionPolicy;
* @param sheetController A {@link BottomSheetController} to show UI in.
*/
/* package */ PaymentHandlerMediator(PropertyModel model, Runnable hider,
WebContents webContents, PaymentHandlerUiObserver observer, View tabView,
int toolbarViewHeightPx, ActivityLifecycleDispatcher activityLifeCycleDispatcher,
WebContents paymentRequestWebContents, WebContents paymentHandlerWebContents,
PaymentHandlerUiObserver observer, View tabView, int toolbarViewHeightPx,
ActivityLifecycleDispatcher activityLifeCycleDispatcher,
BottomSheetController sheetController) {
super(webContents);
assert webContents != null;
super(paymentHandlerWebContents);
assert paymentHandlerWebContents != null;
mTabView = tabView;
mBottomSheetController = sheetController;
mWebContentsRef = webContents;
mPaymentRequestWebContents = paymentRequestWebContents;
mPaymentHandlerWebContents = paymentHandlerWebContents;
mToolbarViewHeightPx = toolbarViewHeightPx;
mModel = model;
mModel.set(PaymentHandlerProperties.BACK_PRESS_CALLBACK, this::onSystemBackButtonClicked);
......@@ -166,7 +166,7 @@ import java.lang.annotation.RetentionPolicy;
private void showScrim() {
// Using an empty scrim observer is to avoid the dismissal of the bottom-sheet on tapping.
ChromeActivity activity = ChromeActivity.fromWebContents(mWebContentsRef);
ChromeActivity activity = ChromeActivity.fromWebContents(mPaymentHandlerWebContents);
assert activity != null;
PropertyModel params = mBottomSheetController.createScrimParams();
......@@ -206,7 +206,7 @@ import java.lang.annotation.RetentionPolicy;
switch (mCloseReason) {
case CloseReason.INSECURE_NAVIGATION:
ServiceWorkerPaymentAppBridge.onClosingPaymentAppWindowForInsecureNavigation(
mWebContentsRef);
mPaymentRequestWebContents);
break;
case CloseReason.USER:
// Intentional fallthrough.
......@@ -214,7 +214,7 @@ import java.lang.annotation.RetentionPolicy;
// Intentional fallthrough.
// TODO(crbug.com/1017926): Respond to service worker with the net error.
case CloseReason.ACTIVITY_DIED:
ServiceWorkerPaymentAppBridge.onClosingPaymentAppWindow(mWebContentsRef);
ServiceWorkerPaymentAppBridge.onClosingPaymentAppWindow(mPaymentRequestWebContents);
break;
case CloseReason.OTHERS:
// No need to notify ServiceWorkerPaymentAppBridge when merchant aborts the
......@@ -230,7 +230,7 @@ import java.lang.annotation.RetentionPolicy;
}
private void hideScrim() {
ChromeActivity activity = ChromeActivity.fromWebContents(mWebContentsRef);
ChromeActivity activity = ChromeActivity.fromWebContents(mPaymentHandlerWebContents);
// activity would be null when this method is triggered by activity being destroyed.
if (activity == null) return;
......@@ -255,7 +255,7 @@ import java.lang.annotation.RetentionPolicy;
}
private void closeIfInsecure() {
if (!SslValidityChecker.isValidPageInPaymentHandlerWindow(mWebContentsRef)) {
if (!SslValidityChecker.isValidPageInPaymentHandlerWindow(mPaymentHandlerWebContents)) {
closeUIForInsecureNavigation();
}
}
......@@ -284,7 +284,7 @@ import java.lang.annotation.RetentionPolicy;
}
private void onSystemBackButtonClicked() {
NavigationController navigation = mWebContentsRef.getNavigationController();
NavigationController navigation = mPaymentHandlerWebContents.getNavigationController();
if (navigation.canGoBack()) navigation.goBack();
}
}
......@@ -121,16 +121,35 @@ static void JNI_ServiceWorkerPaymentAppBridge_GetServiceWorkerPaymentAppsInfo(
static void JNI_ServiceWorkerPaymentAppBridge_OnClosingPaymentAppWindow(
JNIEnv* env,
const JavaParamRef<jobject>& jweb_contents,
const JavaParamRef<jobject>& payment_request_jweb_contents,
jint reason) {
content::WebContents* web_contents =
content::WebContents::FromJavaWebContents(jweb_contents);
DCHECK(web_contents); // Verified in Java before invoking this function.
content::PaymentAppProvider::GetOrCreateForWebContents(web_contents)
content::WebContents* payment_request_web_contents =
content::WebContents::FromJavaWebContents(payment_request_jweb_contents);
DCHECK(payment_request_web_contents); // Verified in Java before invoking
// this function.
content::PaymentAppProvider::GetOrCreateForWebContents(
payment_request_web_contents)
->OnClosingOpenedWindow(
static_cast<payments::mojom::PaymentEventResponseType>(reason));
}
static void JNI_ServiceWorkerPaymentAppBridge_OnOpeningPaymentAppWindow(
JNIEnv* env,
const JavaParamRef<jobject>& payment_request_jweb_contents,
const JavaParamRef<jobject>& payment_handler_jweb_contents) {
content::WebContents* payment_request_web_contents =
content::WebContents::FromJavaWebContents(payment_request_jweb_contents);
content::WebContents* payment_handler_web_contents =
content::WebContents::FromJavaWebContents(payment_handler_jweb_contents);
DCHECK(payment_request_web_contents); // Verified in Java before invoking
// this function.
DCHECK(payment_handler_web_contents); // Verified in Java before invoking
// this function.
content::PaymentAppProvider::GetOrCreateForWebContents(
payment_request_web_contents)
->SetOpenedWindow(payment_handler_web_contents);
}
static jlong
JNI_ServiceWorkerPaymentAppBridge_GetSourceIdForPaymentAppFromScope(
JNIEnv* env,
......
......@@ -104,19 +104,21 @@ void AddModifiersToMap(const std::vector<PaymentDetailsModifierPtr>& modifiers,
// static
PaymentAppProvider* PaymentAppProvider::GetOrCreateForWebContents(
WebContents* web_contents) {
return PaymentAppProviderImpl::GetOrCreateForWebContents(web_contents);
WebContents* payment_request_web_contents) {
return PaymentAppProviderImpl::GetOrCreateForWebContents(
payment_request_web_contents);
}
// static
PaymentAppProviderImpl* PaymentAppProviderImpl::GetOrCreateForWebContents(
WebContents* web_contents) {
WebContents* payment_request_web_contents) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto* data = PaymentAppProviderImpl::FromWebContents(web_contents);
auto* data =
PaymentAppProviderImpl::FromWebContents(payment_request_web_contents);
if (!data)
PaymentAppProviderImpl::CreateForWebContents(web_contents);
PaymentAppProviderImpl::CreateForWebContents(payment_request_web_contents);
return PaymentAppProviderImpl::FromWebContents(web_contents);
return PaymentAppProviderImpl::FromWebContents(payment_request_web_contents);
}
void PaymentAppProviderImpl::InvokePaymentApp(
......@@ -125,7 +127,7 @@ void PaymentAppProviderImpl::InvokePaymentApp(
PaymentRequestEventDataPtr event_data,
InvokePaymentAppCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(web_contents_);
DCHECK(payment_request_web_contents_);
scoped_refptr<DevToolsBackgroundServicesContextImpl> dev_tools =
GetDevTools(sw_origin);
......@@ -148,7 +150,7 @@ void PaymentAppProviderImpl::InvokePaymentApp(
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
BrowserContext::GetDefaultStoragePartition(
web_contents_->GetBrowserContext()));
payment_request_web_contents_->GetBrowserContext()));
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context =
partition->GetServiceWorkerContext();
......@@ -173,7 +175,7 @@ void PaymentAppProviderImpl::InstallAndInvokePaymentApp(
RegistrationIdCallback registration_id_callback,
InvokePaymentAppCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(web_contents_);
DCHECK(payment_request_web_contents_);
if (!sw_js_url.is_valid() || !sw_scope.is_valid() || method.empty()) {
GetUIThreadTaskRunner({})->PostTask(
......@@ -196,8 +198,8 @@ void PaymentAppProviderImpl::InstallAndInvokePaymentApp(
}
PaymentAppInstaller::Install(
web_contents_, app_name, string_encoded_icon, sw_js_url, sw_scope,
sw_use_cache, method, supported_delegations,
payment_request_web_contents_, app_name, string_encoded_icon, sw_js_url,
sw_scope, sw_use_cache, method, supported_delegations,
base::BindOnce(&PaymentAppProviderImpl::OnInstallPaymentApp,
weak_ptr_factory_.GetWeakPtr(),
url::Origin::Create(sw_scope), std::move(event_data),
......@@ -214,7 +216,7 @@ void PaymentAppProviderImpl::UpdatePaymentAppIcon(
PaymentAppProvider::UpdatePaymentAppIconCallback callback) {
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
BrowserContext::GetDefaultStoragePartition(
web_contents_->GetBrowserContext()));
payment_request_web_contents_->GetBrowserContext()));
scoped_refptr<PaymentAppContextImpl> payment_app_context =
partition->GetPaymentAppContext();
......@@ -232,7 +234,7 @@ void PaymentAppProviderImpl::CanMakePayment(
CanMakePaymentEventDataPtr event_data,
CanMakePaymentCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(web_contents_);
DCHECK(payment_request_web_contents_);
scoped_refptr<DevToolsBackgroundServicesContextImpl> dev_tools =
GetDevTools(sw_origin);
......@@ -255,7 +257,7 @@ void PaymentAppProviderImpl::CanMakePayment(
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
BrowserContext::GetDefaultStoragePartition(
web_contents_->GetBrowserContext()));
payment_request_web_contents_->GetBrowserContext()));
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context =
partition->GetServiceWorkerContext();
......@@ -274,7 +276,7 @@ void PaymentAppProviderImpl::AbortPayment(int64_t registration_id,
const std::string& payment_request_id,
AbortCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(web_contents_);
DCHECK(payment_request_web_contents_);
scoped_refptr<DevToolsBackgroundServicesContextImpl> dev_tools =
GetDevTools(sw_origin);
......@@ -287,7 +289,7 @@ void PaymentAppProviderImpl::AbortPayment(int64_t registration_id,
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
BrowserContext::GetDefaultStoragePartition(
web_contents_->GetBrowserContext()));
payment_request_web_contents_->GetBrowserContext()));
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context =
partition->GetServiceWorkerContext();
......@@ -300,15 +302,16 @@ void PaymentAppProviderImpl::AbortPayment(int64_t registration_id,
std::move(service_worker_context), std::move(callback)));
}
void PaymentAppProviderImpl::SetOpenedWindow() {
void PaymentAppProviderImpl::SetOpenedWindow(
WebContents* payment_handler_web_contents) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(web_contents_);
DCHECK(payment_handler_web_contents);
CloseOpenedWindow();
DCHECK(!payment_handler_window_);
payment_handler_window_ =
std::make_unique<PaymentHandlerWindowObserver>(web_contents_);
payment_handler_window_ = std::make_unique<PaymentHandlerWindowObserver>(
payment_handler_web_contents);
}
void PaymentAppProviderImpl::CloseOpenedWindow() {
......@@ -338,9 +341,9 @@ void PaymentAppProviderImpl::OnClosingOpenedWindow(
scoped_refptr<DevToolsBackgroundServicesContextImpl>
PaymentAppProviderImpl::GetDevTools(const url::Origin& sw_origin) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(web_contents_);
DCHECK(payment_request_web_contents_);
auto* storage_partition = BrowserContext::GetStoragePartitionForSite(
web_contents_->GetBrowserContext(), sw_origin.GetURL(),
payment_request_web_contents_->GetBrowserContext(), sw_origin.GetURL(),
/*can_create=*/true);
if (!storage_partition)
return nullptr;
......@@ -362,7 +365,7 @@ void PaymentAppProviderImpl::StartServiceWorkerForDispatch(
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
BrowserContext::GetDefaultStoragePartition(
web_contents_->GetBrowserContext()));
payment_request_web_contents_->GetBrowserContext()));
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context =
partition->GetServiceWorkerContext();
......@@ -381,7 +384,7 @@ void PaymentAppProviderImpl::OnInstallPaymentApp(
InvokePaymentAppCallback callback,
int64_t registration_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(web_contents_);
DCHECK(payment_request_web_contents_);
if (registration_id >= 0) {
std::move(registration_id_callback).Run(registration_id);
......@@ -394,11 +397,12 @@ void PaymentAppProviderImpl::OnInstallPaymentApp(
}
}
PaymentAppProviderImpl::PaymentAppProviderImpl(WebContents* web_contents)
: web_contents_(web_contents),
PaymentAppProviderImpl::PaymentAppProviderImpl(
WebContents* payment_request_web_contents)
: payment_request_web_contents_(payment_request_web_contents),
event_dispatcher_(
std::make_unique<ServiceWorkerCoreThreadEventDispatcher>(
web_contents_)) {
payment_request_web_contents_)) {
event_dispatcher_->set_payment_app_provider(weak_ptr_factory_.GetWeakPtr());
}
......@@ -408,8 +412,8 @@ PaymentAppProviderImpl::~PaymentAppProviderImpl() {
}
PaymentAppProviderImpl::PaymentHandlerWindowObserver::
PaymentHandlerWindowObserver(WebContents* web_contents)
: WebContentsObserver(web_contents) {}
PaymentHandlerWindowObserver(WebContents* payment_handler_web_contents)
: WebContentsObserver(payment_handler_web_contents) {}
PaymentAppProviderImpl::PaymentHandlerWindowObserver::
~PaymentHandlerWindowObserver() = default;
......
......@@ -20,7 +20,7 @@ class CONTENT_EXPORT PaymentAppProviderImpl
public:
~PaymentAppProviderImpl() override;
static PaymentAppProviderImpl* GetOrCreateForWebContents(
WebContents* web_contents);
WebContents* payment_request_web_contents);
// Disallow copy and assign.
PaymentAppProviderImpl(const PaymentAppProviderImpl& other) = delete;
......@@ -60,13 +60,13 @@ class CONTENT_EXPORT PaymentAppProviderImpl
const url::Origin& sw_origin,
const std::string& payment_request_id,
AbortCallback callback) override;
void SetOpenedWindow() override;
void SetOpenedWindow(WebContents* payment_handler_web_contents) override;
void CloseOpenedWindow() override;
void OnClosingOpenedWindow(
payments::mojom::PaymentEventResponseType reason) override;
private:
explicit PaymentAppProviderImpl(WebContents* web_contents);
explicit PaymentAppProviderImpl(WebContents* payment_request_web_contents);
friend class WebContentsUserData<PaymentAppProviderImpl>;
WEB_CONTENTS_USER_DATA_KEY_DECL();
......@@ -86,14 +86,15 @@ class CONTENT_EXPORT PaymentAppProviderImpl
// Note that constructor of WebContentsObserver is protected.
class PaymentHandlerWindowObserver : public WebContentsObserver {
public:
explicit PaymentHandlerWindowObserver(WebContents* web_contents);
explicit PaymentHandlerWindowObserver(
WebContents* payment_handler_web_contents);
~PaymentHandlerWindowObserver() override;
};
std::unique_ptr<PaymentHandlerWindowObserver> payment_handler_window_;
// Owns this object.
WebContents* web_contents_;
WebContents* payment_request_web_contents_;
// It should be accessed only on the service worker core thread.
std::unique_ptr<ServiceWorkerCoreThreadEventDispatcher> event_dispatcher_;
......
......@@ -209,13 +209,6 @@ void DidOpenURLOnUI(WindowType type,
new OpenURLObserver(web_contents,
rfhi->frame_tree_node()->frame_tree_node_id(),
std::move(callback));
if (type == WindowType::PAYMENT_HANDLER_WINDOW) {
// Set the opened web_contents to payment app provider to manage its life
// cycle.
PaymentAppProvider::GetOrCreateForWebContents(web_contents)
->SetOpenedWindow();
}
}
void OpenWindowOnUI(
......
......@@ -32,7 +32,7 @@ class CONTENT_EXPORT PaymentAppProvider {
// This static function is actually implemented in PaymentAppProviderImpl.cc.
// Please see: content/browser/payments/payment_app_provider_impl.cc
static PaymentAppProvider* GetOrCreateForWebContents(
WebContents* web_contents);
WebContents* payment_request_web_contents);
using RegistrationIdCallback =
base::OnceCallback<void(int64_t registration_id)>;
......@@ -84,7 +84,7 @@ class CONTENT_EXPORT PaymentAppProvider {
// opened window for payment handler at any moment in a browser context. The
// previously opened window in the same browser context will be closed after
// calling this interface.
virtual void SetOpenedWindow() = 0;
virtual void SetOpenedWindow(WebContents* payment_handler_web_contents) = 0;
virtual void CloseOpenedWindow() = 0;
// Notify the opened payment handler window is closing or closed by user so as
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment