2015-05-03 22:32:37 +03: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-18 04:30:06 +04: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-25 01:09:03 +04:00
|
|
|
#include "nsIEventTarget.h"
|
2014-02-18 04:30:06 +04:00
|
|
|
#include "nsIFilePicker.h"
|
2014-02-25 01:09:03 +04:00
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsThreadUtils.h"
|
2015-03-19 00:21:02 +03:00
|
|
|
#include "mozilla/dom/File.h"
|
2014-02-18 04:30:06 +04: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 15:11:03 +03:00
|
|
|
void SendFiles(const nsTArray<nsRefPtr<BlobImpl>>& aDomBlobs);
|
2014-02-18 04:30:06 +04:00
|
|
|
|
|
|
|
virtual bool RecvOpen(const int16_t& aSelectedType,
|
|
|
|
const bool& aAddToRecentDocs,
|
|
|
|
const nsString& aDefaultFile,
|
|
|
|
const nsString& aDefaultExtension,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<nsString>&& aFilters,
|
|
|
|
InfallibleTArray<nsString>&& aFilterNames,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsString& aDisplayDirectory) override;
|
2014-02-18 04:30:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
2014-02-18 04:30:06 +04:00
|
|
|
|
|
|
|
class FilePickerShownCallback : public nsIFilePickerShownCallback
|
|
|
|
{
|
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit FilePickerShownCallback(FilePickerParent* aFilePickerParent)
|
2014-02-18 04:30:06 +04:00
|
|
|
: mFilePickerParent(aFilePickerParent)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIFILEPICKERSHOWNCALLBACK
|
|
|
|
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
private:
|
2014-06-23 23:56:07 +04:00
|
|
|
virtual ~FilePickerShownCallback() {}
|
2014-02-18 04:30:06 +04:00
|
|
|
FilePickerParent* mFilePickerParent;
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool CreateFilePicker();
|
|
|
|
|
2014-02-25 01:09:03 +04:00
|
|
|
class FileSizeAndDateRunnable : public nsRunnable
|
|
|
|
{
|
|
|
|
FilePickerParent* mFilePickerParent;
|
2015-05-12 15:11:03 +03:00
|
|
|
nsTArray<nsRefPtr<BlobImpl>> mBlobs;
|
2014-02-25 01:09:03 +04:00
|
|
|
nsCOMPtr<nsIEventTarget> mEventTarget;
|
|
|
|
|
|
|
|
public:
|
2015-05-12 15:11:03 +03:00
|
|
|
FileSizeAndDateRunnable(FilePickerParent *aFPParent, nsTArray<nsRefPtr<BlobImpl>>& aBlobs);
|
2014-02-25 01:09:03 +04:00
|
|
|
bool Dispatch();
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
void Destroy();
|
|
|
|
};
|
|
|
|
|
|
|
|
nsRefPtr<FileSizeAndDateRunnable> mRunnable;
|
2014-02-18 04:30:06 +04:00
|
|
|
nsRefPtr<FilePickerShownCallback> mCallback;
|
|
|
|
nsCOMPtr<nsIFilePicker> mFilePicker;
|
|
|
|
|
|
|
|
nsString mTitle;
|
|
|
|
int16_t mMode;
|
2014-02-25 01:09:03 +04:00
|
|
|
int16_t mResult;
|
2014-02-18 04:30:06 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|