Bug 949666 - Save last used upload dir with e10s. r=billm
☠☠ backed out by 0da722f1ddad ☠ ☠
authorTom Schuster <evilpies@gmail.com>
Sun, 09 Nov 2014 20:26:14 +0100
changeset 239106 1a2c37d55e5e7356bb91789ba8fe7af104fed7ee
parent 239105 bc53cf75bba5477aaf019777fa7c61f75cfb30d8
child 239107 8c8b246906a1aa4f4a734d8f619477459af8c13a
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [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
@@ -1025,22 +1025,16 @@ 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);
 
-  if (XRE_GetProcessType() == GeckoProcessType_Content) {
-    // FIXME (bug 949666): Run this code in the parent process.
-    prefCallback->HandleCompletion(nsIContentPrefCallback2::COMPLETE_ERROR);
-    return NS_OK;
-  }
-
   // 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;
   }
 
@@ -1055,21 +1049,16 @@ UploadLastDir::FetchDirectoryAndDisplayP
 nsresult
 UploadLastDir::StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aDir)
 {
   NS_PRECONDITION(aDoc, "aDoc is null");
   if (!aDir) {
     return NS_OK;
   }
 
-  if (XRE_GetProcessType() == GeckoProcessType_Content) {
-    // FIXME (bug 949666): Run this code in the parent process.
-    return NS_OK;
-  }
-
   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)
     return NS_ERROR_NOT_AVAILABLE;
--- 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)
 {