2015-05-03 12:32:37 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2014-02-17 16:30:06 -08:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_FilePickerParent_h
|
|
|
|
#define mozilla_dom_FilePickerParent_h
|
|
|
|
|
2014-02-24 13:09:03 -08:00
|
|
|
#include "nsIEventTarget.h"
|
2014-02-17 16:30:06 -08:00
|
|
|
#include "nsIFilePicker.h"
|
2014-02-24 13:09:03 -08:00
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsThreadUtils.h"
|
2015-03-18 14:21:02 -07:00
|
|
|
#include "mozilla/dom/File.h"
|
2014-02-17 16:30:06 -08:00
|
|
|
#include "mozilla/dom/PFilePickerParent.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class FilePickerParent : public PFilePickerParent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FilePickerParent(const nsString& aTitle,
|
|
|
|
const int16_t& aMode)
|
|
|
|
: mTitle(aTitle)
|
|
|
|
, mMode(aMode)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~FilePickerParent();
|
|
|
|
|
|
|
|
void Done(int16_t aResult);
|
2015-05-12 05:11:03 -07:00
|
|
|
void SendFiles(const nsTArray<nsRefPtr<BlobImpl>>& aDomBlobs);
|
2014-02-17 16:30:06 -08:00
|
|
|
|
|
|
|
virtual bool RecvOpen(const int16_t& aSelectedType,
|
|
|
|
const bool& aAddToRecentDocs,
|
|
|
|
const nsString& aDefaultFile,
|
|
|
|
const nsString& aDefaultExtension,
|
2015-01-16 11:58:52 -08:00
|
|
|
InfallibleTArray<nsString>&& aFilters,
|
|
|
|
InfallibleTArray<nsString>&& aFilterNames,
|
2015-03-21 09:28:04 -07:00
|
|
|
const nsString& aDisplayDirectory) override;
|
2014-02-17 16:30:06 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
2014-02-17 16:30:06 -08:00
|
|
|
|
|
|
|
class FilePickerShownCallback : public nsIFilePickerShownCallback
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit FilePickerShownCallback(FilePickerParent* aFilePickerParent)
|
2014-02-17 16:30:06 -08:00
|
|
|
: mFilePickerParent(aFilePickerParent)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIFILEPICKERSHOWNCALLBACK
|
|
|
|
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
private:
|
2014-06-23 12:56:07 -07:00
|
|
|
virtual ~FilePickerShownCallback() {}
|
2014-02-17 16:30:06 -08:00
|
|
|
FilePickerParent* mFilePickerParent;
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool CreateFilePicker();
|
|
|
|
|
2014-02-24 13:09:03 -08:00
|
|
|
class FileSizeAndDateRunnable : public nsRunnable
|
|
|
|
{
|
|
|
|
FilePickerParent* mFilePickerParent;
|
2015-05-12 05:11:03 -07:00
|
|
|
nsTArray<nsRefPtr<BlobImpl>> mBlobs;
|
2014-02-24 13:09:03 -08:00
|
|
|
nsCOMPtr<nsIEventTarget> mEventTarget;
|
|
|
|
|
|
|
|
public:
|
2015-05-12 05:11:03 -07:00
|
|
|
FileSizeAndDateRunnable(FilePickerParent *aFPParent, nsTArray<nsRefPtr<BlobImpl>>& aBlobs);
|
2014-02-24 13:09:03 -08:00
|
|
|
bool Dispatch();
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
void Destroy();
|
|
|
|
};
|
|
|
|
|
|
|
|
nsRefPtr<FileSizeAndDateRunnable> mRunnable;
|
2014-02-17 16:30:06 -08:00
|
|
|
nsRefPtr<FilePickerShownCallback> mCallback;
|
|
|
|
nsCOMPtr<nsIFilePicker> mFilePicker;
|
|
|
|
|
|
|
|
nsString mTitle;
|
|
|
|
int16_t mMode;
|
2014-02-24 13:09:03 -08:00
|
|
|
int16_t mResult;
|
2014-02-17 16:30:06 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|