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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/FileSystemWorkspaceBinding.js

Issue 1363993007: DevTools: remove UISourceCode.networkURL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined Created 5 years, 2 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @param {!WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager 33 * @param {!WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager
34 * @param {!WebInspector.Workspace} workspace 34 * @param {!WebInspector.Workspace} workspace
35 * @param {!WebInspector.NetworkMapping} networkMapping
36 */ 35 */
37 WebInspector.FileSystemWorkspaceBinding = function(isolatedFileSystemManager, wo rkspace, networkMapping) 36 WebInspector.FileSystemWorkspaceBinding = function(isolatedFileSystemManager, wo rkspace)
38 { 37 {
39 this._isolatedFileSystemManager = isolatedFileSystemManager; 38 this._isolatedFileSystemManager = isolatedFileSystemManager;
40 this._workspace = workspace; 39 this._workspace = workspace;
41 // FIXME: This dependency should be removed from here once we do not need UR L to create a UISourceCode.
42 this._networkMapping = networkMapping;
43 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemAdded, this._fileSystemAdded, this); 40 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemAdded, this._fileSystemAdded, this);
44 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this); 41 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this);
45 /** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem >} */ 42 /** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem >} */
46 this._boundFileSystems = new Map(); 43 this._boundFileSystems = new Map();
47 44
48 /** @type {!Object.<number, function(!Array.<string>)>} */ 45 /** @type {!Object.<number, function(!Array.<string>)>} */
49 this._callbacks = {}; 46 this._callbacks = {};
50 /** @type {!Object.<number, !WebInspector.Progress>} */ 47 /** @type {!Object.<number, !WebInspector.Progress>} */
51 this._progresses = {}; 48 this._progresses = {};
52 49
(...skipping 17 matching lines...) Expand all
70 return "filesystem:" + fileSystemPath; 67 return "filesystem:" + fileSystemPath;
71 } 68 }
72 69
73 WebInspector.FileSystemWorkspaceBinding.prototype = { 70 WebInspector.FileSystemWorkspaceBinding.prototype = {
74 /** 71 /**
75 * @param {!WebInspector.Event} event 72 * @param {!WebInspector.Event} event
76 */ 73 */
77 _fileSystemAdded: function(event) 74 _fileSystemAdded: function(event)
78 { 75 {
79 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data); 76 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data);
80 var boundFileSystem = new WebInspector.FileSystemWorkspaceBinding.FileSy stem(this, fileSystem, this._workspace, this._networkMapping); 77 var boundFileSystem = new WebInspector.FileSystemWorkspaceBinding.FileSy stem(this, fileSystem, this._workspace);
81 this._boundFileSystems.set(fileSystem.normalizedPath(), boundFileSystem) ; 78 this._boundFileSystems.set(fileSystem.normalizedPath(), boundFileSystem) ;
82 }, 79 },
83 80
84 /** 81 /**
85 * @param {!WebInspector.Event} event 82 * @param {!WebInspector.Event} event
86 */ 83 */
87 _fileSystemRemoved: function(event) 84 _fileSystemRemoved: function(event)
88 { 85 {
89 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data); 86 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data);
90 var boundFileSystem = this._boundFileSystems.get(fileSystem.normalizedPa th()); 87 var boundFileSystem = this._boundFileSystems.get(fileSystem.normalizedPa th());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 }, 192 },
196 } 193 }
197 194
198 /** 195 /**
199 * @constructor 196 * @constructor
200 * @extends {WebInspector.Object} 197 * @extends {WebInspector.Object}
201 * @implements {WebInspector.ProjectDelegate} 198 * @implements {WebInspector.ProjectDelegate}
202 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding 199 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding
203 * @param {!WebInspector.IsolatedFileSystem} isolatedFileSystem 200 * @param {!WebInspector.IsolatedFileSystem} isolatedFileSystem
204 * @param {!WebInspector.Workspace} workspace 201 * @param {!WebInspector.Workspace} workspace
205 * @param {!WebInspector.NetworkMapping} networkMapping
206 */ 202 */
207 WebInspector.FileSystemWorkspaceBinding.FileSystem = function(fileSystemWorkspac eBinding, isolatedFileSystem, workspace, networkMapping) 203 WebInspector.FileSystemWorkspaceBinding.FileSystem = function(fileSystemWorkspac eBinding, isolatedFileSystem, workspace)
208 { 204 {
209 WebInspector.Object.call(this); 205 WebInspector.Object.call(this);
210 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; 206 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding;
211 this._fileSystem = isolatedFileSystem; 207 this._fileSystem = isolatedFileSystem;
212 this._fileSystemBaseURL = "file://" + this._fileSystem.normalizedPath() + "/ "; 208 this._fileSystemBaseURL = "file://" + this._fileSystem.normalizedPath() + "/ ";
213 this._fileSystemProjectURL = "filesystem:" + this._fileSystem.normalizedPath (); 209 this._fileSystemProjectURL = "filesystem:" + this._fileSystem.normalizedPath ();
214 this._workspace = workspace; 210 this._workspace = workspace;
215 // FIXME: This dependency should be removed from here once we do not need UR L to create a UISourceCode.
216 this._networkMapping = networkMapping;
217 211
218 this._projectId = WebInspector.FileSystemWorkspaceBinding.projectId(this._fi leSystem.path()); 212 this._projectId = WebInspector.FileSystemWorkspaceBinding.projectId(this._fi leSystem.path());
219 console.assert(!this._workspace.project(this._projectId)); 213 console.assert(!this._workspace.project(this._projectId));
220 this._workspace.addProject(this._projectId, this); 214 this._workspace.addProject(this._projectId, this);
221 this.populate(); 215 this.populate();
222 } 216 }
223 217
224 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { 218 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {
225 /** 219 /**
226 * @override 220 * @override
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 */ 310 */
317 canRename: function() 311 canRename: function()
318 { 312 {
319 return true; 313 return true;
320 }, 314 },
321 315
322 /** 316 /**
323 * @override 317 * @override
324 * @param {string} path 318 * @param {string} path
325 * @param {string} newName 319 * @param {string} newName
326 * @param {function(boolean, string=, string=, string=, !WebInspector.Resour ceType=)} callback 320 * @param {function(boolean, string=, string=, !WebInspector.ResourceType=)} callback
327 */ 321 */
328 rename: function(path, newName, callback) 322 rename: function(path, newName, callback)
329 { 323 {
330 var filePath = this._filePathForPath(path); 324 var filePath = this._filePathForPath(path);
331 this._fileSystem.renameFile(filePath, newName, innerCallback.bind(this)) ; 325 this._fileSystem.renameFile(filePath, newName, innerCallback.bind(this)) ;
332 326
333 /** 327 /**
334 * @param {boolean} success 328 * @param {boolean} success
335 * @param {string=} newName 329 * @param {string=} newName
336 * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} 330 * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem}
337 */ 331 */
338 function innerCallback(success, newName) 332 function innerCallback(success, newName)
339 { 333 {
340 if (!success) { 334 if (!success) {
341 callback(false, newName); 335 callback(false, newName);
342 return; 336 return;
343 } 337 }
344 var validNewName = /** @type {string} */ (newName); 338 var validNewName = /** @type {string} */ (newName);
345 console.assert(validNewName); 339 console.assert(validNewName);
346 var slash = filePath.lastIndexOf("/"); 340 var slash = filePath.lastIndexOf("/");
347 var parentPath = filePath.substring(0, slash); 341 var parentPath = filePath.substring(0, slash);
348 filePath = parentPath + "/" + validNewName; 342 filePath = parentPath + "/" + validNewName;
349 filePath = filePath.substr(1); 343 filePath = filePath.substr(1);
350 var newURL = this._networkMapping.urlForPath(this._fileSystem.path() , filePath);
351 var extension = this._extensionForPath(validNewName); 344 var extension = this._extensionForPath(validNewName);
352 var newOriginURL = this._fileSystemBaseURL + filePath; 345 var newOriginURL = this._fileSystemBaseURL + filePath;
353 var newContentType = this._contentTypeForExtension(extension); 346 var newContentType = this._contentTypeForExtension(extension);
354 callback(true, validNewName, newURL, newOriginURL, newContentType); 347 callback(true, validNewName, newOriginURL, newContentType);
355 } 348 }
356 }, 349 },
357 350
358 /** 351 /**
359 * @override 352 * @override
360 * @param {string} path 353 * @param {string} path
361 * @param {string} query 354 * @param {string} query
362 * @param {boolean} caseSensitive 355 * @param {boolean} caseSensitive
363 * @param {boolean} isRegex 356 * @param {boolean} isRegex
364 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback 357 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 */ 573 */
581 _addFile: function(filePath) 574 _addFile: function(filePath)
582 { 575 {
583 if (!filePath) 576 if (!filePath)
584 console.assert(false); 577 console.assert(false);
585 578
586 var slash = filePath.lastIndexOf("/"); 579 var slash = filePath.lastIndexOf("/");
587 var parentPath = filePath.substring(0, slash); 580 var parentPath = filePath.substring(0, slash);
588 var name = filePath.substring(slash + 1); 581 var name = filePath.substring(slash + 1);
589 582
590 var url = this._networkMapping.urlForPath(this._fileSystem.path(), fileP ath);
591 var extension = this._extensionForPath(name); 583 var extension = this._extensionForPath(name);
592 var contentType = this._contentTypeForExtension(extension); 584 var contentType = this._contentTypeForExtension(extension);
593 585
594 var fileDescriptor = new WebInspector.FileDescriptor(parentPath, name, t his._fileSystemBaseURL + filePath, url, contentType); 586 var fileDescriptor = new WebInspector.FileDescriptor(parentPath, name, t his._fileSystemBaseURL + filePath, contentType);
595 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileAd ded, fileDescriptor); 587 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileAd ded, fileDescriptor);
596 }, 588 },
597 589
598 /** 590 /**
599 * @param {string} path 591 * @param {string} path
600 */ 592 */
601 _removeFile: function(path) 593 _removeFile: function(path)
602 { 594 {
603 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileRe moved, path); 595 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileRe moved, path);
604 }, 596 },
605 597
606 dispose: function() 598 dispose: function()
607 { 599 {
608 this._workspace.removeProject(this._projectId); 600 this._workspace.removeProject(this._projectId);
609 }, 601 },
610 602
611 __proto__: WebInspector.Object.prototype 603 __proto__: WebInspector.Object.prototype
612 } 604 }
613 605
614 /** 606 /**
615 * @type {!WebInspector.FileSystemWorkspaceBinding} 607 * @type {!WebInspector.FileSystemWorkspaceBinding}
616 */ 608 */
617 WebInspector.fileSystemWorkspaceBinding; 609 WebInspector.fileSystemWorkspaceBinding;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698