From a62bfe14df479cf3f4924cda9b3cd26818d97834 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Mon, 8 Jun 2015 14:01:01 +0100 Subject: [PATCH] Bug 1175860 - Add some documentation to UploadLastDir to make its workings clearer. r=baku --- dom/html/HTMLInputElement.cpp | 3 +++ dom/html/HTMLInputElement.h | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index b2969758b015..2b67f5fdc491 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -805,6 +805,9 @@ UploadLastDir::StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aDir) return NS_ERROR_OUT_OF_MEMORY; prefValue->SetAsAString(unicodePath); + // Use the document's current load context to ensure that the content pref + // service doesn't persistently store this directory for this domain if the + // user is using private browsing: nsCOMPtr loadContext = aDoc->GetLoadContext(); return contentPrefService->Set(spec, CPS_PREF_NAME, prefValue, loadContext, nullptr); } diff --git a/dom/html/HTMLInputElement.h b/dom/html/HTMLInputElement.h index 1ce9f38055db..0e642ce1b0d8 100644 --- a/dom/html/HTMLInputElement.h +++ b/dom/html/HTMLInputElement.h @@ -39,8 +39,17 @@ class Date; class File; class FileList; -class UploadLastDir final : public nsIObserver, public nsSupportsWeakReference { - +/** + * A class we use to create a singleton object that is used to keep track of + * the last directory from which the user has picked files (via + * ) on a per-domain basis. The implementation uses + * nsIContentPrefService2/NS_CONTENT_PREF_SERVICE_CONTRACTID to store the last + * directory per-domain, and to ensure that whether the directories are + * persistently saved (saved across sessions) or not honors whether or not the + * page is being viewed in private browsing. + */ +class UploadLastDir final : public nsIObserver, public nsSupportsWeakReference +{ ~UploadLastDir() {} public: