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

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

Issue 10692104: Add isWritableFileEntry to the fileSystem API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/extensions/extension_function.h" 9 #include "chrome/browser/extensions/extension_function.h"
10 #include "chrome/browser/ui/select_file_dialog.h" 10 #include "chrome/browser/ui/select_file_dialog.h"
(...skipping 11 matching lines...) Expand all
22 22
23 class FileSystemEntryFunction : public AsyncExtensionFunction { 23 class FileSystemEntryFunction : public AsyncExtensionFunction {
24 protected: 24 protected:
25 enum EntryType { 25 enum EntryType {
26 READ_ONLY, 26 READ_ONLY,
27 WRITABLE 27 WRITABLE
28 }; 28 };
29 29
30 virtual ~FileSystemEntryFunction() {} 30 virtual ~FileSystemEntryFunction() {}
31 31
32 bool HasFileSystemWritePermission();
33
34 // Called on the FILE thread. This is called when a writable file entry is 32 // Called on the FILE thread. This is called when a writable file entry is
35 // being returned. The function will ensure the file exists, creating it if 33 // being returned. The function will ensure the file exists, creating it if
36 // necessary, and also check that the file is not a link. 34 // necessary, and also check that the file is not a link.
37 void CheckWritableFile(const FilePath& path); 35 void CheckWritableFile(const FilePath& path);
38 36
39 // This will finish the choose file process. This is either called directly 37 // This will finish the choose file process. This is either called directly
40 // from FileSelected, or from CreateFileIfNecessary. It is called on the UI 38 // from FileSelected, or from CreateFileIfNecessary. It is called on the UI
41 // thread. 39 // thread.
42 void RegisterFileSystemAndSendResponse(const FilePath& path, 40 void RegisterFileSystemAndSendResponse(const FilePath& path,
43 EntryType entry_type); 41 EntryType entry_type);
44 42
45 // called on the UI thread if there is a problem checking a writable file. 43 // called on the UI thread if there is a problem checking a writable file.
46 void HandleWritableFileError(); 44 void HandleWritableFileError();
47 }; 45 };
48 46
49 class FileSystemGetWritableFileEntryFunction : public FileSystemEntryFunction { 47 class FileSystemGetWritableFileEntryFunction : public FileSystemEntryFunction {
50 public: 48 public:
51 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.getWritableFileEntry"); 49 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.getWritableFileEntry");
52 50
53 protected: 51 protected:
54 virtual ~FileSystemGetWritableFileEntryFunction() {} 52 virtual ~FileSystemGetWritableFileEntryFunction() {}
55 virtual bool RunImpl() OVERRIDE; 53 virtual bool RunImpl() OVERRIDE;
56 }; 54 };
57 55
56 class FileSystemIsWritableFileEntryFunction : public SyncExtensionFunction {
57 public:
58 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.isWritableFileEntry");
59
60 protected:
61 virtual ~FileSystemIsWritableFileEntryFunction() {}
62 virtual bool RunImpl() OVERRIDE;
63 };
64
58 class FileSystemChooseFileFunction : public FileSystemEntryFunction { 65 class FileSystemChooseFileFunction : public FileSystemEntryFunction {
59 public: 66 public:
60 // Allow picker UI to be skipped in testing. 67 // Allow picker UI to be skipped in testing.
61 static void SkipPickerAndAlwaysSelectPathForTest(FilePath* path); 68 static void SkipPickerAndAlwaysSelectPathForTest(FilePath* path);
62 static void SkipPickerAndAlwaysCancelForTest(); 69 static void SkipPickerAndAlwaysCancelForTest();
63 static void StopSkippingPickerForTest(); 70 static void StopSkippingPickerForTest();
64 71
65 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.chooseFile"); 72 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.chooseFile");
66 73
67 protected: 74 protected:
68 class FilePicker; 75 class FilePicker;
69 76
70 virtual ~FileSystemChooseFileFunction() {} 77 virtual ~FileSystemChooseFileFunction() {}
71 virtual bool RunImpl() OVERRIDE; 78 virtual bool RunImpl() OVERRIDE;
72 bool ShowPicker(const FilePath& suggested_path, 79 bool ShowPicker(const FilePath& suggested_path,
73 SelectFileDialog::Type picker_type, 80 SelectFileDialog::Type picker_type,
74 EntryType entry_type); 81 EntryType entry_type);
75 82
76 private: 83 private:
77 // FileSelected and FileSelectionCanceled are called by the file picker. 84 // FileSelected and FileSelectionCanceled are called by the file picker.
78 void FileSelected(const FilePath& path, EntryType entry_type); 85 void FileSelected(const FilePath& path, EntryType entry_type);
79 void FileSelectionCanceled(); 86 void FileSelectionCanceled();
80 }; 87 };
81 88
82 } // namespace extensions 89 } // namespace extensions
83 90
84 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ 91 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698