OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // Generated from namespace: fileSystem | |
6 | |
7 part of chrome; | |
8 | |
9 /** | |
10 * Types | |
11 */ | |
12 | |
13 class FilesystemAcceptOption extends ChromeObject { | |
14 /* | |
15 * Public constructor | |
16 */ | |
17 FilesystemAcceptOption({String description, List<String> mimeTypes, List<Strin
g> extensions}) { | |
18 if (description != null) | |
19 this.description = description; | |
20 if (mimeTypes != null) | |
21 this.mimeTypes = mimeTypes; | |
22 if (extensions != null) | |
23 this.extensions = extensions; | |
24 } | |
25 | |
26 /* | |
27 * Private constructor | |
28 */ | |
29 FilesystemAcceptOption._proxy(_jsObject) : super._proxy(_jsObject); | |
30 | |
31 /* | |
32 * Public accessors | |
33 */ | |
34 /// This is the optional text description for this option. If not present, a | |
35 /// description will be automatically generated; typically containing an | |
36 /// expanded list of valid extensions (e.g. "text/html" may expand to "*.html, | |
37 /// *.htm"). | |
38 String get description => JS('String', '#.description', this._jsObject); | |
39 | |
40 void set description(String description) { | |
41 JS('void', '#.description = #', this._jsObject, description); | |
42 } | |
43 | |
44 /// Mime-types to accept, e.g. "image/jpeg" or "audio/*". One of mimeTypes or | |
45 /// extensions must contain at least one valid element. | |
46 List<String> get mimeTypes => JS('List<String>', '#.mimeTypes', this._jsObject
); | |
47 | |
48 void set mimeTypes(List<String> mimeTypes) { | |
49 JS('void', '#.mimeTypes = #', this._jsObject, mimeTypes); | |
50 } | |
51 | |
52 /// Extensions to accept, e.g. "jpg", "gif", "crx". | |
53 List<String> get extensions => JS('List<String>', '#.extensions', this._jsObje
ct); | |
54 | |
55 void set extensions(List<String> extensions) { | |
56 JS('void', '#.extensions = #', this._jsObject, extensions); | |
57 } | |
58 | |
59 } | |
60 | |
61 class FilesystemChooseEntryOptions extends ChromeObject { | |
62 /* | |
63 * Public constructor | |
64 */ | |
65 FilesystemChooseEntryOptions({String type, String suggestedName, List<Filesyst
emAcceptOption> accepts, bool acceptsAllTypes}) { | |
66 if (type != null) | |
67 this.type = type; | |
68 if (suggestedName != null) | |
69 this.suggestedName = suggestedName; | |
70 if (accepts != null) | |
71 this.accepts = accepts; | |
72 if (acceptsAllTypes != null) | |
73 this.acceptsAllTypes = acceptsAllTypes; | |
74 } | |
75 | |
76 /* | |
77 * Private constructor | |
78 */ | |
79 FilesystemChooseEntryOptions._proxy(_jsObject) : super._proxy(_jsObject); | |
80 | |
81 /* | |
82 * Public accessors | |
83 */ | |
84 /// Type of the prompt to show. The default is 'openFile'. | |
85 String get type => JS('String', '#.type', this._jsObject); | |
86 | |
87 void set type(String type) { | |
88 JS('void', '#.type = #', this._jsObject, type); | |
89 } | |
90 | |
91 /// The suggested file name that will be presented to the user as the default | |
92 /// name to read or write. This is optional. | |
93 String get suggestedName => JS('String', '#.suggestedName', this._jsObject); | |
94 | |
95 void set suggestedName(String suggestedName) { | |
96 JS('void', '#.suggestedName = #', this._jsObject, suggestedName); | |
97 } | |
98 | |
99 /// The optional list of accept options for this file opener. Each option will | |
100 /// be presented as a unique group to the end-user. | |
101 List<FilesystemAcceptOption> get accepts { | |
102 List<FilesystemAcceptOption> __proxy_accepts = new List<FilesystemAcceptOpti
on>(); | |
103 int count = JS('int', '#.accepts.length', this._jsObject); | |
104 for (int i = 0; i < count; i++) { | |
105 var item = JS('', '#.accepts[#]', this._jsObject, i); | |
106 __proxy_accepts.add(new FilesystemAcceptOption._proxy(item)); | |
107 } | |
108 return __proxy_accepts; | |
109 } | |
110 | |
111 void set accepts(List<FilesystemAcceptOption> accepts) { | |
112 JS('void', '#.accepts = #', this._jsObject, convertArgument(accepts)); | |
113 } | |
114 | |
115 /// Whether to accept all file types, in addition to the options specified in | |
116 /// the accepts argument. The default is true. If the accepts field is unset o
r | |
117 /// contains no valid entries, this will always be reset to true. | |
118 bool get acceptsAllTypes => JS('bool', '#.acceptsAllTypes', this._jsObject); | |
119 | |
120 void set acceptsAllTypes(bool acceptsAllTypes) { | |
121 JS('void', '#.acceptsAllTypes = #', this._jsObject, acceptsAllTypes); | |
122 } | |
123 | |
124 } | |
125 | |
126 /** | |
127 * Functions | |
128 */ | |
129 | |
130 class API_file_system { | |
131 /* | |
132 * API connection | |
133 */ | |
134 Object _jsObject; | |
135 | |
136 /* | |
137 * Functions | |
138 */ | |
139 /// Get the display path of a FileEntry object. The display path is based on | |
140 /// the full path of the file on the local file system, but may be made more | |
141 /// readable for display purposes. | |
142 void getDisplayPath(FileEntry fileEntry, void callback(String displayPath)) =>
JS('void', '#.getDisplayPath(#, #)', this._jsObject, convertArgument(fileEntry)
, convertDartClosureToJS(callback, 1)); | |
143 | |
144 /// Get a writable FileEntry from another FileEntry. This call will fail if th
e | |
145 /// application does not have the 'write' permission under 'fileSystem'. | |
146 void getWritableEntry(FileEntry fileEntry, void callback(FileEntry fileEntry))
{ | |
147 void __proxy_callback(fileEntry) { | |
148 if (callback != null) { | |
149 callback(fileEntry); | |
150 } | |
151 } | |
152 JS('void', '#.getWritableEntry(#, #)', this._jsObject, convertArgument(fileE
ntry), convertDartClosureToJS(__proxy_callback, 1)); | |
153 } | |
154 | |
155 /// Gets whether this FileEntry is writable or not. | |
156 void isWritableEntry(FileEntry fileEntry, void callback(bool isWritable)) => J
S('void', '#.isWritableEntry(#, #)', this._jsObject, convertArgument(fileEntry),
convertDartClosureToJS(callback, 1)); | |
157 | |
158 /// Ask the user to choose a file. | |
159 void chooseEntry(void callback(FileEntry fileEntry), [FilesystemChooseEntryOpt
ions options]) { | |
160 void __proxy_callback(fileEntry) { | |
161 if (callback != null) { | |
162 callback(fileEntry); | |
163 } | |
164 } | |
165 JS('void', '#.chooseEntry(#, #)', this._jsObject, convertArgument(options),
convertDartClosureToJS(__proxy_callback, 1)); | |
166 } | |
167 | |
168 /// Returns the file entry with the given id if it can be restored. This call | |
169 /// will fail otherwise. | |
170 void restoreEntry(String id, void callback(FileEntry fileEntry)) { | |
171 void __proxy_callback(fileEntry) { | |
172 if (callback != null) { | |
173 callback(fileEntry); | |
174 } | |
175 } | |
176 JS('void', '#.restoreEntry(#, #)', this._jsObject, id, convertDartClosureToJ
S(__proxy_callback, 1)); | |
177 } | |
178 | |
179 /// Returns whether a file entry for the given id can be restored, i.e. whethe
r | |
180 /// restoreEntry would succeed with this id now. | |
181 void isRestorable(String id, void callback(bool isRestorable)) => JS('void', '
#.isRestorable(#, #)', this._jsObject, id, convertDartClosureToJS(callback, 1)); | |
182 | |
183 /// Returns an id that can be passed to restoreEntry to regain access to a | |
184 /// given file entry. Only the 500 most recently used entries are retained, | |
185 /// where calls to retainEntry and restoreEntry count as use. If the app has | |
186 /// the 'retainEntries' permission under 'fileSystem', entries are retained | |
187 /// indefinitely. Otherwise, entries are retained only while the app is runnin
g | |
188 /// and across restarts. | |
189 String retainEntry(FileEntry fileEntry) => JS('String', '#.retainEntry(#)', th
is._jsObject, convertArgument(fileEntry)); | |
190 | |
191 API_file_system(this._jsObject) { | |
192 } | |
193 } | |
OLD | NEW |