Skip to content

Commit

Permalink
Bug 949666 - Save last used upload dir with e10s. r=billm
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpie committed Nov 9, 2014
1 parent f2786d3 commit 2ee0397
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
6 changes: 4 additions & 2 deletions dom/html/HTMLInputElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,11 +1032,12 @@ UploadLastDir::FetchDirectoryAndDisplayPicker(nsIDocument* aDoc,
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 =
Expand All @@ -1062,10 +1063,11 @@ UploadLastDir::StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* 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");
Expand Down
11 changes: 10 additions & 1 deletion dom/ipc/FilePickerParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ FilePickerParent::RecvOpen(const int16_t& aSelectedType,
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);
Expand All @@ -219,6 +220,14 @@ FilePickerParent::RecvOpen(const int16_t& aSelectedType,
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);
Expand Down
3 changes: 2 additions & 1 deletion dom/ipc/FilePickerParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class FilePickerParent : public PFilePickerParent
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;

Expand Down
3 changes: 2 additions & 1 deletion dom/ipc/PFilePicker.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ protocol PFilePicker

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);
Expand Down
9 changes: 7 additions & 2 deletions widget/nsFilePickerProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ 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;
}
Expand Down

0 comments on commit 2ee0397

Please sign in to comment.