dom/ipc/FilePickerParent.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/ipc/FilePickerParent.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * vim: set sw=4 ts=8 et tw=80 :
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_FilePickerParent_h
    1.11 +#define mozilla_dom_FilePickerParent_h
    1.12 +
    1.13 +#include "nsIDOMFile.h"
    1.14 +#include "nsIEventTarget.h"
    1.15 +#include "nsIFilePicker.h"
    1.16 +#include "nsCOMArray.h"
    1.17 +#include "nsThreadUtils.h"
    1.18 +#include "mozilla/dom/PFilePickerParent.h"
    1.19 +
    1.20 +namespace mozilla {
    1.21 +namespace dom {
    1.22 +
    1.23 +class FilePickerParent : public PFilePickerParent
    1.24 +{
    1.25 + public:
    1.26 +  FilePickerParent(const nsString& aTitle,
    1.27 +                   const int16_t& aMode)
    1.28 +  : mTitle(aTitle)
    1.29 +  , mMode(aMode)
    1.30 +  {}
    1.31 +
    1.32 +  virtual ~FilePickerParent();
    1.33 +
    1.34 +  void Done(int16_t aResult);
    1.35 +  void SendFiles(const nsCOMArray<nsIDOMFile>& aDomfiles);
    1.36 +
    1.37 +  virtual bool RecvOpen(const int16_t& aSelectedType,
    1.38 +                        const bool& aAddToRecentDocs,
    1.39 +                        const nsString& aDefaultFile,
    1.40 +                        const nsString& aDefaultExtension,
    1.41 +                        const InfallibleTArray<nsString>& aFilters,
    1.42 +                        const InfallibleTArray<nsString>& aFilterNames) MOZ_OVERRIDE;
    1.43 +
    1.44 +  virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
    1.45 +
    1.46 +  class FilePickerShownCallback : public nsIFilePickerShownCallback
    1.47 +  {
    1.48 +  public:
    1.49 +    FilePickerShownCallback(FilePickerParent* aFilePickerParent)
    1.50 +      : mFilePickerParent(aFilePickerParent)
    1.51 +    { }
    1.52 +    virtual ~FilePickerShownCallback() {}
    1.53 +
    1.54 +    NS_DECL_ISUPPORTS
    1.55 +    NS_DECL_NSIFILEPICKERSHOWNCALLBACK
    1.56 +
    1.57 +    void Destroy();
    1.58 +
    1.59 +  private:
    1.60 +    FilePickerParent* mFilePickerParent;
    1.61 +  };
    1.62 +
    1.63 + private:
    1.64 +  bool CreateFilePicker();
    1.65 +
    1.66 +  class FileSizeAndDateRunnable : public nsRunnable
    1.67 +  {
    1.68 +    FilePickerParent* mFilePickerParent;
    1.69 +    nsCOMArray<nsIDOMFile> mDomfiles;
    1.70 +    nsCOMPtr<nsIEventTarget> mEventTarget;
    1.71 +
    1.72 +  public:
    1.73 +    FileSizeAndDateRunnable(FilePickerParent *aFPParent, nsCOMArray<nsIDOMFile>& aDomfiles);
    1.74 +    bool Dispatch();
    1.75 +    NS_IMETHOD Run();
    1.76 +    void Destroy();
    1.77 +  };
    1.78 +
    1.79 +  nsRefPtr<FileSizeAndDateRunnable> mRunnable;
    1.80 +  nsRefPtr<FilePickerShownCallback> mCallback;
    1.81 +  nsCOMPtr<nsIFilePicker> mFilePicker;
    1.82 +
    1.83 +  nsString mTitle;
    1.84 +  int16_t mMode;
    1.85 +  int16_t mResult;
    1.86 +};
    1.87 +
    1.88 +} // namespace dom
    1.89 +} // namespace mozilla
    1.90 +
    1.91 +#endif

mercurial