Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: chrome/browser/extensions/api/file_system/file_system_api.h

Issue 2967223002: Move fileSystem API FilePicker class to own file (Closed)
Patch Set: CHECK web_contents Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/files/file.h" 12 #include "base/files/file.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/browser/extensions/chrome_extension_function.h" 18 #include "chrome/browser/extensions/chrome_extension_function.h"
19 #include "chrome/browser/extensions/chrome_extension_function_details.h" 19 #include "chrome/browser/extensions/chrome_extension_function_details.h"
20 #include "chrome/common/extensions/api/file_system.h" 20 #include "chrome/common/extensions/api/file_system.h"
21 #include "extensions/browser/extension_function.h" 21 #include "extensions/browser/extension_function.h"
22 #include "ui/shell_dialogs/select_file_dialog.h" 22 #include "ui/shell_dialogs/select_file_dialog.h"
23 23
24 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
25 #include "chrome/browser/extensions/api/file_system/consent_provider.h" 25 #include "chrome/browser/extensions/api/file_system/consent_provider.h"
26 #endif 26 #endif
27 27
28 namespace content {
29 class WebContents;
30 } // namespace content
31
28 namespace extensions { 32 namespace extensions {
29 class ExtensionPrefs; 33 class ExtensionPrefs;
30 34
31 namespace file_system_api { 35 namespace file_system_api {
32 36
33 // Methods to get and set the path of the directory containing the last file 37 // Methods to get and set the path of the directory containing the last file
34 // chosen by the user in response to a chrome.fileSystem.chooseEntry() call for 38 // chosen by the user in response to a chrome.fileSystem.chooseEntry() call for
35 // the given extension. 39 // the given extension.
36 40
37 // Returns an empty path on failure. 41 // Returns an empty path on failure.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 static void BuildFileTypeInfo( 152 static void BuildFileTypeInfo(
149 ui::SelectFileDialog::FileTypeInfo* file_type_info, 153 ui::SelectFileDialog::FileTypeInfo* file_type_info,
150 const base::FilePath::StringType& suggested_extension, 154 const base::FilePath::StringType& suggested_extension,
151 const AcceptOptions* accepts, 155 const AcceptOptions* accepts,
152 const bool* acceptsAllTypes); 156 const bool* acceptsAllTypes);
153 static void BuildSuggestion(const std::string* opt_name, 157 static void BuildSuggestion(const std::string* opt_name,
154 base::FilePath* suggested_name, 158 base::FilePath* suggested_name,
155 base::FilePath::StringType* suggested_extension); 159 base::FilePath::StringType* suggested_extension);
156 160
157 protected: 161 protected:
158 class FilePicker;
159
160 ~FileSystemChooseEntryFunction() override {} 162 ~FileSystemChooseEntryFunction() override {}
161 bool RunAsync() override; 163 bool RunAsync() override;
162 void ShowPicker(const ui::SelectFileDialog::FileTypeInfo& file_type_info, 164 void ShowPicker(const ui::SelectFileDialog::FileTypeInfo& file_type_info,
163 ui::SelectFileDialog::Type picker_type); 165 ui::SelectFileDialog::Type picker_type);
164 166
165 private: 167 private:
166 void SetInitialPathAndShowPicker( 168 void SetInitialPathAndShowPicker(
167 const base::FilePath& previous_path, 169 const base::FilePath& previous_path,
168 const base::FilePath& suggested_name, 170 const base::FilePath& suggested_name,
169 const ui::SelectFileDialog::FileTypeInfo& file_type_info, 171 const ui::SelectFileDialog::FileTypeInfo& file_type_info,
170 ui::SelectFileDialog::Type picker_type, 172 ui::SelectFileDialog::Type picker_type,
171 bool is_path_non_native_directory); 173 bool is_path_non_native_directory);
172 174
173 // FilesSelected and FileSelectionCanceled are called by the file picker. 175 // FilesSelected and FileSelectionCanceled are called by the file picker.
174 void FilesSelected(const std::vector<base::FilePath>& path); 176 void FilesSelected(const std::vector<base::FilePath>& paths);
175 void FileSelectionCanceled(); 177 void FileSelectionCanceled();
176 178
177 // Check if the chosen directory is or is an ancestor of a sensitive 179 // Check if the chosen directory is or is an ancestor of a sensitive
178 // directory. If so, show a dialog to confirm that the user wants to open the 180 // directory. If so, show a dialog to confirm that the user wants to open the
179 // directory. Calls OnDirectoryAccessConfirmed if the directory isn't 181 // directory. Calls OnDirectoryAccessConfirmed if the directory isn't
180 // sensitive or the user chooses to open it. Otherwise, calls 182 // sensitive or the user chooses to open it. Otherwise, calls
181 // FileSelectionCanceled. 183 // FileSelectionCanceled.
182 void ConfirmDirectoryAccessAsync(bool non_native_path, 184 void ConfirmDirectoryAccessAsync(bool non_native_path,
183 const std::vector<base::FilePath>& paths, 185 const std::vector<base::FilePath>& paths,
184 content::WebContents* web_contents); 186 content::WebContents* web_contents);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 ExtensionFunction::ResponseAction Run() override; 320 ExtensionFunction::ResponseAction Run() override;
319 321
320 private: 322 private:
321 ChromeExtensionFunctionDetails chrome_details_; 323 ChromeExtensionFunctionDetails chrome_details_;
322 }; 324 };
323 #endif 325 #endif
324 326
325 } // namespace extensions 327 } // namespace extensions
326 328
327 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ 329 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698