Home | History | Annotate | Download | only in developer_private
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_ENTRY_PICKER_H_
      6 #define CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_ENTRY_PICKER_H_
      7 
      8 #include "chrome/browser/extensions/extension_function.h"
      9 #include "ui/shell_dialogs/select_file_dialog.h"
     10 
     11 namespace content {
     12 class WebContents;
     13 }
     14 
     15 namespace extensions {
     16 
     17 namespace api {
     18 
     19 class EntryPickerClient {
     20  public:
     21   virtual void FileSelected(const base::FilePath& path) = 0;
     22   virtual void FileSelectionCanceled() = 0;
     23 };
     24 
     25 // Handles showing a dialog to the user to ask for the directory name.
     26 class EntryPicker : public ui::SelectFileDialog::Listener {
     27  public:
     28   EntryPicker(EntryPickerClient* client,
     29               content::WebContents* web_contents,
     30               ui::SelectFileDialog::Type picker_type,
     31               const base::FilePath& last_directory,
     32               const string16& select_title,
     33               const ui::SelectFileDialog::FileTypeInfo& info,
     34               int file_type_index);
     35 
     36   // Allow picker UI to be skipped in testing.
     37   static void SkipPickerAndAlwaysSelectPathForTest(base::FilePath* path);
     38   static void SkipPickerAndAlwaysCancelForTest();
     39   static void StopSkippingPickerForTest();
     40 
     41  protected:
     42 
     43   virtual ~EntryPicker();
     44 
     45  private:
     46   // ui::SelectFileDialog::Listener implementation.
     47   virtual void FileSelected(const base::FilePath& path,
     48                             int index,
     49                             void* params) OVERRIDE;
     50 
     51   virtual void FileSelectionCanceled(void* params) OVERRIDE;
     52 
     53   scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
     54   EntryPickerClient* client_;
     55 
     56   DISALLOW_COPY_AND_ASSIGN(EntryPicker);
     57 };
     58 
     59 }  // namespace api
     60 
     61 }  // namespace extensions
     62 
     63 #endif  // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_ENTRY_PICKER_H_
     64