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

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

Issue 1523193002: DevTools: merge UISourceCode's parentPath, name, originURL and uri. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 WebInspector.FileSystemWorkspaceBinding._imageExtensions = WebInspector.Isolated FileSystem.ImageExtensions; 59 WebInspector.FileSystemWorkspaceBinding._imageExtensions = WebInspector.Isolated FileSystem.ImageExtensions;
60 60
61 WebInspector.FileSystemWorkspaceBinding._lastRequestId = 0; 61 WebInspector.FileSystemWorkspaceBinding._lastRequestId = 0;
62 62
63 /** 63 /**
64 * @param {string} fileSystemPath 64 * @param {string} fileSystemPath
65 * @return {string} 65 * @return {string}
66 */ 66 */
67 WebInspector.FileSystemWorkspaceBinding.projectId = function(fileSystemPath) 67 WebInspector.FileSystemWorkspaceBinding.projectId = function(fileSystemPath)
68 { 68 {
69 return "filesystem:" + fileSystemPath; 69 return "file://" + fileSystemPath;
70 } 70 }
71 71
72 /** 72 /**
73 * @param {string} extension 73 * @param {string} extension
74 * @return {!WebInspector.ResourceType} 74 * @return {!WebInspector.ResourceType}
75 */ 75 */
76 WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension = function(exte nsion) 76 WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension = function(exte nsion)
77 { 77 {
78 if (WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions.has(extens ion)) 78 if (WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions.has(extens ion))
79 return WebInspector.resourceTypes.Stylesheet; 79 return WebInspector.resourceTypes.Stylesheet;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 } 130 }
131 }, 131 },
132 132
133 /** 133 /**
134 * @param {string} projectId 134 * @param {string} projectId
135 * @return {string} 135 * @return {string}
136 */ 136 */
137 fileSystemPath: function(projectId) 137 fileSystemPath: function(projectId)
138 { 138 {
139 var fileSystemPath = projectId.substr("filesystem:".length); 139 return projectId.substr("file://".length);
140 var normalizedPath = WebInspector.IsolatedFileSystem.normalizePath(fileS ystemPath);
141 return projectId.substr("filesystem:".length);
142 }, 140 },
143 141
144 /** 142 /**
145 * @return {number} 143 * @return {number}
146 */ 144 */
147 _nextId: function() 145 _nextId: function()
148 { 146 {
149 return ++WebInspector.FileSystemWorkspaceBinding._lastRequestId; 147 return ++WebInspector.FileSystemWorkspaceBinding._lastRequestId;
150 }, 148 },
151 149
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 * @implements {WebInspector.Project} 251 * @implements {WebInspector.Project}
254 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding 252 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding
255 * @param {!WebInspector.IsolatedFileSystem} isolatedFileSystem 253 * @param {!WebInspector.IsolatedFileSystem} isolatedFileSystem
256 * @param {!WebInspector.Workspace} workspace 254 * @param {!WebInspector.Workspace} workspace
257 */ 255 */
258 WebInspector.FileSystemWorkspaceBinding.FileSystem = function(fileSystemWorkspac eBinding, isolatedFileSystem, workspace) 256 WebInspector.FileSystemWorkspaceBinding.FileSystem = function(fileSystemWorkspac eBinding, isolatedFileSystem, workspace)
259 { 257 {
260 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; 258 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding;
261 this._fileSystem = isolatedFileSystem; 259 this._fileSystem = isolatedFileSystem;
262 this._fileSystemBaseURL = "file://" + this._fileSystem.normalizedPath() + "/ "; 260 this._fileSystemBaseURL = "file://" + this._fileSystem.normalizedPath() + "/ ";
261 this._fileSystemPath = this._fileSystem.path();
263 262
264 var id = WebInspector.FileSystemWorkspaceBinding.projectId(this._fileSystem. path()); 263 var id = WebInspector.FileSystemWorkspaceBinding.projectId(this._fileSystemP ath);
265 console.assert(!workspace.project(id)); 264 console.assert(!workspace.project(id));
266 265
267 var url = "filesystem:" + this._fileSystem.normalizedPath();
268 var normalizedPath = isolatedFileSystem.normalizedPath(); 266 var normalizedPath = isolatedFileSystem.normalizedPath();
269 var displayName = normalizedPath.substr(normalizedPath.lastIndexOf("/") + 1) ; 267 var displayName = normalizedPath.substr(normalizedPath.lastIndexOf("/") + 1) ;
270 268
271 WebInspector.ProjectStore.call(this, workspace, id, WebInspector.projectType s.FileSystem, url, displayName); 269 WebInspector.ProjectStore.call(this, workspace, id, WebInspector.projectType s.FileSystem, displayName);
272 270
273 workspace.addProject(this); 271 workspace.addProject(this);
274 this.populate(); 272 this.populate();
275 } 273 }
276 274
277 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { 275 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {
278 /** 276 /**
279 * @return {string} 277 * @return {string}
280 */ 278 */
281 fileSystemPath: function() 279 fileSystemPath: function()
282 { 280 {
283 return this._fileSystem.path(); 281 return this._fileSystemPath;
284 }, 282 },
285 283
286 /** 284 /**
287 * @param {!WebInspector.UISourceCode} uiSourceCode 285 * @param {!WebInspector.UISourceCode} uiSourceCode
288 * @return {string} 286 * @return {string}
289 */ 287 */
290 _filePathForUISourceCode: function(uiSourceCode) 288 _filePathForUISourceCode: function(uiSourceCode)
291 { 289 {
292 return "/" + uiSourceCode.path(); 290 return uiSourceCode.path().substring(("file:// " + this._fileSystemPath) .length);
293 }, 291 },
294 292
295 /** 293 /**
296 * @override 294 * @override
297 * @param {!WebInspector.UISourceCode} uiSourceCode 295 * @param {!WebInspector.UISourceCode} uiSourceCode
298 * @param {function(?string)} callback 296 * @param {function(?string)} callback
299 */ 297 */
300 requestFileContent: function(uiSourceCode, callback) 298 requestFileContent: function(uiSourceCode, callback)
301 { 299 {
302 var filePath = this._filePathForUISourceCode(uiSourceCode); 300 var filePath = this._filePathForUISourceCode(uiSourceCode);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 600
603 /** 601 /**
604 * @param {string} filePath 602 * @param {string} filePath
605 * @return {!WebInspector.UISourceCode} 603 * @return {!WebInspector.UISourceCode}
606 */ 604 */
607 _addFile: function(filePath) 605 _addFile: function(filePath)
608 { 606 {
609 if (!filePath) 607 if (!filePath)
610 console.assert(false); 608 console.assert(false);
611 609
612 var slash = filePath.lastIndexOf("/"); 610 var extension = this._extensionForPath(filePath);
613 var parentPath = filePath.substring(0, slash);
614 var name = filePath.substring(slash + 1);
615
616 var extension = this._extensionForPath(name);
617 var contentType = WebInspector.FileSystemWorkspaceBinding._contentTypeFo rExtension(extension); 611 var contentType = WebInspector.FileSystemWorkspaceBinding._contentTypeFo rExtension(extension);
618 612
619 var uiSourceCode = this.createUISourceCode(parentPath, name, this._fileS ystemBaseURL + filePath, contentType); 613 var uiSourceCode = this.createUISourceCode(this._fileSystemBaseURL + fil ePath, contentType);
620 this.addUISourceCode(uiSourceCode); 614 this.addUISourceCode(uiSourceCode);
621 return uiSourceCode; 615 return uiSourceCode;
622 }, 616 },
623 617
624 /** 618 /**
625 * @param {string} path 619 * @param {string} path
626 */ 620 */
627 _fileChanged: function(path) 621 _fileChanged: function(path)
628 { 622 {
629 var uiSourceCode = this.uiSourceCode(path); 623 var uiSourceCode = this.uiSourceCode(path);
630 if (!uiSourceCode) { 624 if (!uiSourceCode) {
631 this._addFile(path); 625 this._addFile(path);
632 return; 626 return;
633 } 627 }
634 uiSourceCode.checkContentUpdated(); 628 uiSourceCode.checkContentUpdated();
635 }, 629 },
636 630
637 dispose: function() 631 dispose: function()
638 { 632 {
639 this.removeProject(); 633 this.removeProject();
640 }, 634 },
641 635
642 __proto__: WebInspector.ProjectStore.prototype 636 __proto__: WebInspector.ProjectStore.prototype
643 } 637 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698