Open Bug 1498013 Opened 6 years ago Updated 2 years ago

Add a boolean attribute to nsIPaymentRequest to indicate whether it's from a private window

Categories

(Core :: DOM: Web Payments, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: MattN, Unassigned)

References

Details

(Whiteboard: [webpayments-reserve])

Attachments

(2 files)

The PaymentRequest UI has different behaviour in private browsing but we don't currently have a foolproof way to determine if the request is coming from private browsing. Adding a boolean on nsIPaymentRequest would fix this. The current front-end code is: https://dxr.mozilla.org/mozilla-central/rev/c291143e24019097d087f9307e59b49facaf90cb/browser/components/payments/content/paymentDialogWrapper.js#456 That would then be changed so `isPrivate` is set to `this.request.inPrivateBrowsing` if the attribute is named `inPrivateBrowsing`. Please make the change to the front-end code when implementing this. Examples of other comparable attribute names: https://dxr.mozilla.org/mozilla-central/search?q=attribute+private+ext%3Aidl&redirect=false I don't think we should use one that includes the word "window" since it may not always be a separate window in the future.
Flags: qe-verify+
Priority: -- → P3
Priority: P3 → P2
Status: NEW → ASSIGNED
Priority: P2 → P1
Comment on attachment 9025657 [details] [diff] [review] Part 2 - Using nsIPaymentRequest::InPrivateBrowsing in Payment UI. Review of attachment 9025657 [details] [diff] [review]: ----------------------------------------------------------------- This is the minimal necessary change but ideally all references to `state.isPrivate` would have been updated to use `state.request.inPrivateBrowsing`. If you don't want to do that then please file a front-end follow-up to do the cleanup.
Attachment #9025657 - Flags: review?(MattN+bmo) → review+
Comment on attachment 9025656 [details] [diff] [review] Part 1: Adding an attribute nsIPaymentRequest::InPrivateBrowsing to indicate the PaymentRequest is from PrivateBrowsing mode. Review of attachment 9025656 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/payments/PaymentRequest.cpp @@ +673,5 @@ > MOZ_ASSERT(aWindow); > RegisterActivityObserver(); > + nsIDocument* doc = aWindow->GetExtantDoc(); > + if (doc) { > + mInPrivateBrowsing = nsContentUtils::IsInPrivateBrowsing(doc); Defaulting to false with this `doc` check is a bit concerning to me. When is doc ever null here? ::: dom/payments/PaymentRequest.h @@ +215,4 @@ > // front end about it. > bool mDeferredShow; > > + // Ture if the payment is created in the private browsing context. Typo: "ture"
Comment on attachment 9025656 [details] [diff] [review] Part 1: Adding an attribute nsIPaymentRequest::InPrivateBrowsing to indicate the PaymentRequest is from PrivateBrowsing mode. Review of attachment 9025656 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/interfaces/payments/nsIPaymentRequest.idl @@ +83,4 @@ > { > readonly attribute uint64_t topOuterWindowId; > readonly attribute nsIPrincipal topLevelPrincipal; > + readonly attribute bool inPrivateBrowsing; you can use the toplevelPrincipal.originAttributes. why do you need this extra boolean?
Attachment #9025656 - Flags: review?(amarchesini) → review-
(In reply to Andrea Marchesini [:baku] from comment #6) > Comment on attachment 9025656 [details] [diff] [review] > Part 1: Adding an attribute nsIPaymentRequest::InPrivateBrowsing to indicate > the PaymentRequest is from PrivateBrowsing mode. > > ::: dom/interfaces/payments/nsIPaymentRequest.idl > @@ +83,4 @@ > > { > > readonly attribute uint64_t topOuterWindowId; > > readonly attribute nsIPrincipal topLevelPrincipal; > > + readonly attribute bool inPrivateBrowsing; > > you can use the toplevelPrincipal.originAttributes. > why do you need this extra boolean? a) It seemed a bit gross to depend on `privateBrowsingId > 0` for a private browsing check. b) topLevelPrincipal isn't the principal of the document doing the request so in theory `privateBrowsingId` could be different for them. In practice they're currently the same since we only support per-window PB now but I could see this changing with tracking protection and such.
Status: NEW → ASSIGNED
Priority: P2 → P1
Priority: P1 → P3
Assignee: echuang → nobody
Status: ASSIGNED → NEW
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: