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 function MockEventSource() { | 5 function MockEventSource() { |
6 this.listeners_ = []; | 6 this.listeners_ = []; |
7 } | 7 } |
8 | 8 |
9 /** | 9 /** |
10 * Add a listener. There is no remove. | 10 * Add a listener. There is no remove. |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 return match && match[1]; | 219 return match && match[1]; |
220 }, | 220 }, |
221 | 221 |
222 archiveCount_: 0, | 222 archiveCount_: 0, |
223 | 223 |
224 getMountPoints: function(callback) { | 224 getMountPoints: function(callback) { |
225 callback([].concat(chrome.fileBrowserPrivate.mountPoints_)); | 225 callback([].concat(chrome.fileBrowserPrivate.mountPoints_)); |
226 }, | 226 }, |
227 | 227 |
228 | 228 |
229 addMount: function(source, type, options) { | 229 addMount: function(source, type, options, callback) { |
230 chrome.fileBrowserPrivate.requestLocalFileSystem(function(filesystem) { | 230 chrome.fileBrowserPrivate.requestLocalFileSystem(function(filesystem) { |
231 var path = | 231 var path = |
232 (type == 'gdata') ? | 232 (type == 'gdata') ? |
233 '/gdata' : | 233 '/gdata' : |
234 ('/archive/archive' + (++chrome.fileBrowserPrivate.archiveCount_)); | 234 ('/archive/archive' + (++chrome.fileBrowserPrivate.archiveCount_)); |
| 235 callback(source); |
235 util.getOrCreateDirectory(filesystem.root, path, function() { | 236 util.getOrCreateDirectory(filesystem.root, path, function() { |
236 chrome.fileBrowserPrivate.mountPoints_.push({ | 237 chrome.fileBrowserPrivate.mountPoints_.push({ |
237 mountPath: path, | 238 mountPath: path, |
238 type: type | 239 type: type |
239 }); | 240 }); |
240 chrome.fileBrowserPrivate.onMountCompleted.notify({ | 241 chrome.fileBrowserPrivate.onMountCompleted.notify({ |
241 eventType: 'mount', | 242 eventType: 'mount', |
242 status: 'success', | 243 status: 'success', |
243 mountType: type, | 244 mountType: type, |
244 authToken: 'dummy', | 245 authToken: 'dummy', |
245 mountPath: path, | 246 mountPath: path, |
246 sourceUrl: source | 247 sourcePath: source |
247 }); | 248 }); |
248 console.log('Created a mock mount at ' + path); | 249 console.log('Created a mock mount at ' + path); |
249 }, | 250 }, |
250 util.flog('Error creating a mock mount at ' + path)); | 251 util.flog('Error creating a mock mount at ' + path)); |
251 }); | 252 }); |
252 }, | 253 }, |
253 | 254 |
254 removeMount: function(sourceUrl) { | 255 removeMount: function(sourceUrl) { |
255 var mountPath = chrome.fileBrowserPrivate.fileUrlToLocalPath_(sourceUrl); | 256 var mountPath = chrome.fileBrowserPrivate.fileUrlToLocalPath_(sourceUrl); |
256 for (var i = 0; i != chrome.fileBrowserPrivate.mountPoints_.length; i++) { | 257 for (var i = 0; i != chrome.fileBrowserPrivate.mountPoints_.length; i++) { |
257 if (mountPath == chrome.fileBrowserPrivate.mountPoints_[i].mountPath) { | 258 if (mountPath == chrome.fileBrowserPrivate.mountPoints_[i].mountPath) { |
258 chrome.fileBrowserPrivate.mountPoints_.splice(i, 1); | 259 chrome.fileBrowserPrivate.mountPoints_.splice(i, 1); |
259 break; | 260 break; |
260 } | 261 } |
261 } | 262 } |
262 function notify(status) { | 263 function notify(status) { |
263 chrome.fileBrowserPrivate.onMountCompleted.notify({ | 264 chrome.fileBrowserPrivate.onMountCompleted.notify({ |
264 eventType: 'unmount', | 265 eventType: 'unmount', |
265 status: status, | 266 status: status, |
266 mountPath: mountPath, | 267 mountPath: mountPath, |
267 sourceUrl: sourceUrl | 268 sourcePath: sourcePath |
268 }); | 269 }); |
269 } | 270 } |
270 | 271 |
271 webkitResolveLocalFileSystemURL(sourceUrl, function(entry) { | 272 webkitResolveLocalFileSystemURL(sourceUrl, function(entry) { |
272 util.removeFileOrDirectory( | 273 util.removeFileOrDirectory( |
273 entry, | 274 entry, |
274 util.flog('Deleted a mock mount at ' + entry.fullPath, | 275 util.flog('Deleted a mock mount at ' + entry.fullPath, |
275 notify.bind(null, 'success'), | 276 notify.bind(null, 'success'), |
276 util.flog('Error deleting a mock mount at' + entry.fullPath, | 277 util.flog('Error deleting a mock mount at' + entry.fullPath, |
277 notify))); | 278 notify))); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 | 663 |
663 setWindowHeight: function(height) { | 664 setWindowHeight: function(height) { |
664 this.popup_.style.height = height + 'px'; | 665 this.popup_.style.height = height + 'px'; |
665 }, | 666 }, |
666 | 667 |
667 closeWindow: function() { | 668 closeWindow: function() { |
668 this.popup_.parentNode.removeChild(this.popup_); | 669 this.popup_.parentNode.removeChild(this.popup_); |
669 this.popup_ = null; | 670 this.popup_ = null; |
670 } | 671 } |
671 }; | 672 }; |
OLD | NEW |