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

[PRImpl] Move initial states into CPRImpl

Change:
Move the following references into CPRImpl, and provides PRImpl with
getters to access them:
* mRenderFrameHost
* mPaymentRequestOrigin
* mPaymentRequestSecurityOrigin
* mTopLevelOrigin
* mMerchantName
* mCertificateChain
* mIsOffTheRecord

Acronym:
CPRImpl = ComponentPaymentRequestImpl
PRImpl = PaymentRequestImpl

Bug: 1102522

Change-Id: I7e501efed0ab8b4ddc061cebe5170e19be99ab73
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2357630Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800628}
parent b29b9a25
...@@ -199,8 +199,7 @@ public class PaymentRequestFactory implements InterfaceFactory<PaymentRequest> { ...@@ -199,8 +199,7 @@ public class PaymentRequestFactory implements InterfaceFactory<PaymentRequest> {
return ComponentPaymentRequestImpl.createPaymentRequest(mRenderFrameHost, return ComponentPaymentRequestImpl.createPaymentRequest(mRenderFrameHost,
/*isOffTheRecord=*/delegate.isOffTheRecord(webContents), /*isOffTheRecord=*/delegate.isOffTheRecord(webContents),
/*skipUiForBasicCard=*/delegate.skipUiForBasicCard(), /*skipUiForBasicCard=*/delegate.skipUiForBasicCard(),
(renderFrameHost, componentPaymentRequest, isOffTheRecord) (componentPaymentRequest)
-> new PaymentRequestImpl(renderFrameHost, componentPaymentRequest, -> new PaymentRequestImpl(componentPaymentRequest, delegate));
isOffTheRecord, delegate));
} }
} }
...@@ -51,7 +51,6 @@ import org.chromium.chrome.browser.ui.favicon.FaviconHelper; ...@@ -51,7 +51,6 @@ import org.chromium.chrome.browser.ui.favicon.FaviconHelper;
import org.chromium.components.autofill.EditableOption; import org.chromium.components.autofill.EditableOption;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetControllerProvider; import org.chromium.components.browser_ui.bottomsheet.BottomSheetControllerProvider;
import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.components.page_info.CertificateChainHelper;
import org.chromium.components.payments.AbortReason; import org.chromium.components.payments.AbortReason;
import org.chromium.components.payments.BrowserPaymentRequest; import org.chromium.components.payments.BrowserPaymentRequest;
import org.chromium.components.payments.CanMakePaymentQuery; import org.chromium.components.payments.CanMakePaymentQuery;
...@@ -80,7 +79,6 @@ import org.chromium.components.payments.PaymentValidator; ...@@ -80,7 +79,6 @@ import org.chromium.components.payments.PaymentValidator;
import org.chromium.components.payments.Section; import org.chromium.components.payments.Section;
import org.chromium.components.payments.UrlUtil; import org.chromium.components.payments.UrlUtil;
import org.chromium.components.security_state.SecurityStateModel; import org.chromium.components.security_state.SecurityStateModel;
import org.chromium.components.url_formatter.UrlFormatter;
import org.chromium.content_public.browser.RenderFrameHost; import org.chromium.content_public.browser.RenderFrameHost;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.payments.mojom.CanMakePaymentQueryResult; import org.chromium.payments.mojom.CanMakePaymentQueryResult;
...@@ -200,17 +198,9 @@ public class PaymentRequestImpl ...@@ -200,17 +198,9 @@ public class PaymentRequestImpl
}; };
private final Handler mHandler = new Handler(); private final Handler mHandler = new Handler();
private final RenderFrameHost mRenderFrameHost;
private final Delegate mDelegate; private final Delegate mDelegate;
private final WebContents mWebContents; private final WebContents mWebContents;
private final String mTopLevelOrigin;
private final String mPaymentRequestOrigin;
private final Origin mPaymentRequestSecurityOrigin;
private final String mMerchantName;
@Nullable
private final byte[][] mCertificateChain;
private final JourneyLogger mJourneyLogger; private final JourneyLogger mJourneyLogger;
private final boolean mIsOffTheRecord;
private final PaymentUIsManager mPaymentUIsManager; private final PaymentUIsManager mPaymentUIsManager;
...@@ -261,7 +251,6 @@ public class PaymentRequestImpl ...@@ -261,7 +251,6 @@ public class PaymentRequestImpl
private MinimalUICoordinator mMinimalUi; private MinimalUICoordinator mMinimalUi;
private PaymentApp mInvokedPaymentApp; private PaymentApp mInvokedPaymentApp;
private boolean mHideServerAutofillCards; private boolean mHideServerAutofillCards;
private boolean mHasRecordedAbortReason;
private boolean mWaitForUpdatedDetails; private boolean mWaitForUpdatedDetails;
private TabModelSelector mObservedTabModelSelector; private TabModelSelector mObservedTabModelSelector;
private TabModel mObservedTabModel; private TabModel mObservedTabModel;
...@@ -335,32 +324,20 @@ public class PaymentRequestImpl ...@@ -335,32 +324,20 @@ public class PaymentRequestImpl
/** /**
* Builds the PaymentRequest service implementation. * Builds the PaymentRequest service implementation.
* *
* @param renderFrameHost The host of the frame that has invoked the PaymentRequest API.
* @param componentPaymentRequestImpl The component side of the PaymentRequest implementation. * @param componentPaymentRequestImpl The component side of the PaymentRequest implementation.
* @param isOffTheRecord Whether the merchant page is shown in an off-the-record tab.
* @param delegate The delegate of this class. * @param delegate The delegate of this class.
*/ */
public PaymentRequestImpl(RenderFrameHost renderFrameHost, public PaymentRequestImpl(
ComponentPaymentRequestImpl componentPaymentRequestImpl, boolean isOffTheRecord, ComponentPaymentRequestImpl componentPaymentRequestImpl, Delegate delegate) {
Delegate delegate) {
assert renderFrameHost != null;
assert componentPaymentRequestImpl != null; assert componentPaymentRequestImpl != null;
assert delegate != null; assert delegate != null;
mRenderFrameHost = renderFrameHost;
mDelegate = delegate; mDelegate = delegate;
mWebContents = componentPaymentRequestImpl.getWebContents(); mWebContents = componentPaymentRequestImpl.getWebContents();
mPaymentRequestOrigin =
UrlFormatter.formatUrlForSecurityDisplay(mRenderFrameHost.getLastCommittedURL());
mPaymentRequestSecurityOrigin = mRenderFrameHost.getLastCommittedOrigin();
mTopLevelOrigin =
UrlFormatter.formatUrlForSecurityDisplay(mWebContents.getLastCommittedUrl());
mMerchantName = mWebContents.getTitle();
mCertificateChain = CertificateChainHelper.getCertificateChain(mWebContents);
mIsOffTheRecord = isOffTheRecord;
mJourneyLogger = componentPaymentRequestImpl.getJourneyLogger(); mJourneyLogger = componentPaymentRequestImpl.getJourneyLogger();
mPaymentUIsManager = new PaymentUIsManager(/*delegate=*/this, mPaymentUIsManager = new PaymentUIsManager(/*delegate=*/this,
/*params=*/this, mWebContents, mIsOffTheRecord, mJourneyLogger); /*params=*/this, mWebContents, componentPaymentRequestImpl.isOffTheRecord(),
mJourneyLogger);
mComponentPaymentRequestImpl = componentPaymentRequestImpl; mComponentPaymentRequestImpl = componentPaymentRequestImpl;
mComponentPaymentRequestImpl.registerPaymentRequestLifecycleObserver(mPaymentUIsManager); mComponentPaymentRequestImpl.registerPaymentRequestLifecycleObserver(mPaymentUIsManager);
} }
...@@ -581,7 +558,9 @@ public class PaymentRequestImpl ...@@ -581,7 +558,9 @@ public class PaymentRequestImpl
mPaymentUIsManager.setPaymentRequestUI(new PaymentRequestUI(activity, this, mPaymentUIsManager.setPaymentRequestUI(new PaymentRequestUI(activity, this,
mPaymentUIsManager.merchantSupportsAutofillCards(), mPaymentUIsManager.merchantSupportsAutofillCards(),
!PaymentPreferencesUtil.isPaymentCompleteOnce(), mMerchantName, mTopLevelOrigin, !PaymentPreferencesUtil.isPaymentCompleteOnce(),
mComponentPaymentRequestImpl.getMerchantName(),
mComponentPaymentRequestImpl.getTopLevelOrigin(),
SecurityStateModel.getSecurityLevelForWebContents(mWebContents), SecurityStateModel.getSecurityLevelForWebContents(mWebContents),
new ShippingStrings(mShippingType), new ShippingStrings(mShippingType),
mPaymentUIsManager.getPaymentUisShowStateReconciler(), mPaymentUIsManager.getPaymentUisShowStateReconciler(),
...@@ -988,8 +967,8 @@ public class PaymentRequestImpl ...@@ -988,8 +967,8 @@ public class PaymentRequestImpl
assert mInvokedPaymentApp != null; assert mInvokedPaymentApp != null;
assert mInvokedPaymentApp.getPaymentAppType() == PaymentAppType.SERVICE_WORKER_APP; assert mInvokedPaymentApp.getPaymentAppType() == PaymentAppType.SERVICE_WORKER_APP;
boolean success = mPaymentUIsManager.showPaymentHandlerUI( boolean success = mPaymentUIsManager.showPaymentHandlerUI(mWebContents, url,
mWebContents, url, paymentHandlerWebContentsObserver, mIsOffTheRecord); paymentHandlerWebContentsObserver, mComponentPaymentRequestImpl.isOffTheRecord());
if (success) { if (success) {
// UKM for payment app origin should get recorded only when the origin of the invoked // UKM for payment app origin should get recorded only when the origin of the invoked
// payment app is shown to the user. // payment app is shown to the user.
...@@ -1424,10 +1403,13 @@ public class PaymentRequestImpl ...@@ -1424,10 +1403,13 @@ public class PaymentRequestImpl
mInvokedPaymentApp.handlesShippingAddress() mInvokedPaymentApp.handlesShippingAddress()
? mRawShippingOptions ? mRawShippingOptions
: Collections.unmodifiableList(new ArrayList<>()); : Collections.unmodifiableList(new ArrayList<>());
mInvokedPaymentApp.invokePaymentApp(mId, mMerchantName, mTopLevelOrigin, mInvokedPaymentApp.invokePaymentApp(mId, mComponentPaymentRequestImpl.getMerchantName(),
mPaymentRequestOrigin, mCertificateChain, Collections.unmodifiableMap(methodData), mComponentPaymentRequestImpl.getTopLevelOrigin(),
mRawTotal, mRawLineItems, Collections.unmodifiableMap(modifiers), paymentOptions, mComponentPaymentRequestImpl.getPaymentRequestOrigin(),
redactedShippingOptions, this); mComponentPaymentRequestImpl.getCertificateChain(),
Collections.unmodifiableMap(methodData), mRawTotal, mRawLineItems,
Collections.unmodifiableMap(modifiers), paymentOptions, redactedShippingOptions,
this);
mJourneyLogger.setEventOccurred(Event.PAY_CLICKED); mJourneyLogger.setEventOccurred(Event.PAY_CLICKED);
boolean isAutofillCard = mInvokedPaymentApp.isAutofillInstrument(); boolean isAutofillCard = mInvokedPaymentApp.isAutofillInstrument();
...@@ -1608,7 +1590,8 @@ public class PaymentRequestImpl ...@@ -1608,7 +1590,8 @@ public class PaymentRequestImpl
? CanMakePaymentQueryResult.CAN_MAKE_PAYMENT ? CanMakePaymentQueryResult.CAN_MAKE_PAYMENT
: CanMakePaymentQueryResult.CANNOT_MAKE_PAYMENT); : CanMakePaymentQueryResult.CANNOT_MAKE_PAYMENT);
mJourneyLogger.setCanMakePaymentValue(response || mIsOffTheRecord); mJourneyLogger.setCanMakePaymentValue(
response || mComponentPaymentRequestImpl.isOffTheRecord());
if (ComponentPaymentRequestImpl.getObserverForTest() != null) { if (ComponentPaymentRequestImpl.getObserverForTest() != null) {
ComponentPaymentRequestImpl.getObserverForTest() ComponentPaymentRequestImpl.getObserverForTest()
...@@ -1641,8 +1624,9 @@ public class PaymentRequestImpl ...@@ -1641,8 +1624,9 @@ public class PaymentRequestImpl
mIsHasEnrolledInstrumentResponsePending = false; mIsHasEnrolledInstrumentResponsePending = false;
if (CanMakePaymentQuery.canQuery( if (CanMakePaymentQuery.canQuery(mWebContents,
mWebContents, mTopLevelOrigin, mPaymentRequestOrigin, mQueryForQuota)) { mComponentPaymentRequestImpl.getTopLevelOrigin(),
mComponentPaymentRequestImpl.getPaymentRequestOrigin(), mQueryForQuota)) {
mComponentPaymentRequestImpl.onHasEnrolledInstrument(response mComponentPaymentRequestImpl.onHasEnrolledInstrument(response
? HasEnrolledInstrumentQueryResult.HAS_ENROLLED_INSTRUMENT ? HasEnrolledInstrumentQueryResult.HAS_ENROLLED_INSTRUMENT
: HasEnrolledInstrumentQueryResult.HAS_NO_ENROLLED_INSTRUMENT); : HasEnrolledInstrumentQueryResult.HAS_NO_ENROLLED_INSTRUMENT);
...@@ -1655,7 +1639,8 @@ public class PaymentRequestImpl ...@@ -1655,7 +1639,8 @@ public class PaymentRequestImpl
: HasEnrolledInstrumentQueryResult.WARNING_HAS_NO_ENROLLED_INSTRUMENT); : HasEnrolledInstrumentQueryResult.WARNING_HAS_NO_ENROLLED_INSTRUMENT);
} }
mJourneyLogger.setHasEnrolledInstrumentValue(response || mIsOffTheRecord); mJourneyLogger.setHasEnrolledInstrumentValue(
response || mComponentPaymentRequestImpl.isOffTheRecord());
if (ComponentPaymentRequestImpl.getObserverForTest() != null) { if (ComponentPaymentRequestImpl.getObserverForTest() != null) {
ComponentPaymentRequestImpl.getObserverForTest() ComponentPaymentRequestImpl.getObserverForTest()
...@@ -1702,7 +1687,7 @@ public class PaymentRequestImpl ...@@ -1702,7 +1687,7 @@ public class PaymentRequestImpl
// PaymentAppFactoryParams implementation. // PaymentAppFactoryParams implementation.
@Override @Override
public RenderFrameHost getRenderFrameHost() { public RenderFrameHost getRenderFrameHost() {
return mRenderFrameHost; return mComponentPaymentRequestImpl.getRenderFrameHost();
} }
// PaymentAppFactoryParams implementation. // PaymentAppFactoryParams implementation.
...@@ -1720,26 +1705,26 @@ public class PaymentRequestImpl ...@@ -1720,26 +1705,26 @@ public class PaymentRequestImpl
// PaymentAppFactoryParams implementation. // PaymentAppFactoryParams implementation.
@Override @Override
public String getTopLevelOrigin() { public String getTopLevelOrigin() {
return mTopLevelOrigin; return mComponentPaymentRequestImpl.getTopLevelOrigin();
} }
// PaymentAppFactoryParams implementation. // PaymentAppFactoryParams implementation.
@Override @Override
public String getPaymentRequestOrigin() { public String getPaymentRequestOrigin() {
return mPaymentRequestOrigin; return mComponentPaymentRequestImpl.getPaymentRequestOrigin();
} }
// PaymentAppFactoryParams implementation. // PaymentAppFactoryParams implementation.
@Override @Override
public Origin getPaymentRequestSecurityOrigin() { public Origin getPaymentRequestSecurityOrigin() {
return mPaymentRequestSecurityOrigin; return mComponentPaymentRequestImpl.getPaymentRequestSecurityOrigin();
} }
// PaymentAppFactoryParams implementation. // PaymentAppFactoryParams implementation.
@Override @Override
@Nullable @Nullable
public byte[][] getCertificateChain() { public byte[][] getCertificateChain() {
return mCertificateChain; return mComponentPaymentRequestImpl.getCertificateChain();
} }
// PaymentAppFactoryParams implementation. // PaymentAppFactoryParams implementation.
...@@ -1983,7 +1968,7 @@ public class PaymentRequestImpl ...@@ -1983,7 +1968,7 @@ public class PaymentRequestImpl
// Chrome always refuses payments with invalid SSL and in prohibited origin types. // Chrome always refuses payments with invalid SSL and in prohibited origin types.
disconnectFromClientWithDebugMessage( disconnectFromClientWithDebugMessage(
mRejectShowErrorMessage, PaymentErrorReason.NOT_SUPPORTED); mRejectShowErrorMessage, PaymentErrorReason.NOT_SUPPORTED);
} else if (mIsOffTheRecord) { } else if (mComponentPaymentRequestImpl.isOffTheRecord()) {
// If the user is in the OffTheRecord mode, hide the absence of their payment // If the user is in the OffTheRecord mode, hide the absence of their payment
// methods from the merchant site. // methods from the merchant site.
disconnectFromClientWithDebugMessage( disconnectFromClientWithDebugMessage(
......
...@@ -4,6 +4,7 @@ include_rules = [ ...@@ -4,6 +4,7 @@ include_rules = [
"+components/autofill", "+components/autofill",
"+components/keyed_service/content", "+components/keyed_service/content",
"+components/keyed_service/core", "+components/keyed_service/core",
"+components/page_info",
"+components/prefs", "+components/prefs",
"+components/strings", "+components/strings",
"+components/ukm/content", "+components/ukm/content",
......
...@@ -121,7 +121,9 @@ android_library("java") { ...@@ -121,7 +121,9 @@ android_library("java") {
"//base:base_java", "//base:base_java",
"//base:jni_java", "//base:jni_java",
"//components/autofill/android:autofill_java", "//components/autofill/android:autofill_java",
"//components/page_info/android:java",
"//components/payments/mojom:mojom_java", "//components/payments/mojom:mojom_java",
"//components/url_formatter/android:url_formatter_java",
"//content/public/android:content_java", "//content/public/android:content_java",
"//mojo/public/java:bindings_java", "//mojo/public/java:bindings_java",
"//mojo/public/java:system_java", "//mojo/public/java:system_java",
......
...@@ -6,7 +6,6 @@ package org.chromium.components.payments; ...@@ -6,7 +6,6 @@ package org.chromium.components.payments;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import org.chromium.content_public.browser.RenderFrameHost;
import org.chromium.payments.mojom.PaymentDetails; import org.chromium.payments.mojom.PaymentDetails;
import org.chromium.payments.mojom.PaymentMethodData; import org.chromium.payments.mojom.PaymentMethodData;
import org.chromium.payments.mojom.PaymentOptions; import org.chromium.payments.mojom.PaymentOptions;
...@@ -22,15 +21,12 @@ public interface BrowserPaymentRequest { ...@@ -22,15 +21,12 @@ public interface BrowserPaymentRequest {
interface Factory { interface Factory {
/** /**
* Create an instance of {@link BrowserPaymentRequest}. * Create an instance of {@link BrowserPaymentRequest}.
* @param renderFrameHost The RenderFrameHost of the merchant page.
* @param componentPaymentRequestImpl The ComponentPaymentRequestImpl to work together with * @param componentPaymentRequestImpl The ComponentPaymentRequestImpl to work together with
* the BrowserPaymentRequest instance. * the BrowserPaymentRequest instance, cannot be null.
* @param isOffTheRecord Whether the merchant page is in an OffTheRecord (e.g., incognito,
* guest mode) Tab.
* @return An instance of BrowserPaymentRequest, cannot be null. * @return An instance of BrowserPaymentRequest, cannot be null.
*/ */
BrowserPaymentRequest createBrowserPaymentRequest(RenderFrameHost renderFrameHost, BrowserPaymentRequest createBrowserPaymentRequest(
ComponentPaymentRequestImpl componentPaymentRequestImpl, boolean isOffTheRecord); ComponentPaymentRequestImpl componentPaymentRequestImpl);
} }
/** /**
......
...@@ -9,6 +9,8 @@ import androidx.annotation.VisibleForTesting; ...@@ -9,6 +9,8 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.components.autofill.EditableOption; import org.chromium.components.autofill.EditableOption;
import org.chromium.components.page_info.CertificateChainHelper;
import org.chromium.components.url_formatter.UrlFormatter;
import org.chromium.content_public.browser.RenderFrameHost; import org.chromium.content_public.browser.RenderFrameHost;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.WebContentsStatics; import org.chromium.content_public.browser.WebContentsStatics;
...@@ -23,6 +25,7 @@ import org.chromium.payments.mojom.PaymentRequest; ...@@ -23,6 +25,7 @@ import org.chromium.payments.mojom.PaymentRequest;
import org.chromium.payments.mojom.PaymentRequestClient; import org.chromium.payments.mojom.PaymentRequestClient;
import org.chromium.payments.mojom.PaymentResponse; import org.chromium.payments.mojom.PaymentResponse;
import org.chromium.payments.mojom.PaymentValidationErrors; import org.chromium.payments.mojom.PaymentValidationErrors;
import org.chromium.url.Origin;
import java.util.List; import java.util.List;
...@@ -44,6 +47,14 @@ public class ComponentPaymentRequestImpl { ...@@ -44,6 +47,14 @@ public class ComponentPaymentRequestImpl {
private final Runnable mOnClosedListener; private final Runnable mOnClosedListener;
private final WebContents mWebContents; private final WebContents mWebContents;
private final JourneyLogger mJourneyLogger; private final JourneyLogger mJourneyLogger;
private final RenderFrameHost mRenderFrameHost;
private final String mTopLevelOrigin;
private final String mPaymentRequestOrigin;
private final Origin mPaymentRequestSecurityOrigin;
private final String mMerchantName;
@Nullable
private final byte[][] mCertificateChain;
private final boolean mIsOffTheRecord;
private boolean mSkipUiForNonUrlPaymentMethodIdentifiers; private boolean mSkipUiForNonUrlPaymentMethodIdentifiers;
private PaymentRequestLifecycleObserver mPaymentRequestLifecycleObserver; private PaymentRequestLifecycleObserver mPaymentRequestLifecycleObserver;
private boolean mHasClosed; private boolean mHasClosed;
...@@ -210,8 +221,9 @@ public class ComponentPaymentRequestImpl { ...@@ -210,8 +221,9 @@ public class ComponentPaymentRequestImpl {
return null; return null;
} }
ComponentPaymentRequestImpl instance = new ComponentPaymentRequestImpl(client, ComponentPaymentRequestImpl instance =
renderFrameHost, webContents, journeyLogger, skipUiForBasicCard, onClosedListener); new ComponentPaymentRequestImpl(client, renderFrameHost, webContents, journeyLogger,
skipUiForBasicCard, isOffTheRecord, onClosedListener);
instance.onCreated(); instance.onCreated();
boolean valid = instance.initAndValidate(renderFrameHost, browserPaymentRequestFactory, boolean valid = instance.initAndValidate(renderFrameHost, browserPaymentRequestFactory,
methodData, details, options, googlePayBridgeEligible, isOffTheRecord); methodData, details, options, googlePayBridgeEligible, isOffTheRecord);
...@@ -238,15 +250,27 @@ public class ComponentPaymentRequestImpl { ...@@ -238,15 +250,27 @@ public class ComponentPaymentRequestImpl {
private ComponentPaymentRequestImpl(PaymentRequestClient client, private ComponentPaymentRequestImpl(PaymentRequestClient client,
RenderFrameHost renderFrameHost, WebContents webContents, JourneyLogger journeyLogger, RenderFrameHost renderFrameHost, WebContents webContents, JourneyLogger journeyLogger,
boolean skipUiForBasicCard, Runnable onClosedListener) { boolean skipUiForBasicCard, boolean isOffTheRecord, Runnable onClosedListener) {
assert client != null; assert client != null;
assert renderFrameHost != null; assert renderFrameHost != null;
assert webContents != null; assert webContents != null;
assert journeyLogger != null; assert journeyLogger != null;
mRenderFrameHost = renderFrameHost;
mPaymentRequestSecurityOrigin = mRenderFrameHost.getLastCommittedOrigin();
mWebContents = webContents;
// TODO(crbug.com/992593): replace UrlFormatter with GURL operations.
mPaymentRequestOrigin =
UrlFormatter.formatUrlForSecurityDisplay(mRenderFrameHost.getLastCommittedURL());
mTopLevelOrigin =
UrlFormatter.formatUrlForSecurityDisplay(mWebContents.getLastCommittedUrl());
mMerchantName = mWebContents.getTitle();
mCertificateChain = CertificateChainHelper.getCertificateChain(mWebContents);
mIsOffTheRecord = isOffTheRecord;
mSkipUiForNonUrlPaymentMethodIdentifiers = skipUiForBasicCard; mSkipUiForNonUrlPaymentMethodIdentifiers = skipUiForBasicCard;
mClient = client; mClient = client;
mWebContents = webContents;
mJourneyLogger = journeyLogger; mJourneyLogger = journeyLogger;
mOnClosedListener = onClosedListener; mOnClosedListener = onClosedListener;
mHasClosed = false; mHasClosed = false;
...@@ -272,8 +296,7 @@ public class ComponentPaymentRequestImpl { ...@@ -272,8 +296,7 @@ public class ComponentPaymentRequestImpl {
BrowserPaymentRequest.Factory factory, @Nullable PaymentMethodData[] methodData, BrowserPaymentRequest.Factory factory, @Nullable PaymentMethodData[] methodData,
@Nullable PaymentDetails details, @Nullable PaymentOptions options, @Nullable PaymentDetails details, @Nullable PaymentOptions options,
boolean googlePayBridgeEligible, boolean isOffTheRecord) { boolean googlePayBridgeEligible, boolean isOffTheRecord) {
mBrowserPaymentRequest = mBrowserPaymentRequest = factory.createBrowserPaymentRequest(this);
factory.createBrowserPaymentRequest(renderFrameHost, this, isOffTheRecord);
return mBrowserPaymentRequest.initAndValidate( return mBrowserPaymentRequest.initAndValidate(
methodData, details, options, googlePayBridgeEligible); methodData, details, options, googlePayBridgeEligible);
} }
...@@ -564,4 +587,43 @@ public class ComponentPaymentRequestImpl { ...@@ -564,4 +587,43 @@ public class ComponentPaymentRequestImpl {
public WebContents getWebContents() { public WebContents getWebContents() {
return mWebContents; return mWebContents;
} }
/** @return Whether the WebContents is currently showing an off-the-record tab. */
public boolean isOffTheRecord() {
return mIsOffTheRecord;
}
/** @return The certificate chain from the merchant page's WebContents. */
public byte[][] getCertificateChain() {
return mCertificateChain;
}
/** @return The origin of the page at which the PaymentRequest is created. */
public String getPaymentRequestOrigin() {
return mPaymentRequestOrigin;
}
/** @return The merchant page's title. */
public String getMerchantName() {
return mMerchantName;
}
/** @return The origin of the top level frame of the merchant page. */
public String getTopLevelOrigin() {
return mTopLevelOrigin;
}
/** @return The RendererFrameHost of the merchant page. */
public RenderFrameHost getRenderFrameHost() {
return mRenderFrameHost;
}
/**
* @return The origin of the iframe that invoked the PaymentRequest API. Can be opaque. Used by
* security features like 'Sec-Fetch-Site' and 'Cross-Origin-Resource-Policy'. Should not be
* null.
*/
public Origin getPaymentRequestSecurityOrigin() {
return mPaymentRequestSecurityOrigin;
}
} }
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