OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Enumerates all the files in directory. | 44 // Enumerates all the files in directory. |
45 static void EnumerateDirectory(content::WebContents* tab, | 45 static void EnumerateDirectory(content::WebContents* tab, |
46 int request_id, | 46 int request_id, |
47 const base::FilePath& path); | 47 const base::FilePath& path); |
48 | 48 |
49 private: | 49 private: |
50 friend class base::RefCountedThreadSafe<FileSelectHelper>; | 50 friend class base::RefCountedThreadSafe<FileSelectHelper>; |
51 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, IsAcceptTypeValid); | 51 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, IsAcceptTypeValid); |
52 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, ZipPackage); | 52 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, ZipPackage); |
53 explicit FileSelectHelper(Profile* profile); | 53 explicit FileSelectHelper(Profile* profile); |
54 virtual ~FileSelectHelper(); | 54 ~FileSelectHelper() override; |
55 | 55 |
56 // Utility class which can listen for directory lister events and relay | 56 // Utility class which can listen for directory lister events and relay |
57 // them to the main object with the correct tracking id. | 57 // them to the main object with the correct tracking id. |
58 class DirectoryListerDispatchDelegate | 58 class DirectoryListerDispatchDelegate |
59 : public net::DirectoryLister::DirectoryListerDelegate { | 59 : public net::DirectoryLister::DirectoryListerDelegate { |
60 public: | 60 public: |
61 DirectoryListerDispatchDelegate(FileSelectHelper* parent, int id) | 61 DirectoryListerDispatchDelegate(FileSelectHelper* parent, int id) |
62 : parent_(parent), | 62 : parent_(parent), |
63 id_(id) {} | 63 id_(id) {} |
64 virtual ~DirectoryListerDispatchDelegate() {} | 64 ~DirectoryListerDispatchDelegate() override {} |
65 virtual void OnListFile( | 65 void OnListFile( |
66 const net::DirectoryLister::DirectoryListerData& data) override; | 66 const net::DirectoryLister::DirectoryListerData& data) override; |
67 virtual void OnListDone(int error) override; | 67 void OnListDone(int error) override; |
| 68 |
68 private: | 69 private: |
69 // This FileSelectHelper owns this object. | 70 // This FileSelectHelper owns this object. |
70 FileSelectHelper* parent_; | 71 FileSelectHelper* parent_; |
71 int id_; | 72 int id_; |
72 | 73 |
73 DISALLOW_COPY_AND_ASSIGN(DirectoryListerDispatchDelegate); | 74 DISALLOW_COPY_AND_ASSIGN(DirectoryListerDispatchDelegate); |
74 }; | 75 }; |
75 | 76 |
76 void RunFileChooser(content::RenderViewHost* render_view_host, | 77 void RunFileChooser(content::RenderViewHost* render_view_host, |
77 content::WebContents* web_contents, | 78 content::WebContents* web_contents, |
78 const content::FileChooserParams& params); | 79 const content::FileChooserParams& params); |
79 void RunFileChooserOnFileThread( | 80 void RunFileChooserOnFileThread( |
80 const content::FileChooserParams& params); | 81 const content::FileChooserParams& params); |
81 void RunFileChooserOnUIThread( | 82 void RunFileChooserOnUIThread( |
82 const content::FileChooserParams& params); | 83 const content::FileChooserParams& params); |
83 | 84 |
84 // Cleans up and releases this instance. This must be called after the last | 85 // Cleans up and releases this instance. This must be called after the last |
85 // callback is received from the file chooser dialog. | 86 // callback is received from the file chooser dialog. |
86 void RunFileChooserEnd(); | 87 void RunFileChooserEnd(); |
87 | 88 |
88 // SelectFileDialog::Listener overrides. | 89 // SelectFileDialog::Listener overrides. |
89 virtual void FileSelected( | 90 void FileSelected(const base::FilePath& path, |
90 const base::FilePath& path, int index, void* params) override; | 91 int index, |
91 virtual void FileSelectedWithExtraInfo( | 92 void* params) override; |
92 const ui::SelectedFileInfo& file, | 93 void FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file, |
93 int index, | 94 int index, |
94 void* params) override; | 95 void* params) override; |
95 virtual void MultiFilesSelected(const std::vector<base::FilePath>& files, | 96 void MultiFilesSelected(const std::vector<base::FilePath>& files, |
96 void* params) override; | 97 void* params) override; |
97 virtual void MultiFilesSelectedWithExtraInfo( | 98 void MultiFilesSelectedWithExtraInfo( |
98 const std::vector<ui::SelectedFileInfo>& files, | 99 const std::vector<ui::SelectedFileInfo>& files, |
99 void* params) override; | 100 void* params) override; |
100 virtual void FileSelectionCanceled(void* params) override; | 101 void FileSelectionCanceled(void* params) override; |
101 | 102 |
102 // content::NotificationObserver overrides. | 103 // content::NotificationObserver overrides. |
103 virtual void Observe(int type, | 104 void Observe(int type, |
104 const content::NotificationSource& source, | 105 const content::NotificationSource& source, |
105 const content::NotificationDetails& details) override; | 106 const content::NotificationDetails& details) override; |
106 | 107 |
107 void EnumerateDirectory(int request_id, | 108 void EnumerateDirectory(int request_id, |
108 content::RenderViewHost* render_view_host, | 109 content::RenderViewHost* render_view_host, |
109 const base::FilePath& path); | 110 const base::FilePath& path); |
110 | 111 |
111 // Kicks off a new directory enumeration. | 112 // Kicks off a new directory enumeration. |
112 void StartNewEnumeration(const base::FilePath& path, | 113 void StartNewEnumeration(const base::FilePath& path, |
113 int request_id, | 114 int request_id, |
114 content::RenderViewHost* render_view_host); | 115 content::RenderViewHost* render_view_host); |
115 | 116 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 content::NotificationRegistrar notification_registrar_; | 197 content::NotificationRegistrar notification_registrar_; |
197 | 198 |
198 // Temporary files only used on OSX. This class is responsible for deleting | 199 // Temporary files only used on OSX. This class is responsible for deleting |
199 // these files when they are no longer needed. | 200 // these files when they are no longer needed. |
200 std::vector<base::FilePath> temporary_files_; | 201 std::vector<base::FilePath> temporary_files_; |
201 | 202 |
202 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); | 203 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); |
203 }; | 204 }; |
204 | 205 |
205 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ | 206 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ |
OLD | NEW |