| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_FILE_SELECT_HELPER_H_ | 5 #ifndef CHROME_BROWSER_FILE_SELECT_HELPER_H_ |
| 6 #define CHROME_BROWSER_FILE_SELECT_HELPER_H_ | 6 #define CHROME_BROWSER_FILE_SELECT_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "chrome/browser/shell_dialogs.h" | 11 #include "chrome/browser/shell_dialogs.h" |
| 12 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 12 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 13 #include "chrome/common/notification_observer.h" | 13 #include "chrome/common/notification_observer.h" |
| 14 #include "chrome/common/notification_registrar.h" | 14 #include "chrome/common/notification_registrar.h" |
| 15 #include "net/base/directory_lister.h" | 15 #include "net/base/directory_lister.h" |
| 16 | 16 |
| 17 class Profile; | 17 class Profile; |
| 18 class RenderViewHost; | 18 class RenderViewHost; |
| 19 struct ViewHostMsg_RunFileChooser_Params; | 19 struct ViewHostMsg_RunFileChooser_Params; |
| 20 | 20 |
| 21 class FileSelectHelper | 21 class FileSelectHelper |
| 22 : public SelectFileDialog::Listener, | 22 : public SelectFileDialog::Listener, |
| 23 public net::DirectoryLister::DirectoryListerDelegate, | 23 public net::DirectoryLister::Delegate, |
| 24 public RenderViewHostDelegate::FileSelect, | 24 public RenderViewHostDelegate::FileSelect, |
| 25 public NotificationObserver { | 25 public NotificationObserver { |
| 26 public: | 26 public: |
| 27 explicit FileSelectHelper(Profile* profile); | 27 explicit FileSelectHelper(Profile* profile); |
| 28 ~FileSelectHelper(); | 28 ~FileSelectHelper(); |
| 29 | 29 |
| 30 // SelectFileDialog::Listener | 30 // SelectFileDialog::Listener |
| 31 virtual void FileSelected(const FilePath& path, int index, void* params); | 31 virtual void FileSelected(const FilePath& path, int index, void* params); |
| 32 virtual void MultiFilesSelected(const std::vector<FilePath>& files, | 32 virtual void MultiFilesSelected(const std::vector<FilePath>& files, |
| 33 void* params); | 33 void* params); |
| 34 virtual void FileSelectionCanceled(void* params); | 34 virtual void FileSelectionCanceled(void* params); |
| 35 | 35 |
| 36 // net::DirectoryLister::DirectoryListerDelegate | 36 // net::DirectoryLister::Delegate |
| 37 virtual void OnListFile( | 37 virtual void OnListFile(const net::DirectoryLister::Data& data); |
| 38 const net::DirectoryLister::DirectoryListerData& data); | |
| 39 virtual void OnListDone(int error); | 38 virtual void OnListDone(int error); |
| 40 | 39 |
| 41 // RenderViewHostDelegate::FileSelect | 40 // RenderViewHostDelegate::FileSelect |
| 42 virtual void RunFileChooser(RenderViewHost* render_view_host, | 41 virtual void RunFileChooser(RenderViewHost* render_view_host, |
| 43 const ViewHostMsg_RunFileChooser_Params& params); | 42 const ViewHostMsg_RunFileChooser_Params& params); |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 // NotificationObserver implementation. | 45 // NotificationObserver implementation. |
| 47 virtual void Observe(NotificationType type, | 46 virtual void Observe(NotificationType type, |
| 48 const NotificationSource& source, | 47 const NotificationSource& source, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 // The RenderViewHost for the page we are associated with. | 62 // The RenderViewHost for the page we are associated with. |
| 64 RenderViewHost* render_view_host_; | 63 RenderViewHost* render_view_host_; |
| 65 | 64 |
| 66 // Dialog box used for choosing files to upload from file form fields. | 65 // Dialog box used for choosing files to upload from file form fields. |
| 67 scoped_refptr<SelectFileDialog> select_file_dialog_; | 66 scoped_refptr<SelectFileDialog> select_file_dialog_; |
| 68 | 67 |
| 69 // The type of file dialog last shown. | 68 // The type of file dialog last shown. |
| 70 SelectFileDialog::Type dialog_type_; | 69 SelectFileDialog::Type dialog_type_; |
| 71 | 70 |
| 72 // The current directory lister (runs on a separate thread). | 71 // The current directory lister (runs on a separate thread). |
| 73 scoped_refptr<net::DirectoryLister> directory_lister_; | 72 scoped_ptr<net::DirectoryLister> directory_lister_; |
| 74 | 73 |
| 75 // The current directory lister results, which may update incrementally | 74 // The current directory lister results, which may update incrementally |
| 76 // as the listing proceeds. | 75 // as the listing proceeds. |
| 77 std::vector<FilePath> directory_lister_results_; | 76 std::vector<FilePath> directory_lister_results_; |
| 78 | 77 |
| 79 // Registrar for notifications regarding our RenderViewHost. | 78 // Registrar for notifications regarding our RenderViewHost. |
| 80 NotificationRegistrar notification_registrar_; | 79 NotificationRegistrar notification_registrar_; |
| 81 | 80 |
| 82 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); | 81 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); |
| 83 }; | 82 }; |
| 84 | 83 |
| 85 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ | 84 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ |
| OLD | NEW |