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

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

Issue 1564113003: DevTools: merge uisourcecode's url-alike members. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 4 years, 11 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return fileSystemPath; 59 return fileSystemPath;
60 } 60 }
61 61
62 /** 62 /**
63 * @param {!WebInspector.UISourceCode} uiSourceCode 63 * @param {!WebInspector.UISourceCode} uiSourceCode
64 * @return {!Array<string>} 64 * @return {!Array<string>}
65 */ 65 */
66 WebInspector.FileSystemWorkspaceBinding.relativePath = function(uiSourceCode) 66 WebInspector.FileSystemWorkspaceBinding.relativePath = function(uiSourceCode)
67 { 67 {
68 var baseURL = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSystem }*/(uiSourceCode.project())._fileSystemBaseURL; 68 var baseURL = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSystem }*/(uiSourceCode.project())._fileSystemBaseURL;
69 return uiSourceCode.path().substring(baseURL.length).split("/"); 69 return uiSourceCode.url().substring(baseURL.length).split("/");
70 } 70 }
71 71
72 /** 72 /**
73 * @param {!WebInspector.Project} project 73 * @param {!WebInspector.Project} project
74 * @param {string} relativePath 74 * @param {string} relativePath
75 * @return {string} 75 * @return {string}
76 */ 76 */
77 WebInspector.FileSystemWorkspaceBinding.completeURL = function(project, relative Path) 77 WebInspector.FileSystemWorkspaceBinding.completeURL = function(project, relative Path)
78 { 78 {
79 var fsProject = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSyst em}*/(project); 79 var fsProject = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSyst em}*/(project);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 { 196 {
197 return this._fileSystemPath; 197 return this._fileSystemPath;
198 }, 198 },
199 199
200 /** 200 /**
201 * @param {!WebInspector.UISourceCode} uiSourceCode 201 * @param {!WebInspector.UISourceCode} uiSourceCode
202 * @return {string} 202 * @return {string}
203 */ 203 */
204 _filePathForUISourceCode: function(uiSourceCode) 204 _filePathForUISourceCode: function(uiSourceCode)
205 { 205 {
206 return uiSourceCode.path().substring(this._fileSystemPath.length); 206 return uiSourceCode.url().substring(this._fileSystemPath.length);
207 }, 207 },
208 208
209 /** 209 /**
210 * @override 210 * @override
211 * @param {!WebInspector.UISourceCode} uiSourceCode 211 * @param {!WebInspector.UISourceCode} uiSourceCode
212 * @param {function(?string)} callback 212 * @param {function(?string)} callback
213 */ 213 */
214 requestFileContent: function(uiSourceCode, callback) 214 requestFileContent: function(uiSourceCode, callback)
215 { 215 {
216 var filePath = this._filePathForUISourceCode(uiSourceCode); 216 var filePath = this._filePathForUISourceCode(uiSourceCode);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 264
265 /** 265 /**
266 * @override 266 * @override
267 * @param {!WebInspector.UISourceCode} uiSourceCode 267 * @param {!WebInspector.UISourceCode} uiSourceCode
268 * @param {string} newName 268 * @param {string} newName
269 * @param {function(boolean, string=, string=, !WebInspector.ResourceType=)} callback 269 * @param {function(boolean, string=, string=, !WebInspector.ResourceType=)} callback
270 */ 270 */
271 rename: function(uiSourceCode, newName, callback) 271 rename: function(uiSourceCode, newName, callback)
272 { 272 {
273 if (newName === uiSourceCode.name()) { 273 if (newName === uiSourceCode.name()) {
274 callback(true, uiSourceCode.name(), uiSourceCode.originURL(), uiSour ceCode.contentType()); 274 callback(true, uiSourceCode.name(), uiSourceCode.url(), uiSourceCode .contentType());
275 return; 275 return;
276 } 276 }
277 277
278 var filePath = this._filePathForUISourceCode(uiSourceCode); 278 var filePath = this._filePathForUISourceCode(uiSourceCode);
279 this._fileSystem.renameFile(filePath, newName, innerCallback.bind(this)) ; 279 this._fileSystem.renameFile(filePath, newName, innerCallback.bind(this)) ;
280 280
281 /** 281 /**
282 * @param {boolean} success 282 * @param {boolean} success
283 * @param {string=} newName 283 * @param {string=} newName
284 * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} 284 * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem}
285 */ 285 */
286 function innerCallback(success, newName) 286 function innerCallback(success, newName)
287 { 287 {
288 if (!success || !newName) { 288 if (!success || !newName) {
289 callback(false, newName); 289 callback(false, newName);
290 return; 290 return;
291 } 291 }
292 console.assert(newName); 292 console.assert(newName);
293 var slash = filePath.lastIndexOf("/"); 293 var slash = filePath.lastIndexOf("/");
294 var parentPath = filePath.substring(0, slash); 294 var parentPath = filePath.substring(0, slash);
295 filePath = parentPath + "/" + newName; 295 filePath = parentPath + "/" + newName;
296 filePath = filePath.substr(1); 296 filePath = filePath.substr(1);
297 var extension = this._extensionForPath(newName); 297 var extension = this._extensionForPath(newName);
298 var newOriginURL = this._fileSystemBaseURL + filePath; 298 var newURL = this._fileSystemBaseURL + filePath;
299 var newContentType = WebInspector.FileSystemWorkspaceBinding._conten tTypeForExtension(extension); 299 var newContentType = WebInspector.FileSystemWorkspaceBinding._conten tTypeForExtension(extension);
300 this.renameUISourceCode(uiSourceCode, newName); 300 this.renameUISourceCode(uiSourceCode, newName);
301 callback(true, newName, newOriginURL, newContentType); 301 callback(true, newName, newURL, newContentType);
302 } 302 }
303 }, 303 },
304 304
305 /** 305 /**
306 * @override 306 * @override
307 * @param {!WebInspector.UISourceCode} uiSourceCode 307 * @param {!WebInspector.UISourceCode} uiSourceCode
308 * @param {string} query 308 * @param {string} query
309 * @param {boolean} caseSensitive 309 * @param {boolean} caseSensitive
310 * @param {boolean} isRegex 310 * @param {boolean} isRegex
311 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback 311 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 * @param {string} path 401 * @param {string} path
402 * @param {function()=} callback 402 * @param {function()=} callback
403 */ 403 */
404 refresh: function(path, callback) 404 refresh: function(path, callback)
405 { 405 {
406 this._fileSystem.requestFilesRecursive(path, this._addFile.bind(this), c allback); 406 this._fileSystem.requestFilesRecursive(path, this._addFile.bind(this), c allback);
407 }, 407 },
408 408
409 /** 409 /**
410 * @override 410 * @override
411 * @param {string} path 411 * @param {string} url
412 */ 412 */
413 excludeFolder: function(path) 413 excludeFolder: function(url)
414 { 414 {
415 var relativeFolder = path.substring(this._fileSystemBaseURL.length); 415 var relativeFolder = url.substring(this._fileSystemBaseURL.length);
416 if (!relativeFolder.startsWith("/")) 416 if (!relativeFolder.startsWith("/"))
417 relativeFolder = "/" + relativeFolder; 417 relativeFolder = "/" + relativeFolder;
418 if (!relativeFolder.endsWith("/")) 418 if (!relativeFolder.endsWith("/"))
419 relativeFolder += "/"; 419 relativeFolder += "/";
420 this._fileSystem.addExcludedFolder(relativeFolder); 420 this._fileSystem.addExcludedFolder(relativeFolder);
421 421
422 var uiSourceCodes = this.uiSourceCodes().slice(); 422 var uiSourceCodes = this.uiSourceCodes().slice();
423 for (var i = 0; i < uiSourceCodes.length; ++i) { 423 for (var i = 0; i < uiSourceCodes.length; ++i) {
424 var uiSourceCode = uiSourceCodes[i]; 424 var uiSourceCode = uiSourceCodes[i];
425 if (uiSourceCode.path().startsWith(path)) 425 if (uiSourceCode.url().startsWith(url))
426 this.removeUISourceCode(uiSourceCode.path()); 426 this.removeUISourceCode(uiSourceCode.url());
427 } 427 }
428 }, 428 },
429 429
430 /** 430 /**
431 * @override 431 * @override
432 * @param {string} path 432 * @param {string} path
433 * @param {?string} name 433 * @param {?string} name
434 * @param {string} content 434 * @param {string} content
435 * @param {function(?WebInspector.UISourceCode)} callback 435 * @param {function(?WebInspector.UISourceCode)} callback
436 */ 436 */
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 var uiSourceCode = this.createUISourceCode(this._fileSystemBaseURL + fil ePath, contentType); 499 var uiSourceCode = this.createUISourceCode(this._fileSystemBaseURL + fil ePath, contentType);
500 this.addUISourceCode(uiSourceCode); 500 this.addUISourceCode(uiSourceCode);
501 return uiSourceCode; 501 return uiSourceCode;
502 }, 502 },
503 503
504 /** 504 /**
505 * @param {string} path 505 * @param {string} path
506 */ 506 */
507 _fileChanged: function(path) 507 _fileChanged: function(path)
508 { 508 {
509 var uiSourceCode = this.uiSourceCode(path); 509 var uiSourceCode = this.uiSourceCodeForURL(path);
510 if (!uiSourceCode) { 510 if (!uiSourceCode) {
511 this._addFile(path); 511 this._addFile(path);
512 return; 512 return;
513 } 513 }
514 uiSourceCode.checkContentUpdated(); 514 uiSourceCode.checkContentUpdated();
515 }, 515 },
516 516
517 dispose: function() 517 dispose: function()
518 { 518 {
519 this.removeProject(); 519 this.removeProject();
520 }, 520 },
521 521
522 __proto__: WebInspector.ProjectStore.prototype 522 __proto__: WebInspector.ProjectStore.prototype
523 } 523 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698