12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef UI_SHELL_DIALOGS_SELECT_FILE_DIALOG_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define UI_SHELL_DIALOGS_SELECT_FILE_DIALOG_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/callback_forward.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/ref_counted.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
167d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/strings/string16.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/native_widget_types.h"
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/shell_dialogs/base_shell_dialog.h"
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/shell_dialogs/shell_dialogs_export.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui {
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SelectFileDialogFactory;
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SelectFilePolicy;
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct SelectedFileInfo;
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ShellDialogsDelegate;
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Shows a dialog box for selecting a file or a folder.
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class SHELL_DIALOGS_EXPORT SelectFileDialog
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    : public base::RefCountedThreadSafe<SelectFileDialog>,
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      public BaseShellDialog {
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum Type {
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SELECT_NONE,
34a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
35a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    // For opening a folder.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SELECT_FOLDER,
37a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
38a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    // Like SELECT_FOLDER, but the dialog UI should explicitly show it's
39a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    // specifically for "upload".
40a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    SELECT_UPLOAD_FOLDER,
41a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
42a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    // For saving into a file, allowing a nonexistent file to be selected.
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SELECT_SAVEAS_FILE,
44a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
45a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    // For opening a file.
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SELECT_OPEN_FILE,
47a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
48a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)    // Like SELECT_OPEN_FILE, but allowing multiple files to open.
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SELECT_OPEN_MULTI_FILE
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // An interface implemented by a Listener object wishing to know about the
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the result of the Select File/Folder action. These callbacks must be
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // re-entrant.
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  class SHELL_DIALOGS_EXPORT Listener {
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   public:
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Notifies the Listener that a file/folder selection has been made. The
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // file/folder path is in |path|. |params| is contextual passed to
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // SelectFile. |index| specifies the index of the filter passed to the
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // the initial call to SelectFile.
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    virtual void FileSelected(const base::FilePath& path,
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              int index, void* params) = 0;
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Similar to FileSelected() but takes SelectedFileInfo instead of
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // base::FilePath. Used for passing extra information (ex. display name).
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    //
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // If not overridden, calls FileSelected() with path from |file|.
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual void FileSelectedWithExtraInfo(
69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        const SelectedFileInfo& file,
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        int index,
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        void* params);
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Notifies the Listener that many files have been selected. The
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // files are in |files|. |params| is contextual passed to SelectFile.
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual void MultiFilesSelected(
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        const std::vector<base::FilePath>& files, void* params) {}
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Similar to MultiFilesSelected() but takes SelectedFileInfo instead of
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // base::FilePath. Used for passing extra information (ex. display name).
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    //
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // If not overridden, calls MultiFilesSelected() with paths from |files|.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual void MultiFilesSelectedWithExtraInfo(
83868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        const std::vector<SelectedFileInfo>& files,
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        void* params);
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Notifies the Listener that the file/folder selection was aborted (via
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // the  user canceling or closing the selection dialog box, for example).
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // |params| is contextual passed to SelectFile.
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual void FileSelectionCanceled(void* params) {}
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)   protected:
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    virtual ~Listener() {}
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the factory that creates SelectFileDialog objects, overriding default
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // behaviour.
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is optional and should only be used by components that have to live
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // elsewhere in the tree due to layering violations. (For example, because of
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a dependency on chrome's extension system.)
101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  static void SetFactory(SelectFileDialogFactory* factory);
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Creates a dialog box helper. This is an inexpensive wrapper around the
1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // platform-native file selection dialog. |policy| is an optional class that
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // can prevent showing a dialog.
1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static scoped_refptr<SelectFileDialog> Create(Listener* listener,
107868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                                                SelectFilePolicy* policy);
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Holds information about allowed extensions on a file save dialog.
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  struct SHELL_DIALOGS_EXPORT FileTypeInfo {
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    FileTypeInfo();
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ~FileTypeInfo();
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // A list of allowed extensions. For example, it might be
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    //
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    //   { { "htm", "html" }, { "txt" } }
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    //
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Only pass more than one extension in the inner vector if the extensions
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // are equivalent. Do NOT include leading periods.
1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    std::vector<std::vector<base::FilePath::StringType> > extensions;
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Overrides the system descriptions of the specified extensions. Entries
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // correspond to |extensions|; if left blank the system descriptions will
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // be used.
125868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    std::vector<base::string16> extension_description_overrides;
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Specifies whether there will be a filter added for all files (i.e. *.*).
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool include_all_files;
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1303240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch    // Specifies whether the caller can directly support file paths pointing to
1313240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch    // files/folders on Google Drive. If the flag is true, the file dialog does
1323240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch    // nothing special; just returns a Drive path. If it is false, the dialog
1333240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch    // creates a local replica of the Drive file and returns its path, so that
1343240926e260ce088908e02ac07a6cf7b0c0cbf44Ben Murdoch    // the caller can use it without any difference than when it were local.
1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    bool support_drive;
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Selects a File.
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Before doing anything this function checks if FileBrowsing is forbidden
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // by Policy. If so, it tries to show an InfoBar and behaves as though no File
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // was selected (the user clicked `Cancel` immediately).
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Otherwise it will start displaying the dialog box. This will also
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // block the calling window until the dialog box is complete. The listener
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // associated with this object will be notified when the selection is
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // complete.
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |type| is the type of file dialog to be shown, see Type enumeration above.
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |title| is the title to be displayed in the dialog. If this string is
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   empty, the default title is used.
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |default_path| is the default path and suggested file name to be shown in
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   the dialog. This only works for SELECT_SAVEAS_FILE and SELECT_OPEN_FILE.
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   Can be an empty string to indicate the platform default.
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |file_types| holds the information about the file types allowed. Pass NULL
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   to get no special behavior
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |file_type_index| is the 1-based index into the file type list in
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   |file_types|. Specify 0 if you don't need to specify extension behavior.
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |default_extension| is the default extension to add to the file if the
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   user doesn't type one. This should NOT include the '.'. On Windows, if
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   you specify this you must also specify |file_types|.
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |owning_window| is the window the dialog is modal to, or NULL for a
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   modeless dialog.
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |params| is data from the calling context which will be passed through to
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   the listener. Can be NULL.
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NOTE: only one instance of any shell dialog can be shown per owning_window
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //       at a time (for obvious reasons).
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SelectFile(Type type,
166868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                  const base::string16& title,
1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                  const base::FilePath& default_path,
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                  const FileTypeInfo* file_types,
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                  int file_type_index,
1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                  const base::FilePath::StringType& default_extension,
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                  gfx::NativeWindow owning_window,
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                  void* params);
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool HasMultipleFileTypeChoices();
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Sets the global ShellDialogsDelegate. Defaults to NULL.
1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static void SetShellDialogsDelegate(ShellDialogsDelegate* delegate);
1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class base::RefCountedThreadSafe<SelectFileDialog>;
180868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  explicit SelectFileDialog(Listener* listener, SelectFilePolicy* policy);
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~SelectFileDialog();
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Displays the actual file-selection dialog.
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is overridden in the platform-specific descendants of FileSelectDialog
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and gets called from SelectFile after testing the
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // AllowFileSelectionDialogs-Policy.
1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void SelectFileImpl(
1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      Type type,
189868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      const base::string16& title,
1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::FilePath& default_path,
1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const FileTypeInfo* file_types,
1922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      int file_type_index,
1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::FilePath::StringType& default_extension,
1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      gfx::NativeWindow owning_window,
1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      void* params) = 0;
1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns the global ShellDialogsDelegate instance if any.
1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ShellDialogsDelegate* GetShellDialogsDelegate();
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The listener to be notified of selection completion.
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Listener* listener_;
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Tests if the file selection dialog can be displayed by
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // testing if the AllowFileSelectionDialogs-Policy is
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // either unset or set to true.
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool CanOpenSelectFileDialog();
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Informs the |listener_| that the file selection dialog was canceled. Moved
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to a function for being able to post it to the message loop.
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CancelFileSelection(void* params);
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the dialog has multiple file type choices.
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool HasMultipleFileTypeChoicesImpl() = 0;
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
216868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_ptr<SelectFilePolicy> select_file_policy_;
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(SelectFileDialog);
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace ui
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // UI_SHELL_DIALOGS_SELECT_FILE_DIALOG_H_
224