Bug 949666 - Save last used upload dir with e10s. r=billm
authorTom Schuster <evilpies@gmail.com>
Sun, 09 Nov 2014 20:26:14 +0100
changeset 215629 c9e1814d648d006db6da926266cd060d003043e9
parent 215628 63eace116946532e669949f1ea88ea1a7c98b906
child 215630 451e1d755d89b0c4b678f35ac85a782fccf6752c
push id51799
push userevilpies@gmail.com
push dateThu, 13 Nov 2014 21:08:59 +0000
treeherdermozilla-inbound@c9e1814d648d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs949666
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 949666 - Save last used upload dir with e10s. r=billm
dom/html/HTMLInputElement.cpp
dom/ipc/FilePickerParent.cpp
dom/ipc/FilePickerParent.h
dom/ipc/PFilePicker.ipdl
widget/nsFilePickerProxy.cpp
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -1027,21 +1027,22 @@ UploadLastDir::FetchDirectoryAndDisplayP
 
   nsIURI* docURI = aDoc->GetDocumentURI();
   NS_PRECONDITION(docURI, "docURI is null");
 
   nsCOMPtr<nsILoadContext> loadContext = aDoc->GetLoadContext();
   nsCOMPtr<nsIContentPrefCallback2> prefCallback = 
     new UploadLastDir::ContentPrefCallback(aFilePicker, aFpCallback);
 
+#ifdef MOZ_B2G
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
-    // FIXME (bug 949666): Run this code in the parent process.
     prefCallback->HandleCompletion(nsIContentPrefCallback2::COMPLETE_ERROR);
     return NS_OK;
   }
+#endif
 
   // Attempt to get the CPS, if it's not present we'll fallback to use the Desktop folder
   nsCOMPtr<nsIContentPrefService2> contentPrefService =
     do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID);
   if (!contentPrefService) {
     prefCallback->HandleCompletion(nsIContentPrefCallback2::COMPLETE_ERROR);
     return NS_OK;
   }
@@ -1057,20 +1058,21 @@ UploadLastDir::FetchDirectoryAndDisplayP
 nsresult
 UploadLastDir::StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aDir)
 {
   NS_PRECONDITION(aDoc, "aDoc is null");
   if (!aDir) {
     return NS_OK;
   }
 
+#ifdef MOZ_B2G
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
-    // FIXME (bug 949666): Run this code in the parent process.
     return NS_OK;
   }
+#endif
 
   nsCOMPtr<nsIURI> docURI = aDoc->GetDocumentURI();
   NS_PRECONDITION(docURI, "docURI is null");
 
   // Attempt to get the CPS, if it's not present we'll just return
   nsCOMPtr<nsIContentPrefService2> contentPrefService =
     do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID);
   if (!contentPrefService)
--- a/dom/ipc/FilePickerParent.cpp
+++ b/dom/ipc/FilePickerParent.cpp
@@ -197,33 +197,42 @@ FilePickerParent::CreateFilePicker()
 }
 
 bool
 FilePickerParent::RecvOpen(const int16_t& aSelectedType,
                            const bool& aAddToRecentDocs,
                            const nsString& aDefaultFile,
                            const nsString& aDefaultExtension,
                            const InfallibleTArray<nsString>& aFilters,
-                           const InfallibleTArray<nsString>& aFilterNames)
+                           const InfallibleTArray<nsString>& aFilterNames,
+                           const nsString& aDisplayDirectory)
 {
   if (!CreateFilePicker()) {
     unused << Send__delete__(this, void_t(), nsIFilePicker::returnCancel);
     return true;
   }
 
   mFilePicker->SetAddToRecentDocs(aAddToRecentDocs);
 
   for (uint32_t i = 0; i < aFilters.Length(); ++i) {
     mFilePicker->AppendFilter(aFilterNames[i], aFilters[i]);
   }
 
   mFilePicker->SetDefaultString(aDefaultFile);
   mFilePicker->SetDefaultExtension(aDefaultExtension);
   mFilePicker->SetFilterIndex(aSelectedType);
 
+  if (!aDisplayDirectory.IsEmpty()) {
+    nsCOMPtr<nsIFile> localFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
+    if (localFile) {
+      localFile->InitWithPath(aDisplayDirectory);
+      mFilePicker->SetDisplayDirectory(localFile);
+    }
+  }
+
   mCallback = new FilePickerShownCallback(this);
 
   mFilePicker->Open(mCallback);
   return true;
 }
 
 void
 FilePickerParent::ActorDestroy(ActorDestroyReason aWhy)
--- a/dom/ipc/FilePickerParent.h
+++ b/dom/ipc/FilePickerParent.h
@@ -31,17 +31,18 @@ class FilePickerParent : public PFilePic
   void Done(int16_t aResult);
   void SendFiles(const nsCOMArray<nsIDOMFile>& aDomfiles);
 
   virtual bool RecvOpen(const int16_t& aSelectedType,
                         const bool& aAddToRecentDocs,
                         const nsString& aDefaultFile,
                         const nsString& aDefaultExtension,
                         const InfallibleTArray<nsString>& aFilters,
-                        const InfallibleTArray<nsString>& aFilterNames) MOZ_OVERRIDE;
+                        const InfallibleTArray<nsString>& aFilterNames,
+                        const nsString& aDisplayDirectory) MOZ_OVERRIDE;
 
   virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
 
   class FilePickerShownCallback : public nsIFilePickerShownCallback
   {
   public:
     explicit FilePickerShownCallback(FilePickerParent* aFilePickerParent)
       : mFilePickerParent(aFilePickerParent)
--- a/dom/ipc/PFilePicker.ipdl
+++ b/dom/ipc/PFilePicker.ipdl
@@ -24,16 +24,17 @@ union MaybeInputFiles
 };
 
 protocol PFilePicker
 {
   manager PBrowser;
 
 parent:
     Open(int16_t selectedType, bool addToRecentDocs, nsString defaultFile,
-         nsString defaultExtension, nsString[] filters, nsString[] filterNames);
+         nsString defaultExtension, nsString[] filters, nsString[] filterNames,
+         nsString displayDirectory);
 
 child:
     __delete__(MaybeInputFiles files, int16_t result);
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/widget/nsFilePickerProxy.cpp
+++ b/widget/nsFilePickerProxy.cpp
@@ -131,18 +131,23 @@ nsFilePickerProxy::Show(int16_t* aReturn
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsFilePickerProxy::Open(nsIFilePickerShownCallback* aCallback)
 {
   mCallback = aCallback;
 
-  SendOpen(mSelectedType, mAddToRecentDocs, mDefault,
-           mDefaultExtension, mFilters, mFilterNames);
+  nsString displayDirectory;
+  if (mDisplayDirectory) {
+    mDisplayDirectory->GetPath(displayDirectory);
+  }
+
+  SendOpen(mSelectedType, mAddToRecentDocs, mDefault, mDefaultExtension,
+           mFilters, mFilterNames, displayDirectory);
 
   return NS_OK;
 }
 
 bool
 nsFilePickerProxy::Recv__delete__(const MaybeInputFiles& aFiles,
                                   const int16_t& aResult)
 {