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 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "content/public/browser/browser_thread.h" | |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
19 #include "content/public/common/file_chooser_params.h" | 20 #include "content/public/common/file_chooser_params.h" |
20 #include "net/base/directory_lister.h" | 21 #include "net/base/directory_lister.h" |
21 #include "ui/shell_dialogs/select_file_dialog.h" | 22 #include "ui/shell_dialogs/select_file_dialog.h" |
22 | 23 |
23 #if defined(FULL_SAFE_BROWSING) | 24 #if defined(FULL_SAFE_BROWSING) |
24 #include "chrome/browser/safe_browsing/unverified_download_policy.h" | 25 #include "chrome/browser/safe_browsing/unverified_download_policy.h" |
25 #endif | 26 #endif |
26 | 27 |
27 class Profile; | 28 class Profile; |
28 | 29 |
29 namespace content { | 30 namespace content { |
30 struct FileChooserFileInfo; | 31 struct FileChooserFileInfo; |
31 class RenderViewHost; | 32 class RenderViewHost; |
32 class WebContents; | 33 class WebContents; |
33 } | 34 } |
34 | 35 |
35 namespace ui { | 36 namespace ui { |
36 struct SelectedFileInfo; | 37 struct SelectedFileInfo; |
37 } | 38 } |
38 | 39 |
39 // This class handles file-selection requests coming from WebUI elements | 40 // This class handles file-selection requests coming from WebUI elements |
40 // (via the extensions::ExtensionHost class). It implements both the | 41 // (via the extensions::ExtensionHost class). It implements both the |
41 // initialisation and listener functions for file-selection dialogs. | 42 // initialisation and listener functions for file-selection dialogs. |
42 class FileSelectHelper : public base::RefCountedThreadSafe<FileSelectHelper>, | 43 class FileSelectHelper : public base::RefCountedThreadSafe< |
44 FileSelectHelper, | |
45 content::BrowserThread::DeleteOnUIThread>, | |
sky
2016/01/21 18:06:27
Please add a comment as to why this needs to be de
| |
43 public ui::SelectFileDialog::Listener, | 46 public ui::SelectFileDialog::Listener, |
44 public content::WebContentsObserver, | 47 public content::WebContentsObserver, |
45 public content::NotificationObserver { | 48 public content::NotificationObserver { |
46 public: | 49 public: |
47 | |
48 // Show the file chooser dialog. | 50 // Show the file chooser dialog. |
49 static void RunFileChooser(content::WebContents* tab, | 51 static void RunFileChooser(content::WebContents* tab, |
50 const content::FileChooserParams& params); | 52 const content::FileChooserParams& params); |
51 | 53 |
52 // Enumerates all the files in directory. | 54 // Enumerates all the files in directory. |
53 static void EnumerateDirectory(content::WebContents* tab, | 55 static void EnumerateDirectory(content::WebContents* tab, |
54 int request_id, | 56 int request_id, |
55 const base::FilePath& path); | 57 const base::FilePath& path); |
56 | 58 |
57 private: | 59 private: |
58 friend class base::RefCountedThreadSafe<FileSelectHelper>; | 60 friend class base::RefCountedThreadSafe<FileSelectHelper>; |
61 friend class base::DeleteHelper<FileSelectHelper>; | |
62 friend struct content::BrowserThread::DeleteOnThread< | |
63 content::BrowserThread::UI>; | |
64 | |
59 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, IsAcceptTypeValid); | 65 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, IsAcceptTypeValid); |
60 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, ZipPackage); | 66 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, ZipPackage); |
61 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, GetSanitizedFileName); | 67 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, GetSanitizedFileName); |
62 explicit FileSelectHelper(Profile* profile); | 68 explicit FileSelectHelper(Profile* profile); |
63 ~FileSelectHelper() override; | 69 ~FileSelectHelper() override; |
64 | 70 |
65 // Utility class which can listen for directory lister events and relay | 71 // Utility class which can listen for directory lister events and relay |
66 // them to the main object with the correct tracking id. | 72 // them to the main object with the correct tracking id. |
67 class DirectoryListerDispatchDelegate | 73 class DirectoryListerDispatchDelegate |
68 : public net::DirectoryLister::DirectoryListerDelegate { | 74 : public net::DirectoryLister::DirectoryListerDelegate { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 content::NotificationRegistrar notification_registrar_; | 242 content::NotificationRegistrar notification_registrar_; |
237 | 243 |
238 // Temporary files only used on OSX. This class is responsible for deleting | 244 // Temporary files only used on OSX. This class is responsible for deleting |
239 // these files when they are no longer needed. | 245 // these files when they are no longer needed. |
240 std::vector<base::FilePath> temporary_files_; | 246 std::vector<base::FilePath> temporary_files_; |
241 | 247 |
242 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); | 248 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); |
243 }; | 249 }; |
244 | 250 |
245 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ | 251 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ |
OLD | NEW |