Chromium Code Reviews| 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 "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/common/file_chooser_params.h" | 15 #include "content/public/common/file_chooser_params.h" |
| 16 #include "net/base/directory_lister.h" | 16 #include "net/base/directory_lister.h" |
| 17 #include "ui/shell_dialogs/select_file_dialog.h" | 17 #include "ui/shell_dialogs/select_file_dialog.h" |
| 18 | 18 |
| 19 class Profile; | 19 class Profile; |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 struct FileChooserFileInfo; | |
| 22 class RenderViewHost; | 23 class RenderViewHost; |
| 23 class WebContents; | 24 class WebContents; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace ui { | 27 namespace ui { |
| 27 struct SelectedFileInfo; | 28 struct SelectedFileInfo; |
| 28 } | 29 } |
| 29 | 30 |
| 30 // This class handles file-selection requests coming from WebUI elements | 31 // This class handles file-selection requests coming from WebUI elements |
| 31 // (via the extensions::ExtensionHost class). It implements both the | 32 // (via the extensions::ExtensionHost class). It implements both the |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 void ProcessSelectedFilesMacOnUIThread( | 134 void ProcessSelectedFilesMacOnUIThread( |
| 134 const std::vector<ui::SelectedFileInfo>& files, | 135 const std::vector<ui::SelectedFileInfo>& files, |
| 135 const std::vector<base::FilePath>& zipped_files); | 136 const std::vector<base::FilePath>& zipped_files); |
| 136 | 137 |
| 137 // Zips the package at |path| into a temporary destination. Returns the | 138 // Zips the package at |path| into a temporary destination. Returns the |
| 138 // temporary destination, if the zip was successful. Otherwise returns an | 139 // temporary destination, if the zip was successful. Otherwise returns an |
| 139 // empty path. | 140 // empty path. |
| 140 static base::FilePath ZipPackage(const base::FilePath& path); | 141 static base::FilePath ZipPackage(const base::FilePath& path); |
| 141 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 142 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 142 | 143 |
| 144 #if defined(OS_CHROMEOS) | |
| 145 // Converts |files| into FileChooserFileInfo with handling non-native files. | |
|
Avi (use Gerrit)
2014/10/16 15:21:20
... with handling of non-native files.
hirono
2014/10/17 11:42:10
Done.
| |
| 146 void ProcessSelectedFilesChromeOS( | |
| 147 const std::vector<ui::SelectedFileInfo>& files); | |
| 148 | |
| 149 // Passes the result to |NotifyRenderViewHostAndEnd|. | |
| 150 void ProcessSelectedFilesChromeOSAfterConvresion( | |
|
Avi (use Gerrit)
2014/10/16 15:21:20
...AfterConversion
hirono
2014/10/17 11:42:10
Done.
| |
| 151 scoped_ptr<std::vector<content::FileChooserFileInfo>> list); | |
| 152 #endif // defined(OS_CHROMEOS) | |
| 153 | |
| 154 void ProcessSelectedFiles(const std::vector<ui::SelectedFileInfo>& files); | |
|
Avi (use Gerrit)
2014/10/16 15:21:20
Is ProcessSelectedFiles mutually exclusive with Pr
hirono
2014/10/17 11:42:10
I combined the two function. Added a comment.
| |
| 155 | |
| 143 // Utility method that passes |files| to the render view host, and ends the | 156 // Utility method that passes |files| to the render view host, and ends the |
| 144 // file chooser. | 157 // file chooser. |
|
Avi (use Gerrit)
2014/10/16 15:21:20
Is this no longer supposed to be called? It seems
hirono
2014/10/17 11:42:10
Done.
| |
| 145 void NotifyRenderViewHostAndEnd( | 158 void NotifyRenderViewHostAndEnd( |
| 146 const std::vector<ui::SelectedFileInfo>& files); | 159 const std::vector<content::FileChooserFileInfo>& files); |
| 147 | 160 |
| 148 // Schedules the deletion of the files in |temporary_files_| and clears the | 161 // Schedules the deletion of the files in |temporary_files_| and clears the |
| 149 // vector. | 162 // vector. |
| 150 void DeleteTemporaryFiles(); | 163 void DeleteTemporaryFiles(); |
| 151 | 164 |
| 152 // Helper method to get allowed extensions for select file dialog from | 165 // Helper method to get allowed extensions for select file dialog from |
| 153 // the specified accept types as defined in the spec: | 166 // the specified accept types as defined in the spec: |
| 154 // http://whatwg.org/html/number-state.html#attr-input-accept | 167 // http://whatwg.org/html/number-state.html#attr-input-accept |
| 155 // |accept_types| contains only valid lowercased MIME types or file extensions | 168 // |accept_types| contains only valid lowercased MIME types or file extensions |
| 156 // beginning with a period (.). | 169 // beginning with a period (.). |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 content::NotificationRegistrar notification_registrar_; | 203 content::NotificationRegistrar notification_registrar_; |
| 191 | 204 |
| 192 // Temporary files only used on OSX. This class is responsible for deleting | 205 // Temporary files only used on OSX. This class is responsible for deleting |
| 193 // these files when they are no longer needed. | 206 // these files when they are no longer needed. |
| 194 std::vector<base::FilePath> temporary_files_; | 207 std::vector<base::FilePath> temporary_files_; |
| 195 | 208 |
| 196 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); | 209 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); |
| 197 }; | 210 }; |
| 198 | 211 |
| 199 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ | 212 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ |
| OLD | NEW |