OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_TAB_CONTENTS_TAB_CONTENTS_FILE_SELECT_HELPER_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_FILE_SELECT_HELPER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <vector> |
| 10 |
| 11 #include "chrome/browser/shell_dialogs.h" |
| 12 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 13 #include "net/base/directory_lister.h" |
| 14 |
| 15 class RenderViewHost; |
| 16 class TabContents; |
| 17 struct ViewHostMsg_RunFileChooser_Params; |
| 18 |
| 19 class TabContentsFileSelectHelper |
| 20 : public SelectFileDialog::Listener, |
| 21 public net::DirectoryLister::DirectoryListerDelegate, |
| 22 public RenderViewHostDelegate::FileSelect { |
| 23 public: |
| 24 explicit TabContentsFileSelectHelper(TabContents* tab_contents); |
| 25 |
| 26 ~TabContentsFileSelectHelper(); |
| 27 |
| 28 // SelectFileDialog::Listener |
| 29 virtual void FileSelected(const FilePath& path, int index, void* params); |
| 30 virtual void MultiFilesSelected(const std::vector<FilePath>& files, |
| 31 void* params); |
| 32 virtual void FileSelectionCanceled(void* params); |
| 33 |
| 34 // net::DirectoryLister::DirectoryListerDelegate |
| 35 virtual void OnListFile( |
| 36 const net::DirectoryLister::DirectoryListerData& data); |
| 37 virtual void OnListDone(int error); |
| 38 |
| 39 // RenderViewHostDelegate::FileSelect |
| 40 virtual void RunFileChooser(const ViewHostMsg_RunFileChooser_Params& params); |
| 41 |
| 42 private: |
| 43 // Returns the RenderViewHost of tab_contents_. |
| 44 RenderViewHost* GetRenderViewHost(); |
| 45 |
| 46 // Helper method for handling the SelectFileDialog::Listener callbacks. |
| 47 void DirectorySelected(const FilePath& path); |
| 48 |
| 49 // The tab contents this class is helping. |tab_contents_| owns this object, |
| 50 // so this pointer is guaranteed to be valid. |
| 51 TabContents* tab_contents_; |
| 52 |
| 53 // Dialog box used for choosing files to upload from file form fields. |
| 54 scoped_refptr<SelectFileDialog> select_file_dialog_; |
| 55 |
| 56 // The type of file dialog last shown. |
| 57 SelectFileDialog::Type dialog_type_; |
| 58 |
| 59 // The current directory lister (runs on a separate thread). |
| 60 scoped_refptr<net::DirectoryLister> directory_lister_; |
| 61 |
| 62 // The current directory lister results, which may update incrementally |
| 63 // as the listing proceeds. |
| 64 std::vector<FilePath> directory_lister_results_; |
| 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(TabContentsFileSelectHelper); |
| 67 }; |
| 68 |
| 69 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_FILE_SELECT_HELPER_H_ |
OLD | NEW |