widget/nsBaseFilePicker.h
author Noemi Erli <nerli@mozilla.com>
Thu, 20 Jun 2019 22:13:33 +0300
changeset 479716 7034f38fc20714e2467db5288b4896db811afbef
parent 455356 ab592ce5d5ae37bd2d5008600d8c566ed30becae
child 482223 ddbf599fa85804c64acd157402f9cd44f20a3a4b
permissions -rw-r--r--
Backed out 3 changesets (bug 1557265) for causing Linux bustages CLOSED TREE Backed out changeset 5e797f74091a (bug 1557265) Backed out changeset f10c947516e0 (bug 1557265) Backed out changeset f7e5ef31a50b (bug 1557265)

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * 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 nsBaseFilePicker_h__
#define nsBaseFilePicker_h__

#include "nsISupports.h"
#include "nsIFilePicker.h"
#include "nsISimpleEnumerator.h"
#include "nsArrayEnumerator.h"
#include "nsCOMPtr.h"
#include "nsString.h"

class nsPIDOMWindowOuter;
class nsIWidget;

class nsBaseFilePicker : public nsIFilePicker {
  class AsyncShowFilePicker;

 public:
  nsBaseFilePicker();
  virtual ~nsBaseFilePicker();

  NS_IMETHOD Init(mozIDOMWindowProxy* aParent, const nsAString& aTitle,
                  int16_t aMode) override;

  NS_IMETHOD Open(nsIFilePickerShownCallback* aCallback) override;
  NS_IMETHOD AppendFilters(int32_t filterMask) override;
  NS_IMETHOD AppendRawFilter(const nsAString& aFilter) override;
  NS_IMETHOD GetFilterIndex(int32_t* aFilterIndex) override;
  NS_IMETHOD SetFilterIndex(int32_t aFilterIndex) override;
  NS_IMETHOD GetFiles(nsISimpleEnumerator** aFiles) override;
  NS_IMETHOD GetDisplayDirectory(nsIFile** aDisplayDirectory) override;
  NS_IMETHOD SetDisplayDirectory(nsIFile* aDisplayDirectory) override;
  NS_IMETHOD GetDisplaySpecialDirectory(nsAString& aDisplayDirectory) override;
  NS_IMETHOD SetDisplaySpecialDirectory(
      const nsAString& aDisplayDirectory) override;
  NS_IMETHOD GetAddToRecentDocs(bool* aFlag) override;
  NS_IMETHOD SetAddToRecentDocs(bool aFlag) override;
  NS_IMETHOD GetMode(int16_t* aMode) override;
  NS_IMETHOD SetOkButtonLabel(const nsAString& aLabel) override;
  NS_IMETHOD GetOkButtonLabel(nsAString& aLabel) override;

  NS_IMETHOD GetDomFileOrDirectory(nsISupports** aValue) override;
  NS_IMETHOD GetDomFileOrDirectoryEnumerator(
      nsISimpleEnumerator** aValue) override;

 protected:
  virtual void InitNative(nsIWidget* aParent, const nsAString& aTitle) = 0;
  virtual nsresult Show(int16_t* _retval) = 0;

  bool mAddToRecentDocs;
  nsCOMPtr<nsIFile> mDisplayDirectory;
  nsString mDisplaySpecialDirectory;

  nsCOMPtr<nsPIDOMWindowOuter> mParent;
  int16_t mMode;
  nsString mOkButtonLabel;
  InfallibleTArray<nsString> mRawFilters;
};

#endif  // nsBaseFilePicker_h__