Closed Bug 722996 Opened 12 years ago Closed 12 years ago

cookieAcceptDialog.js uses global Private Browsing state to make decisions

Categories

(Toolkit :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: jdm, Assigned: sawrubh)

References

()

Details

(Whiteboard: [mentor=jdm][lang=js])

Attachments

(1 file, 3 obsolete files)

The global state is going away. We should obtain the window's docshell and query the PB state that way instead.
This looks like we can use the same strategy as bug 722978.
OS: Mac OS X → All
Hardware: x86 → All
Whiteboard: [mentor=jdm][lang=js]
Assignee: nobody → saurabhanandiit
Comment on attachment 637261 [details] [diff] [review]
Patch v1

Review of attachment 637261 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me!
Attachment #637261 - Flags: feedback?(ehsan) → feedback+
Josh, Saurabh mentioned that you told him there's a missing piece here.  Would you mind elaborating on that?
This is toolkit code, yet its relying on gPrivateBrowsingUI which is a browser/ property. We should be explicitly obtaining the load context instead.
(In reply to Josh Matthews [:jdm] from comment #5)
> This is toolkit code, yet its relying on gPrivateBrowsingUI which is a
> browser/ property. We should be explicitly obtaining the load context
> instead.

That is a very good point.  Josh is right on, as usual.  :-)
Dao told me once that any files included in html or xul files usually have a window attached to them, since here cookieAcceptDialog.xul exists, hence I thought that we will have access to the browser window, which will have gPrivateBrowsingUI property. 
I am not sure whether this accessible browser window will allow us to QI it (something like this |window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsILoadContext).usePrivateBrowsing| ) like we do when going by the nsILoadContext path ?

@Josh what do you think about this ?
I can't think of any reason the QI chain in comment 7 wouldn't work, except that I'm not certain that the usePrivateBrowsing flag would propagate to the dialog window from the parent. You might need to use window.opener for that as well.
(In reply to Josh Matthews [:jdm] from comment #8)
> I can't think of any reason the QI chain in comment 7 wouldn't work, except
> that I'm not certain that the usePrivateBrowsing flag would propagate to the
> dialog window from the parent.

It doesn't.

> You might need to use window.opener for that as well.

Yes, you want to use the opener property.  Also, you can use the API added in bug 769467 (which is currently on the inbound branch.)
Attached patch Patch v2 (obsolete) — Splinter Review
What this patch does :
Uses the API introduced in Bug 769467.

This patch passes the entire "privatebrowsing/test/browser" test suite.
Attachment #637261 - Attachment is obsolete: true
Attachment #643283 - Flags: review?(ehsan)
Attached patch Patch v3 (obsolete) — Splinter Review
Sorry, I attached the not-so complete patch in Patch v2.

This patch is basically (a couple of whitespace cleanup + Patch v2).
Attachment #643283 - Attachment is obsolete: true
Attachment #643283 - Flags: review?(ehsan)
Attachment #643286 - Flags: review?(ehsan)
Here is the try run for Patch v3 :

https://tbpl.mozilla.org/?tree=Try&rev=7a7186ba3398
Comment on attachment 643286 [details] [diff] [review]
Patch v3

Review of attachment 643286 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with the changes below.

::: toolkit/components/cookie/content/cookieAcceptDialog.js
@@ +131,4 @@
>  
>    // The Private Browsing service might not be available
>    try {
> +    let opener = window.opener;

No point in declaring this local opener variable.  window is the global object, and you can access its properties by just referencing the name.  In other words, if you drop this line, everything should continue to work properly!  :-)

@@ +132,5 @@
>    // The Private Browsing service might not be available
>    try {
> +    let opener = window.opener;
> +    if (opener) {
> +      if (PrivateBrowsingUtils.isWindowPrivate(opener)) {

Nit: drop the nested ifs, and just && the conditions please.
Attachment #643286 - Flags: review?(ehsan) → review+
Attached patch Patch v4Splinter Review
Addressed Eshan's comments. Carries r+ from him. Passes "privatebrowsing/test" suite and had a good enough try run.
Attachment #643286 - Attachment is obsolete: true
Attachment #643573 - Flags: checkin?(ehsan)
Comment on attachment 643573 [details] [diff] [review]
Patch v4

Review of attachment 643573 [details] [diff] [review]:
-----------------------------------------------------------------

https://hg.mozilla.org/integration/mozilla-inbound/rev/82b78defe027
Attachment #643573 - Flags: checkin?(ehsan) → checkin+
https://hg.mozilla.org/mozilla-central/rev/82b78defe027
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: