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" | |
13 #include "chrome/common/notification_observer.h" | 12 #include "chrome/common/notification_observer.h" |
14 #include "chrome/common/notification_registrar.h" | 13 #include "chrome/common/notification_registrar.h" |
15 #include "net/base/directory_lister.h" | 14 #include "net/base/directory_lister.h" |
16 | 15 |
17 class Profile; | 16 class Profile; |
18 class RenderViewHost; | 17 class RenderViewHost; |
19 struct ViewHostMsg_RunFileChooser_Params; | 18 struct ViewHostMsg_RunFileChooser_Params; |
20 | 19 |
21 class FileSelectHelper | 20 class FileSelectHelper |
22 : public SelectFileDialog::Listener, | 21 : public SelectFileDialog::Listener, |
23 public net::DirectoryLister::DirectoryListerDelegate, | 22 public net::DirectoryLister::DirectoryListerDelegate, |
24 public RenderViewHostDelegate::FileSelect, | |
25 public NotificationObserver { | 23 public NotificationObserver { |
26 public: | 24 public: |
27 explicit FileSelectHelper(Profile* profile); | 25 explicit FileSelectHelper(Profile* profile); |
28 ~FileSelectHelper(); | 26 ~FileSelectHelper(); |
29 | 27 |
30 // SelectFileDialog::Listener | 28 // SelectFileDialog::Listener |
31 virtual void FileSelected(const FilePath& path, int index, void* params); | 29 virtual void FileSelected(const FilePath& path, int index, void* params); |
32 virtual void MultiFilesSelected(const std::vector<FilePath>& files, | 30 virtual void MultiFilesSelected(const std::vector<FilePath>& files, |
33 void* params); | 31 void* params); |
34 virtual void FileSelectionCanceled(void* params); | 32 virtual void FileSelectionCanceled(void* params); |
35 | 33 |
36 // net::DirectoryLister::DirectoryListerDelegate | 34 // net::DirectoryLister::DirectoryListerDelegate |
37 virtual void OnListFile( | 35 virtual void OnListFile( |
38 const net::DirectoryLister::DirectoryListerData& data); | 36 const net::DirectoryLister::DirectoryListerData& data); |
39 virtual void OnListDone(int error); | 37 virtual void OnListDone(int error); |
40 | 38 |
41 // RenderViewHostDelegate::FileSelect | 39 // Show the file chooser dialog. |
42 virtual void RunFileChooser(RenderViewHost* render_view_host, | 40 void RunFileChooser(RenderViewHost* render_view_host, |
43 const ViewHostMsg_RunFileChooser_Params& params); | 41 const ViewHostMsg_RunFileChooser_Params& params); |
44 | 42 |
45 private: | 43 private: |
46 // NotificationObserver implementation. | 44 // NotificationObserver implementation. |
47 virtual void Observe(NotificationType type, | 45 virtual void Observe(NotificationType type, |
48 const NotificationSource& source, | 46 const NotificationSource& source, |
49 const NotificationDetails& details); | 47 const NotificationDetails& details); |
50 | 48 |
51 // Helper method for handling the SelectFileDialog::Listener callbacks. | 49 // Helper method for handling the SelectFileDialog::Listener callbacks. |
52 void DirectorySelected(const FilePath& path); | 50 void DirectorySelected(const FilePath& path); |
53 | 51 |
(...skipping 22 matching lines...) Expand all Loading... |
76 // as the listing proceeds. | 74 // as the listing proceeds. |
77 std::vector<FilePath> directory_lister_results_; | 75 std::vector<FilePath> directory_lister_results_; |
78 | 76 |
79 // Registrar for notifications regarding our RenderViewHost. | 77 // Registrar for notifications regarding our RenderViewHost. |
80 NotificationRegistrar notification_registrar_; | 78 NotificationRegistrar notification_registrar_; |
81 | 79 |
82 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); | 80 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); |
83 }; | 81 }; |
84 | 82 |
85 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ | 83 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ |
OLD | NEW |