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

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: 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) 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 */ 174 */
175 indexContent: function(progress) { }, 175 indexContent: function(progress) { },
176 176
177 /** 177 /**
178 * @param {string} path 178 * @param {string} path
179 * @return {?WebInspector.UISourceCode} 179 * @return {?WebInspector.UISourceCode}
180 */ 180 */
181 uiSourceCode: function(path) { }, 181 uiSourceCode: function(path) { },
182 182
183 /** 183 /**
184 * @param {string} originURL 184 * @param {string} url
185 * @return {?WebInspector.UISourceCode} 185 * @return {?WebInspector.UISourceCode}
186 */ 186 */
187 uiSourceCodeForOriginURL: function(originURL) { }, 187 uiSourceCodeForURL: function(url) { },
188 188
189 /** 189 /**
190 * @return {!Array.<!WebInspector.UISourceCode>} 190 * @return {!Array.<!WebInspector.UISourceCode>}
191 */ 191 */
192 uiSourceCodes: function() { } 192 uiSourceCodes: function() { }
193 } 193 }
194 194
195 /** 195 /**
196 * @enum {string} 196 * @enum {string}
197 */ 197 */
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 return new WebInspector.UISourceCode(this._project, url, contentType); 270 return new WebInspector.UISourceCode(this._project, url, contentType);
271 }, 271 },
272 272
273 /** 273 /**
274 * @param {!WebInspector.UISourceCode} uiSourceCode 274 * @param {!WebInspector.UISourceCode} uiSourceCode
275 * @param {boolean=} replace 275 * @param {boolean=} replace
276 * @return {boolean} 276 * @return {boolean}
277 */ 277 */
278 addUISourceCode: function(uiSourceCode, replace) 278 addUISourceCode: function(uiSourceCode, replace)
279 { 279 {
280 var path = uiSourceCode.path(); 280 var path = uiSourceCode.url();
dgozman 2016/01/08 20:22:07 path -> url
281 if (this.uiSourceCode(path)) { 281 if (this.uiSourceCode(path)) {
282 if (replace) 282 if (replace)
283 this.removeUISourceCode(path); 283 this.removeUISourceCode(path);
284 else 284 else
285 return false; 285 return false;
286 } 286 }
287 this._uiSourceCodesMap.set(path, {uiSourceCode: uiSourceCode, index: thi s._uiSourceCodesList.length}); 287 this._uiSourceCodesMap.set(path, {uiSourceCode: uiSourceCode, index: thi s._uiSourceCodesList.length});
288 this._uiSourceCodesList.push(uiSourceCode); 288 this._uiSourceCodesList.push(uiSourceCode);
289 this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.U ISourceCodeAdded, uiSourceCode); 289 this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.U ISourceCodeAdded, uiSourceCode);
290 return true; 290 return true;
291 }, 291 },
292 292
293 /** 293 /**
294 * @param {string} path 294 * @param {string} path
295 */ 295 */
296 removeUISourceCode: function(path) 296 removeUISourceCode: function(path)
297 { 297 {
298 var uiSourceCode = this.uiSourceCode(path); 298 var uiSourceCode = this.uiSourceCode(path);
299 if (!uiSourceCode) 299 if (!uiSourceCode)
300 return; 300 return;
301 301
302 var entry = this._uiSourceCodesMap.get(path); 302 var entry = this._uiSourceCodesMap.get(path);
303 var movedUISourceCode = this._uiSourceCodesList[this._uiSourceCodesList. length - 1]; 303 var movedUISourceCode = this._uiSourceCodesList[this._uiSourceCodesList. length - 1];
304 this._uiSourceCodesList[entry.index] = movedUISourceCode; 304 this._uiSourceCodesList[entry.index] = movedUISourceCode;
305 var movedEntry = this._uiSourceCodesMap.get(movedUISourceCode.path()); 305 var movedEntry = this._uiSourceCodesMap.get(movedUISourceCode.url());
306 movedEntry.index = entry.index; 306 movedEntry.index = entry.index;
307 this._uiSourceCodesList.splice(this._uiSourceCodesList.length - 1, 1); 307 this._uiSourceCodesList.splice(this._uiSourceCodesList.length - 1, 1);
308 this._uiSourceCodesMap.delete(path); 308 this._uiSourceCodesMap.delete(path);
309 this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.U ISourceCodeRemoved, entry.uiSourceCode); 309 this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.U ISourceCodeRemoved, entry.uiSourceCode);
310 }, 310 },
311 311
312 removeProject: function() 312 removeProject: function()
313 { 313 {
314 this._workspace._removeProject(this._project); 314 this._workspace._removeProject(this._project);
315 this._uiSourceCodesMap = new Map(); 315 this._uiSourceCodesMap = new Map();
316 this._uiSourceCodesList = []; 316 this._uiSourceCodesList = [];
317 }, 317 },
318 318
319 /** 319 /**
320 * @param {string} path 320 * @param {string} path
321 * @return {?WebInspector.UISourceCode} 321 * @return {?WebInspector.UISourceCode}
322 */ 322 */
323 uiSourceCode: function(path) 323 uiSourceCode: function(path)
324 { 324 {
325 var entry = this._uiSourceCodesMap.get(path); 325 var entry = this._uiSourceCodesMap.get(path);
326 return entry ? entry.uiSourceCode : null; 326 return entry ? entry.uiSourceCode : null;
327 }, 327 },
328 328
329 /** 329 /**
330 * @param {string} originURL 330 * @param {string} url
331 * @return {?WebInspector.UISourceCode} 331 * @return {?WebInspector.UISourceCode}
332 */ 332 */
333 uiSourceCodeForOriginURL: function(originURL) 333 uiSourceCodeForURL: function(url)
334 { 334 {
335 for (var i = 0; i < this._uiSourceCodesList.length; ++i) { 335 for (var i = 0; i < this._uiSourceCodesList.length; ++i) {
336 var uiSourceCode = this._uiSourceCodesList[i]; 336 var uiSourceCode = this._uiSourceCodesList[i];
337 if (uiSourceCode.originURL() === originURL) 337 if (uiSourceCode.url() === url)
338 return uiSourceCode; 338 return uiSourceCode;
339 } 339 }
340 return null; 340 return null;
341 }, 341 },
342 342
343 /** 343 /**
344 * @return {!Array.<!WebInspector.UISourceCode>} 344 * @return {!Array.<!WebInspector.UISourceCode>}
345 */ 345 */
346 uiSourceCodes: function() 346 uiSourceCodes: function()
347 { 347 {
348 return this._uiSourceCodesList; 348 return this._uiSourceCodesList;
349 }, 349 },
350 350
351 /** 351 /**
352 * @param {!WebInspector.UISourceCode} uiSourceCode 352 * @param {!WebInspector.UISourceCode} uiSourceCode
353 * @param {string} newName 353 * @param {string} newName
354 */ 354 */
355 renameUISourceCode: function(uiSourceCode, newName) 355 renameUISourceCode: function(uiSourceCode, newName)
356 { 356 {
357 var oldPath = uiSourceCode.path(); 357 var oldPath = uiSourceCode.url();
358 var newPath = uiSourceCode.parentPath() ? uiSourceCode.parentPath() + "/ " + newName : newName; 358 var newPath = uiSourceCode.parentURL() ? uiSourceCode.parentURL() + "/" + newName : newName;
359 var value = /** @type {!{uiSourceCode: !WebInspector.UISourceCode, index : number}} */ (this._uiSourceCodesMap.get(oldPath)); 359 var value = /** @type {!{uiSourceCode: !WebInspector.UISourceCode, index : number}} */ (this._uiSourceCodesMap.get(oldPath));
360 this._uiSourceCodesMap.set(newPath, value); 360 this._uiSourceCodesMap.set(newPath, value);
361 this._uiSourceCodesMap.delete(oldPath); 361 this._uiSourceCodesMap.delete(oldPath);
362 } 362 }
363 } 363 }
364 364
365 /** 365 /**
366 * @constructor 366 * @constructor
367 * @extends {WebInspector.Object} 367 * @extends {WebInspector.Object}
368 */ 368 */
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 * @param {string} path 411 * @param {string} path
412 * @return {?WebInspector.UISourceCode} 412 * @return {?WebInspector.UISourceCode}
413 */ 413 */
414 uiSourceCode: function(projectId, path) 414 uiSourceCode: function(projectId, path)
415 { 415 {
416 var project = this._projects.get(projectId); 416 var project = this._projects.get(projectId);
417 return project ? project.uiSourceCode(path) : null; 417 return project ? project.uiSourceCode(path) : null;
418 }, 418 },
419 419
420 /** 420 /**
421 * @param {string} originURL 421 * @param {string} url
422 * @return {?WebInspector.UISourceCode} 422 * @return {?WebInspector.UISourceCode}
423 */ 423 */
424 uiSourceCodeForOriginURL: function(originURL) 424 uiSourceCodeForURL: function(url)
425 { 425 {
426 var projects = this.projectsForType(WebInspector.projectTypes.Network); 426 var projects = this.projectsForType(WebInspector.projectTypes.Network);
dgozman 2016/01/08 20:22:07 Search in all projects.
427 projects = projects.concat(this.projectsForType(WebInspector.projectType s.ContentScripts)); 427 projects = projects.concat(this.projectsForType(WebInspector.projectType s.ContentScripts));
428 for (var project of projects) { 428 for (var project of projects) {
429 var uiSourceCode = project.uiSourceCodeForOriginURL(originURL); 429 var uiSourceCode = project.uiSourceCodeForURL(url);
430 if (uiSourceCode) 430 if (uiSourceCode)
431 return uiSourceCode; 431 return uiSourceCode;
432 } 432 }
433 return null; 433 return null;
434 }, 434 },
435 435
436 /** 436 /**
437 * @param {string} originURL 437 * @param {string} url
438 * @return {?WebInspector.UISourceCode} 438 * @return {?WebInspector.UISourceCode}
439 */ 439 */
440 filesystemUISourceCode: function(originURL) 440 filesystemUISourceCode: function(url)
dgozman 2016/01/08 20:22:07 Let's remove this one
441 { 441 {
442 for (var project of this.projectsForType(WebInspector.projectTypes.FileS ystem)) { 442 for (var project of this.projectsForType(WebInspector.projectTypes.FileS ystem)) {
443 var uiSourceCode = project.uiSourceCodeForOriginURL(originURL); 443 var uiSourceCode = project.uiSourceCodeForURL(url);
444 if (uiSourceCode) 444 if (uiSourceCode)
445 return uiSourceCode; 445 return uiSourceCode;
446 } 446 }
447 return null; 447 return null;
448 }, 448 },
449 449
450 /** 450 /**
451 * @param {string} type 451 * @param {string} type
452 * @return {!Array.<!WebInspector.UISourceCode>} 452 * @return {!Array.<!WebInspector.UISourceCode>}
453 */ 453 */
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return this._hasResourceContentTrackingExtensions; 536 return this._hasResourceContentTrackingExtensions;
537 }, 537 },
538 538
539 __proto__: WebInspector.Object.prototype 539 __proto__: WebInspector.Object.prototype
540 } 540 }
541 541
542 /** 542 /**
543 * @type {!WebInspector.Workspace} 543 * @type {!WebInspector.Workspace}
544 */ 544 */
545 WebInspector.workspace; 545 WebInspector.workspace;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698