| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "chrome/browser/ui/select_file_dialog.h" | 13 #include "chrome/browser/ui/select_file_dialog.h" |
| 14 #include "content/browser/tab_contents/tab_contents_observer.h" | 14 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "net/base/directory_lister.h" | 17 #include "net/base/directory_lister.h" |
| 18 | 18 |
| 19 class Profile; | 19 class Profile; |
| 20 class RenderViewHost; | 20 class RenderViewHost; |
| 21 struct ViewHostMsg_RunFileChooser_Params; | |
| 22 | 21 |
| 22 namespace content { |
| 23 struct FileChooserParams; |
| 24 } |
| 23 | 25 |
| 24 // This class handles file-selection requests coming from WebUI elements | 26 // This class handles file-selection requests coming from WebUI elements |
| 25 // (via the ExtensionHost class). It implements both the initialisation | 27 // (via the ExtensionHost class). It implements both the initialisation |
| 26 // and listener functions for file-selection dialogs. | 28 // and listener functions for file-selection dialogs. |
| 27 class FileSelectHelper | 29 class FileSelectHelper |
| 28 : public base::RefCountedThreadSafe<FileSelectHelper>, | 30 : public base::RefCountedThreadSafe<FileSelectHelper>, |
| 29 public SelectFileDialog::Listener, | 31 public SelectFileDialog::Listener, |
| 30 public content::NotificationObserver { | 32 public content::NotificationObserver { |
| 31 public: | 33 public: |
| 32 explicit FileSelectHelper(Profile* profile); | 34 explicit FileSelectHelper(Profile* profile); |
| 33 | 35 |
| 34 // Show the file chooser dialog. | 36 // Show the file chooser dialog. |
| 35 void RunFileChooser(RenderViewHost* render_view_host, | 37 void RunFileChooser(RenderViewHost* render_view_host, |
| 36 TabContents* tab_contents, | 38 TabContents* tab_contents, |
| 37 const ViewHostMsg_RunFileChooser_Params& params); | 39 const content::FileChooserParams& params); |
| 38 | 40 |
| 39 // Enumerates all the files in directory. | 41 // Enumerates all the files in directory. |
| 40 void EnumerateDirectory(int request_id, | 42 void EnumerateDirectory(int request_id, |
| 41 RenderViewHost* render_view_host, | 43 RenderViewHost* render_view_host, |
| 42 const FilePath& path); | 44 const FilePath& path); |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 friend class base::RefCountedThreadSafe<FileSelectHelper>; | 47 friend class base::RefCountedThreadSafe<FileSelectHelper>; |
| 46 virtual ~FileSelectHelper(); | 48 virtual ~FileSelectHelper(); |
| 47 | 49 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 } | 65 } |
| 64 private: | 66 private: |
| 65 // This FileSelectHelper owns this object. | 67 // This FileSelectHelper owns this object. |
| 66 FileSelectHelper* parent_; | 68 FileSelectHelper* parent_; |
| 67 int id_; | 69 int id_; |
| 68 | 70 |
| 69 DISALLOW_COPY_AND_ASSIGN(DirectoryListerDispatchDelegate); | 71 DISALLOW_COPY_AND_ASSIGN(DirectoryListerDispatchDelegate); |
| 70 }; | 72 }; |
| 71 | 73 |
| 72 void RunFileChooserOnFileThread( | 74 void RunFileChooserOnFileThread( |
| 73 const ViewHostMsg_RunFileChooser_Params& params); | 75 const content::FileChooserParams& params); |
| 74 void RunFileChooserOnUIThread( | 76 void RunFileChooserOnUIThread( |
| 75 const ViewHostMsg_RunFileChooser_Params& params); | 77 const content::FileChooserParams& params); |
| 76 | 78 |
| 77 // Cleans up and releases this instance. This must be called after the last | 79 // Cleans up and releases this instance. This must be called after the last |
| 78 // callback is received from the file chooser dialog. | 80 // callback is received from the file chooser dialog. |
| 79 void RunFileChooserEnd(); | 81 void RunFileChooserEnd(); |
| 80 | 82 |
| 81 // SelectFileDialog::Listener overrides. | 83 // SelectFileDialog::Listener overrides. |
| 82 virtual void FileSelected( | 84 virtual void FileSelected( |
| 83 const FilePath& path, int index, void* params) OVERRIDE; | 85 const FilePath& path, int index, void* params) OVERRIDE; |
| 84 virtual void MultiFilesSelected(const std::vector<FilePath>& files, | 86 virtual void MultiFilesSelected(const std::vector<FilePath>& files, |
| 85 void* params) OVERRIDE; | 87 void* params) OVERRIDE; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 struct ActiveDirectoryEnumeration; | 135 struct ActiveDirectoryEnumeration; |
| 134 std::map<int, ActiveDirectoryEnumeration*> directory_enumerations_; | 136 std::map<int, ActiveDirectoryEnumeration*> directory_enumerations_; |
| 135 | 137 |
| 136 // Registrar for notifications regarding our RenderViewHost. | 138 // Registrar for notifications regarding our RenderViewHost. |
| 137 content::NotificationRegistrar notification_registrar_; | 139 content::NotificationRegistrar notification_registrar_; |
| 138 | 140 |
| 139 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); | 141 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); |
| 140 }; | 142 }; |
| 141 | 143 |
| 142 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ | 144 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ |
| OLD | NEW |