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_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 "chrome/browser/extensions/extension_function.h" | 8 #include "chrome/browser/extensions/extension_function.h" |
| 9 #include "chrome/common/extensions/api/file_system.h" |
9 #include "ui/base/dialogs/select_file_dialog.h" | 10 #include "ui/base/dialogs/select_file_dialog.h" |
10 | 11 |
11 namespace extensions { | 12 namespace extensions { |
12 | 13 |
13 class FileSystemGetDisplayPathFunction : public SyncExtensionFunction { | 14 class FileSystemGetDisplayPathFunction : public SyncExtensionFunction { |
14 public: | 15 public: |
15 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.getDisplayPath"); | 16 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.getDisplayPath"); |
16 | 17 |
17 protected: | 18 protected: |
18 virtual ~FileSystemGetDisplayPathFunction() {} | 19 virtual ~FileSystemGetDisplayPathFunction() {} |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 66 |
66 class FileSystemChooseFileFunction : public FileSystemEntryFunction { | 67 class FileSystemChooseFileFunction : public FileSystemEntryFunction { |
67 public: | 68 public: |
68 // Allow picker UI to be skipped in testing. | 69 // Allow picker UI to be skipped in testing. |
69 static void SkipPickerAndAlwaysSelectPathForTest(FilePath* path); | 70 static void SkipPickerAndAlwaysSelectPathForTest(FilePath* path); |
70 static void SkipPickerAndAlwaysCancelForTest(); | 71 static void SkipPickerAndAlwaysCancelForTest(); |
71 static void StopSkippingPickerForTest(); | 72 static void StopSkippingPickerForTest(); |
72 | 73 |
73 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.chooseFile"); | 74 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.chooseFile"); |
74 | 75 |
| 76 typedef std::vector<linked_ptr<extensions::api::file_system::AcceptOption> > |
| 77 AcceptOptions; |
| 78 |
| 79 static void BuildFileTypeInfo( |
| 80 ui::SelectFileDialog::FileTypeInfo* file_type_info, |
| 81 const FilePath::StringType& suggested_extension, |
| 82 const AcceptOptions* accepts, |
| 83 const bool* acceptsAllTypes); |
| 84 static void BuildSuggestion(const std::string* opt_name, |
| 85 FilePath* suggested_name, |
| 86 FilePath::StringType* suggested_extension); |
| 87 |
75 protected: | 88 protected: |
76 class FilePicker; | 89 class FilePicker; |
77 | 90 |
78 virtual ~FileSystemChooseFileFunction() {} | 91 virtual ~FileSystemChooseFileFunction() {} |
79 virtual bool RunImpl() OVERRIDE; | 92 virtual bool RunImpl() OVERRIDE; |
80 bool ShowPicker(const FilePath& suggested_path, | 93 bool ShowPicker(const FilePath& suggested_path, |
| 94 const ui::SelectFileDialog::FileTypeInfo& file_type_info, |
81 ui::SelectFileDialog::Type picker_type, | 95 ui::SelectFileDialog::Type picker_type, |
82 EntryType entry_type); | 96 EntryType entry_type); |
83 | 97 |
84 private: | 98 private: |
85 // FileSelected and FileSelectionCanceled are called by the file picker. | 99 // FileSelected and FileSelectionCanceled are called by the file picker. |
86 void FileSelected(const FilePath& path, EntryType entry_type); | 100 void FileSelected(const FilePath& path, EntryType entry_type); |
87 void FileSelectionCanceled(); | 101 void FileSelectionCanceled(); |
88 }; | 102 }; |
89 | 103 |
90 } // namespace extensions | 104 } // namespace extensions |
91 | 105 |
92 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 106 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
OLD | NEW |