Closed
Bug 722864
Opened 12 years ago
Closed 12 years ago
nsFilePicker uses global PB service to decide whether to add choices to recent documents
Categories
(Core :: Widget: Win32, defect)
Tracking
()
RESOLVED
FIXED
mozilla14
People
(Reporter: jdm, Assigned: diana)
References
Details
Attachments
(1 file, 2 obsolete files)
The global Private Browsing service is going away. The File Picker should use a reference to the nearest relevant docshell to decide instead.
Comment 1•12 years ago
|
||
This information should be propagated down from the callers of the file picker dialog. The callers that we care about are the following I think: * the file control frame implementation * open/save dialogs invoked by the File menu entries Firefox should treat any caller which does not pass down that information as not in PB mode.
Reporter | ||
Comment 2•12 years ago
|
||
It looks like the file picker is initialized with an nsDOMWindow (nsBaseFilePicker::Init). Could we get an nsIWebNavigation from that, and get the nsILoadContext from there?
Comment 3•12 years ago
|
||
(In reply to Josh Matthews [:jdm] from comment #2) > It looks like the file picker is initialized with an nsDOMWindow > (nsBaseFilePicker::Init). Could we get an nsIWebNavigation from that, and > get the nsILoadContext from there? Yes. You should be able to do_GetInterface(domWindow) to get an nsIWebNavigation out of it.
Comment 4•12 years ago
|
||
So what needs to be done here is to make the Windows nsFilePicker (widget/windows/nsFilePicker.cpp) override nsBaseFilePicker::Init, get the docshell associated with the nsIDOMWindow passed to it, QueryInterface it to nsILoadContext and then hold on to that in an nsCOMPtr member variable. Once that is done, nsFilePicker::IsPrivacyModeEnabled can be modified to call GetUsePrivateBrowsing on the member nsILoadContext and return the result, instead of querying nsIPrivateBrowsingEnabled. Hessam, are you willing to work on this?
Reporter | ||
Comment 5•12 years ago
|
||
Actually Diana has been looking into this bug already, I'm pretty sure.
Comment 6•12 years ago
|
||
(In reply to Josh Matthews [:jdm] from comment #5) > Actually Diana has been looking into this bug already, I'm pretty sure. Oh, sorry for stepping on your toes here, Diana! :-) I'll look for another bug for you, Hessam!
Assignee | ||
Comment 7•12 years ago
|
||
My fault really, should have taken the bug.
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → aem_koenraadt
Assignee | ||
Comment 8•12 years ago
|
||
Attachment #613337 -
Flags: review?(josh)
Comment 9•12 years ago
|
||
Comment on attachment 613337 [details] [diff] [review] use reference to docShell's loadContext to determine privacy mode Review of attachment 613337 [details] [diff] [review]: ----------------------------------------------------------------- This looks like a great start, Diana! I have a few comments below on the patch. Also, can you please test this patch using the steps mentioned in bug 651093 comment 0 to make sure that this doesn't break anything? Thanks! ::: widget/windows/nsFilePicker.cpp @@ +1287,5 @@ > > bool > nsFilePicker::IsPrivacyModeEnabled() > { > + bool usingPB; Please initialize this to false, so that it would not have a random value inside it if mLoadContext is null. @@ +1294,2 @@ > } > + return usingPB; With the usage of nsIPrivateBrowsingService removed, you can also remove this line at the beginning of this file: #include "nsIPrivateBrowsingService.h" ::: widget/windows/nsFilePicker.h @@ +137,5 @@ > static void PickerCallbackTimerFunc(nsITimer *aTimer, void *aPicker); > static UINT_PTR CALLBACK MultiFilePickerHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); > static UINT_PTR CALLBACK FilePickerHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); > > + nsCOMPtr<nsILoadContext> loadContext; Nit: please use mLoadContext as the name.
Attachment #613337 -
Flags: review?(josh)
Assignee | ||
Comment 10•12 years ago
|
||
Thanks for the quick reply, will do!
Reporter | ||
Comment 11•12 years ago
|
||
Comment on attachment 613337 [details] [diff] [review] use reference to docShell's loadContext to determine privacy mode Review of attachment 613337 [details] [diff] [review]: ----------------------------------------------------------------- This is looking good. I'll pass this on to someone who actually owns this code once the changes below are made :) Have you tried opening a random html file in normal mode, seeing if it shows up in Recent Documents, then entering PB mode, loading another file and making sure it's not present? ::: widget/windows/nsFilePicker.cpp @@ +224,5 @@ > > +NS_IMETHODIMP nsFilePicker::Init(nsIDOMWindow *aParent, const nsAString& aTitle, PRInt16 aMode) > +{ > + nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aParent); > + nsIDocShell* docShell = window->GetDocShell(); This should probably be |window ? window->GetDocShell() : NULL|. do_QueryInterface is null-safe, so we shouldn't need any other null checks. @@ +1287,5 @@ > > bool > nsFilePicker::IsPrivacyModeEnabled() > { > + bool usingPB; This method can become |return mLoadContext && mLoadContext->UsePrivateBrowsing();| since there's a simplified getter at http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsILoadContext.idl#96. ::: widget/windows/nsFilePicker.h @@ +54,5 @@ > #undef _WIN32_IE > #define _WIN32_IE _WIN32_IE_IE70 > #endif > > +#include "nsILoadContext.h" We can remove this include and use a forward declaration instead: |class nsILoadContext;|. @@ +137,5 @@ > static void PickerCallbackTimerFunc(nsITimer *aTimer, void *aPicker); > static UINT_PTR CALLBACK MultiFilePickerHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); > static UINT_PTR CALLBACK FilePickerHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); > > + nsCOMPtr<nsILoadContext> loadContext; mLoadContext
Attachment #613337 -
Flags: feedback+
Assignee | ||
Comment 12•12 years ago
|
||
Forward declaration yields error 'use of undefined type nsILoadContext' (both before and after #include block) so unless I'm mistaken including nsILoadContext.h is necessary.
Reporter | ||
Comment 13•12 years ago
|
||
Including nsILoadContext.h in the CPP file is necessary, but forward declarations in headers are always preferable since they reduce build dependencies.
Assignee | ||
Comment 14•12 years ago
|
||
Tested and correct: - printf of boolean on Ctrl+s - menu > history item - Windows 7 'recent items' behavior
Attachment #613337 -
Attachment is obsolete: true
Attachment #613350 -
Flags: review?(josh)
Reporter | ||
Comment 15•12 years ago
|
||
Comment on attachment 613350 [details] [diff] [review] Improvements from review have been processed Looks good; you'll want to upload another version with the patch metadata (author, commit message, etc.), so please make the forward declaration change at the same time when you do. Let's see what Jim says!
Attachment #613350 -
Flags: review?(josh) → review?(jmathies)
![]() |
||
Comment 16•12 years ago
|
||
Comment on attachment 613350 [details] [diff] [review] Improvements from review have been processed Does this means we are moving toward private browsing per tab? (Which would be awesome!)
Attachment #613350 -
Flags: review?(jmathies) → review+
Assignee | ||
Comment 17•12 years ago
|
||
Attachment #613350 -
Attachment is obsolete: true
Attachment #613368 -
Flags: review?(jmathies)
Reporter | ||
Comment 18•12 years ago
|
||
Comment on attachment 613368 [details] [diff] [review] Proposed patch: use reference to docShell's loadContext to determine privacy mode This got an r+ from jimm, so I'll check it in.
Attachment #613368 -
Flags: review?(jmathies)
Reporter | ||
Comment 19•12 years ago
|
||
http://hg.mozilla.org/integration/mozilla-inbound/rev/490b6732369e And yes, jimm, per-window PB mode is under way!
Reporter | ||
Updated•12 years ago
|
Target Milestone: --- → mozilla14
Comment 20•12 years ago
|
||
Thanks a lot for your patch, Diana! https://hg.mozilla.org/mozilla-central/rev/490b6732369e Let me know if you're interested to work on another bug about per-window private browsing. :-)
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 21•12 years ago
|
||
(In reply to Ehsan Akhgari [:ehsan] from comment #20) > Thanks a lot for your patch, Diana! > > https://hg.mozilla.org/mozilla-central/rev/490b6732369e > > Let me know if you're interested to work on another bug about per-window > private browsing. :-) Yes! :) Josh has already sent me an e-mail with some suggestions for bugs, this was one of them. Will look at that message again, but any other suggestions are welcome. Feel free to e-mail me.
You need to log in
before you can comment on or make changes to this bug.
Description
•