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

Side by Side Diff: chrome/browser/resources/file_manager/js/mock_chrome.js

Issue 10231010: gdata: Apply correct mount label when mounting archives in GData (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years, 7 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 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
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 setTimeout(function() { 241 setTimeout(function() {
241 chrome.fileBrowserPrivate.onMountCompleted.notify({ 242 chrome.fileBrowserPrivate.onMountCompleted.notify({
242 eventType: 'mount', 243 eventType: 'mount',
243 status: 'success', 244 status: 'success',
244 mountType: type, 245 mountType: type,
245 authToken: 'dummy', 246 authToken: 'dummy',
246 mountPath: path, 247 mountPath: path,
247 sourceUrl: source 248 sourcePath: source
248 }); 249 });
249 }, 1000); 250 }, 1000);
250 console.log('Created a mock mount at ' + path); 251 console.log('Created a mock mount at ' + path);
251 }, 252 },
252 util.flog('Error creating a mock mount at ' + path)); 253 util.flog('Error creating a mock mount at ' + path));
253 }); 254 });
254 }, 255 },
255 256
256 removeMount: function(sourceUrl) { 257 removeMount: function(sourceUrl) {
257 var mountPath = chrome.fileBrowserPrivate.fileUrlToLocalPath_(sourceUrl); 258 var mountPath = chrome.fileBrowserPrivate.fileUrlToLocalPath_(sourceUrl);
258 for (var i = 0; i != chrome.fileBrowserPrivate.mountPoints_.length; i++) { 259 for (var i = 0; i != chrome.fileBrowserPrivate.mountPoints_.length; i++) {
259 if (mountPath == chrome.fileBrowserPrivate.mountPoints_[i].mountPath) { 260 if (mountPath == chrome.fileBrowserPrivate.mountPoints_[i].mountPath) {
260 chrome.fileBrowserPrivate.mountPoints_.splice(i, 1); 261 chrome.fileBrowserPrivate.mountPoints_.splice(i, 1);
261 break; 262 break;
262 } 263 }
263 } 264 }
264 function notify(status) { 265 function notify(status) {
265 chrome.fileBrowserPrivate.onMountCompleted.notify({ 266 chrome.fileBrowserPrivate.onMountCompleted.notify({
266 eventType: 'unmount', 267 eventType: 'unmount',
267 status: status, 268 status: status,
268 mountPath: mountPath, 269 mountPath: mountPath,
269 sourceUrl: sourceUrl 270 sourcePath: sourcePath
270 }); 271 });
271 } 272 }
272 273
273 webkitResolveLocalFileSystemURL(sourceUrl, function(entry) { 274 webkitResolveLocalFileSystemURL(sourceUrl, function(entry) {
274 util.removeFileOrDirectory( 275 util.removeFileOrDirectory(
275 entry, 276 entry,
276 util.flog('Deleted a mock mount at ' + entry.fullPath, 277 util.flog('Deleted a mock mount at ' + entry.fullPath,
277 notify.bind(null, 'success'), 278 notify.bind(null, 'success'),
278 util.flog('Error deleting a mock mount at' + entry.fullPath, 279 util.flog('Error deleting a mock mount at' + entry.fullPath,
279 notify))); 280 notify)));
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 665
665 setWindowHeight: function(height) { 666 setWindowHeight: function(height) {
666 this.popup_.style.height = height + 'px'; 667 this.popup_.style.height = height + 'px';
667 }, 668 },
668 669
669 closeWindow: function() { 670 closeWindow: function() {
670 this.popup_.parentNode.removeChild(this.popup_); 671 this.popup_.parentNode.removeChild(this.popup_);
671 this.popup_ = null; 672 this.popup_ = null;
672 } 673 }
673 }; 674 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/js/file_manager.js ('k') | chrome/common/extensions/api/fileBrowserPrivate.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698