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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/workspace/Workspace.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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 * @param {function(!Array.<string>)} callback 168 * @param {function(!Array.<string>)} callback
169 */ 169 */
170 findFilesMatchingSearchRequest: function(searchConfig, filesMathingFileQuery , progress, callback) { }, 170 findFilesMatchingSearchRequest: function(searchConfig, filesMathingFileQuery , progress, callback) { },
171 171
172 /** 172 /**
173 * @param {!WebInspector.Progress} progress 173 * @param {!WebInspector.Progress} progress
174 */ 174 */
175 indexContent: function(progress) { }, 175 indexContent: function(progress) { },
176 176
177 /** 177 /**
178 * @param {string} path 178 * @param {string} url
179 * @return {?WebInspector.UISourceCode} 179 * @return {?WebInspector.UISourceCode}
180 */ 180 */
181 uiSourceCode: function(path) { }, 181 uiSourceCodeForURL: function(url) { },
182
183 /**
184 * @param {string} originURL
185 * @return {?WebInspector.UISourceCode}
186 */
187 uiSourceCodeForOriginURL: function(originURL) { },
188 182
189 /** 183 /**
190 * @return {!Array.<!WebInspector.UISourceCode>} 184 * @return {!Array.<!WebInspector.UISourceCode>}
191 */ 185 */
192 uiSourceCodes: function() { } 186 uiSourceCodes: function() { }
193 } 187 }
194 188
195 /** 189 /**
196 * @enum {string} 190 * @enum {string}
197 */ 191 */
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 return new WebInspector.UISourceCode(this._project, url, contentType); 264 return new WebInspector.UISourceCode(this._project, url, contentType);
271 }, 265 },
272 266
273 /** 267 /**
274 * @param {!WebInspector.UISourceCode} uiSourceCode 268 * @param {!WebInspector.UISourceCode} uiSourceCode
275 * @param {boolean=} replace 269 * @param {boolean=} replace
276 * @return {boolean} 270 * @return {boolean}
277 */ 271 */
278 addUISourceCode: function(uiSourceCode, replace) 272 addUISourceCode: function(uiSourceCode, replace)
279 { 273 {
280 var path = uiSourceCode.path(); 274 var url = uiSourceCode.url();
281 if (this.uiSourceCode(path)) { 275 if (this.uiSourceCodeForURL(url)) {
282 if (replace) 276 if (replace)
283 this.removeUISourceCode(path); 277 this.removeUISourceCode(url);
284 else 278 else
285 return false; 279 return false;
286 } 280 }
287 this._uiSourceCodesMap.set(path, {uiSourceCode: uiSourceCode, index: thi s._uiSourceCodesList.length}); 281 this._uiSourceCodesMap.set(url, {uiSourceCode: uiSourceCode, index: this ._uiSourceCodesList.length});
288 this._uiSourceCodesList.push(uiSourceCode); 282 this._uiSourceCodesList.push(uiSourceCode);
289 this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.U ISourceCodeAdded, uiSourceCode); 283 this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.U ISourceCodeAdded, uiSourceCode);
290 return true; 284 return true;
291 }, 285 },
292 286
293 /** 287 /**
294 * @param {string} path 288 * @param {string} url
295 */ 289 */
296 removeUISourceCode: function(path) 290 removeUISourceCode: function(url)
297 { 291 {
298 var uiSourceCode = this.uiSourceCode(path); 292 var uiSourceCode = this.uiSourceCodeForURL(url);
299 if (!uiSourceCode) 293 if (!uiSourceCode)
300 return; 294 return;
301 295
302 var entry = this._uiSourceCodesMap.get(path); 296 var entry = this._uiSourceCodesMap.get(url);
303 var movedUISourceCode = this._uiSourceCodesList[this._uiSourceCodesList. length - 1]; 297 var movedUISourceCode = this._uiSourceCodesList[this._uiSourceCodesList. length - 1];
304 this._uiSourceCodesList[entry.index] = movedUISourceCode; 298 this._uiSourceCodesList[entry.index] = movedUISourceCode;
305 var movedEntry = this._uiSourceCodesMap.get(movedUISourceCode.path()); 299 var movedEntry = this._uiSourceCodesMap.get(movedUISourceCode.url());
306 movedEntry.index = entry.index; 300 movedEntry.index = entry.index;
307 this._uiSourceCodesList.splice(this._uiSourceCodesList.length - 1, 1); 301 this._uiSourceCodesList.splice(this._uiSourceCodesList.length - 1, 1);
308 this._uiSourceCodesMap.delete(path); 302 this._uiSourceCodesMap.delete(url);
309 this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.U ISourceCodeRemoved, entry.uiSourceCode); 303 this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.U ISourceCodeRemoved, entry.uiSourceCode);
310 }, 304 },
311 305
312 removeProject: function() 306 removeProject: function()
313 { 307 {
314 this._workspace._removeProject(this._project); 308 this._workspace._removeProject(this._project);
315 this._uiSourceCodesMap = new Map(); 309 this._uiSourceCodesMap = new Map();
316 this._uiSourceCodesList = []; 310 this._uiSourceCodesList = [];
317 }, 311 },
318 312
319 /** 313 /**
320 * @param {string} path 314 * @param {string} url
321 * @return {?WebInspector.UISourceCode} 315 * @return {?WebInspector.UISourceCode}
322 */ 316 */
323 uiSourceCode: function(path) 317 uiSourceCodeForURL: function(url)
324 { 318 {
325 var entry = this._uiSourceCodesMap.get(path); 319 var entry = this._uiSourceCodesMap.get(url);
326 return entry ? entry.uiSourceCode : null; 320 return entry ? entry.uiSourceCode : null;
327 }, 321 },
328 322
329 /** 323 /**
330 * @param {string} originURL
331 * @return {?WebInspector.UISourceCode}
332 */
333 uiSourceCodeForOriginURL: function(originURL)
334 {
335 for (var i = 0; i < this._uiSourceCodesList.length; ++i) {
336 var uiSourceCode = this._uiSourceCodesList[i];
337 if (uiSourceCode.originURL() === originURL)
338 return uiSourceCode;
339 }
340 return null;
341 },
342
343 /**
344 * @return {!Array.<!WebInspector.UISourceCode>} 324 * @return {!Array.<!WebInspector.UISourceCode>}
345 */ 325 */
346 uiSourceCodes: function() 326 uiSourceCodes: function()
347 { 327 {
348 return this._uiSourceCodesList; 328 return this._uiSourceCodesList;
349 }, 329 },
350 330
351 /** 331 /**
352 * @param {!WebInspector.UISourceCode} uiSourceCode 332 * @param {!WebInspector.UISourceCode} uiSourceCode
353 * @param {string} newName 333 * @param {string} newName
354 */ 334 */
355 renameUISourceCode: function(uiSourceCode, newName) 335 renameUISourceCode: function(uiSourceCode, newName)
356 { 336 {
357 var oldPath = uiSourceCode.path(); 337 var oldPath = uiSourceCode.url();
358 var newPath = uiSourceCode.parentPath() ? uiSourceCode.parentPath() + "/ " + newName : newName; 338 var newPath = uiSourceCode.parentURL() ? uiSourceCode.parentURL() + "/" + newName : newName;
359 var value = /** @type {!{uiSourceCode: !WebInspector.UISourceCode, index : number}} */ (this._uiSourceCodesMap.get(oldPath)); 339 var value = /** @type {!{uiSourceCode: !WebInspector.UISourceCode, index : number}} */ (this._uiSourceCodesMap.get(oldPath));
360 this._uiSourceCodesMap.set(newPath, value); 340 this._uiSourceCodesMap.set(newPath, value);
361 this._uiSourceCodesMap.delete(oldPath); 341 this._uiSourceCodesMap.delete(oldPath);
362 } 342 }
363 } 343 }
364 344
365 /** 345 /**
366 * @constructor 346 * @constructor
367 * @extends {WebInspector.Object} 347 * @extends {WebInspector.Object}
368 */ 348 */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 var unsavedSourceCodes = []; 381 var unsavedSourceCodes = [];
402 var projects = this.projectsForType(WebInspector.projectTypes.FileSystem ); 382 var projects = this.projectsForType(WebInspector.projectTypes.FileSystem );
403 for (var i = 0; i < projects.length; ++i) 383 for (var i = 0; i < projects.length; ++i)
404 unsavedSourceCodes = unsavedSourceCodes.concat(projects[i].uiSourceC odes().filter(filterUnsaved)); 384 unsavedSourceCodes = unsavedSourceCodes.concat(projects[i].uiSourceC odes().filter(filterUnsaved));
405 385
406 return unsavedSourceCodes; 386 return unsavedSourceCodes;
407 }, 387 },
408 388
409 /** 389 /**
410 * @param {string} projectId 390 * @param {string} projectId
411 * @param {string} path 391 * @param {string} url
412 * @return {?WebInspector.UISourceCode} 392 * @return {?WebInspector.UISourceCode}
413 */ 393 */
414 uiSourceCode: function(projectId, path) 394 uiSourceCode: function(projectId, url)
415 { 395 {
416 var project = this._projects.get(projectId); 396 var project = this._projects.get(projectId);
417 return project ? project.uiSourceCode(path) : null; 397 return project ? project.uiSourceCodeForURL(url) : null;
418 }, 398 },
419 399
420 /** 400 /**
421 * @param {string} originURL 401 * @param {string} url
422 * @return {?WebInspector.UISourceCode} 402 * @return {?WebInspector.UISourceCode}
423 */ 403 */
424 uiSourceCodeForOriginURL: function(originURL) 404 uiSourceCodeForURL: function(url)
425 { 405 {
426 var projects = this.projectsForType(WebInspector.projectTypes.Network); 406 for (var project of this._projects.values()) {
427 projects = projects.concat(this.projectsForType(WebInspector.projectType s.ContentScripts)); 407 var uiSourceCode = project.uiSourceCodeForURL(url);
428 for (var project of projects) {
429 var uiSourceCode = project.uiSourceCodeForOriginURL(originURL);
430 if (uiSourceCode) 408 if (uiSourceCode)
431 return uiSourceCode; 409 return uiSourceCode;
432 } 410 }
433 return null;
434 },
435
436 /**
437 * @param {string} originURL
438 * @return {?WebInspector.UISourceCode}
439 */
440 filesystemUISourceCode: function(originURL)
441 {
442 for (var project of this.projectsForType(WebInspector.projectTypes.FileS ystem)) {
443 var uiSourceCode = project.uiSourceCodeForOriginURL(originURL);
444 if (uiSourceCode)
445 return uiSourceCode;
446 }
447 return null; 411 return null;
448 }, 412 },
449 413
450 /** 414 /**
451 * @param {string} type 415 * @param {string} type
452 * @return {!Array.<!WebInspector.UISourceCode>} 416 * @return {!Array.<!WebInspector.UISourceCode>}
453 */ 417 */
454 uiSourceCodesForProjectType: function(type) 418 uiSourceCodesForProjectType: function(type)
455 { 419 {
456 var result = []; 420 var result = [];
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return this._hasResourceContentTrackingExtensions; 500 return this._hasResourceContentTrackingExtensions;
537 }, 501 },
538 502
539 __proto__: WebInspector.Object.prototype 503 __proto__: WebInspector.Object.prototype
540 } 504 }
541 505
542 /** 506 /**
543 * @type {!WebInspector.Workspace} 507 * @type {!WebInspector.Workspace}
544 */ 508 */
545 WebInspector.workspace; 509 WebInspector.workspace;
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698