OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "webkit/tools/test_shell/simple_file_system.h" | 5 #include "webkit/tools/test_shell/simple_file_system.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/memory/scoped_callback_factory.h" | 8 #include "base/memory/scoped_callback_factory.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 web_entries_vector; | 96 web_entries_vector; |
97 callbacks_->didReadDirectory(web_entries, has_more); | 97 callbacks_->didReadDirectory(web_entries, has_more); |
98 } | 98 } |
99 | 99 |
100 virtual void DidOpenFileSystem( | 100 virtual void DidOpenFileSystem( |
101 const std::string& name, const GURL& root) { | 101 const std::string& name, const GURL& root) { |
102 DCHECK(file_system_); | 102 DCHECK(file_system_); |
103 if (!root.is_valid()) | 103 if (!root.is_valid()) |
104 callbacks_->didFail(WebKit::WebFileErrorSecurity); | 104 callbacks_->didFail(WebKit::WebFileErrorSecurity); |
105 else | 105 else |
106 // Temporary hack to ease a 4-phase Chromium/WebKit commit. | |
107 #ifdef WEBFILESYSTEMCALLBACKS_USE_URL_NOT_STRING | |
108 callbacks_->didOpenFileSystem(WebString::fromUTF8(name), root); | 106 callbacks_->didOpenFileSystem(WebString::fromUTF8(name), root); |
109 #else | |
110 callbacks_->didOpenFileSystem( | |
111 WebString::fromUTF8(name), WebString::fromUTF8(root.spec())); | |
112 #endif | |
113 } | 107 } |
114 | 108 |
115 virtual void DidFail(base::PlatformFileError error_code) { | 109 virtual void DidFail(base::PlatformFileError error_code) { |
116 DCHECK(file_system_); | 110 DCHECK(file_system_); |
117 callbacks_->didFail( | 111 callbacks_->didFail( |
118 webkit_glue::PlatformFileErrorToWebFileError(error_code)); | 112 webkit_glue::PlatformFileErrorToWebFileError(error_code)); |
119 } | 113 } |
120 | 114 |
121 virtual void DidWrite(int64, bool) { | 115 virtual void DidWrite(int64, bool) { |
122 NOTREACHED(); | 116 NOTREACHED(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 else { | 164 else { |
171 // Unknown type filesystem is requested. | 165 // Unknown type filesystem is requested. |
172 callbacks->didFail(WebKit::WebFileErrorSecurity); | 166 callbacks->didFail(WebKit::WebFileErrorSecurity); |
173 return; | 167 return; |
174 } | 168 } |
175 | 169 |
176 GURL origin_url(frame->document().securityOrigin().toString()); | 170 GURL origin_url(frame->document().securityOrigin().toString()); |
177 GetNewOperation(callbacks)->OpenFileSystem(origin_url, type, create); | 171 GetNewOperation(callbacks)->OpenFileSystem(origin_url, type, create); |
178 } | 172 } |
179 | 173 |
180 void SimpleFileSystem::move(const WebString& src_path, | |
181 const WebString& dest_path, | |
182 WebFileSystemCallbacks* callbacks) { | |
183 move(GURL(src_path), GURL(dest_path), callbacks); | |
184 } | |
185 | |
186 void SimpleFileSystem::copy(const WebString& src_path, | |
187 const WebString& dest_path, | |
188 WebFileSystemCallbacks* callbacks) { | |
189 copy(GURL(src_path), GURL(dest_path), callbacks); | |
190 } | |
191 | |
192 void SimpleFileSystem::remove(const WebString& path, | |
193 WebFileSystemCallbacks* callbacks) { | |
194 remove(GURL(path), callbacks); | |
195 } | |
196 | |
197 void SimpleFileSystem::removeRecursively(const WebString& path, | |
198 WebFileSystemCallbacks* callbacks) { | |
199 removeRecursively(GURL(path), callbacks); | |
200 } | |
201 | |
202 void SimpleFileSystem::readMetadata(const WebString& path, | |
203 WebFileSystemCallbacks* callbacks) { | |
204 readMetadata(GURL(path), callbacks); | |
205 } | |
206 | |
207 void SimpleFileSystem::createFile(const WebString& path, | |
208 bool exclusive, | |
209 WebFileSystemCallbacks* callbacks) { | |
210 createFile(GURL(path), exclusive, callbacks); | |
211 } | |
212 | |
213 void SimpleFileSystem::createDirectory(const WebString& path, | |
214 bool exclusive, | |
215 WebFileSystemCallbacks* callbacks) { | |
216 createDirectory(GURL(path), exclusive, callbacks); | |
217 } | |
218 | |
219 void SimpleFileSystem::fileExists(const WebString& path, | |
220 WebFileSystemCallbacks* callbacks) { | |
221 fileExists(GURL(path), callbacks); | |
222 } | |
223 | |
224 void SimpleFileSystem::directoryExists(const WebString& path, | |
225 WebFileSystemCallbacks* callbacks) { | |
226 directoryExists(GURL(path), callbacks); | |
227 } | |
228 | |
229 void SimpleFileSystem::readDirectory(const WebString& path, | |
230 WebFileSystemCallbacks* callbacks) { | |
231 readDirectory(GURL(path), callbacks); | |
232 } | |
233 | |
234 WebKit::WebFileWriter* SimpleFileSystem::createFileWriter( | |
235 const WebString& path, WebKit::WebFileWriterClient* client) { | |
236 return createFileWriter(GURL(path), client); | |
237 } | |
238 | |
239 void SimpleFileSystem::move( | 174 void SimpleFileSystem::move( |
240 const WebURL& src_path, | 175 const WebURL& src_path, |
241 const WebURL& dest_path, WebFileSystemCallbacks* callbacks) { | 176 const WebURL& dest_path, WebFileSystemCallbacks* callbacks) { |
242 GetNewOperation(callbacks)->Move(GURL(src_path), GURL(dest_path)); | 177 GetNewOperation(callbacks)->Move(GURL(src_path), GURL(dest_path)); |
243 } | 178 } |
244 | 179 |
245 void SimpleFileSystem::copy( | 180 void SimpleFileSystem::copy( |
246 const WebURL& src_path, const WebURL& dest_path, | 181 const WebURL& src_path, const WebURL& dest_path, |
247 WebFileSystemCallbacks* callbacks) { | 182 WebFileSystemCallbacks* callbacks) { |
248 GetNewOperation(callbacks)->Copy(GURL(src_path), GURL(dest_path)); | 183 GetNewOperation(callbacks)->Copy(GURL(src_path), GURL(dest_path)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 230 |
296 FileSystemOperation* SimpleFileSystem::GetNewOperation( | 231 FileSystemOperation* SimpleFileSystem::GetNewOperation( |
297 WebFileSystemCallbacks* callbacks) { | 232 WebFileSystemCallbacks* callbacks) { |
298 SimpleFileSystemCallbackDispatcher* dispatcher = | 233 SimpleFileSystemCallbackDispatcher* dispatcher = |
299 new SimpleFileSystemCallbackDispatcher(AsWeakPtr(), callbacks); | 234 new SimpleFileSystemCallbackDispatcher(AsWeakPtr(), callbacks); |
300 FileSystemOperation* operation = new FileSystemOperation( | 235 FileSystemOperation* operation = new FileSystemOperation( |
301 dispatcher, base::MessageLoopProxy::current(), | 236 dispatcher, base::MessageLoopProxy::current(), |
302 file_system_context_.get(), NULL); | 237 file_system_context_.get(), NULL); |
303 return operation; | 238 return operation; |
304 } | 239 } |
OLD | NEW |