| OLD | NEW |
| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 var sectionElement = this._nameToSection.get(sectionName); | 264 var sectionElement = this._nameToSection.get(sectionName); |
| 265 if (!sectionElement) { | 265 if (!sectionElement) { |
| 266 var uiSectionName = sectionName && Common.UIString(sectionName); | 266 var uiSectionName = sectionName && Common.UIString(sectionName); |
| 267 sectionElement = this._appendSection(uiSectionName); | 267 sectionElement = this._appendSection(uiSectionName); |
| 268 this._nameToSection.set(sectionName, sectionElement); | 268 this._nameToSection.set(sectionName, sectionElement); |
| 269 } | 269 } |
| 270 return sectionElement; | 270 return sectionElement; |
| 271 } | 271 } |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 | |
| 275 /** | |
| 276 * @unrestricted | |
| 277 */ | |
| 278 Settings.WorkspaceSettingsTab = class extends Settings.SettingsTab { | |
| 279 constructor() { | |
| 280 super(Common.UIString('Workspace'), 'workspace-tab-content'); | |
| 281 Workspace.isolatedFileSystemManager.addEventListener( | |
| 282 Workspace.IsolatedFileSystemManager.Events.FileSystemAdded, this._fileSy
stemAdded, this); | |
| 283 Workspace.isolatedFileSystemManager.addEventListener( | |
| 284 Workspace.IsolatedFileSystemManager.Events.FileSystemRemoved, this._file
SystemRemoved, this); | |
| 285 | |
| 286 var folderExcludePatternInput = this._createFolderExcludePatternInput(); | |
| 287 folderExcludePatternInput.classList.add('folder-exclude-pattern'); | |
| 288 this.containerElement.appendChild(folderExcludePatternInput); | |
| 289 | |
| 290 if (Runtime.experiments.isEnabled('persistence2')) { | |
| 291 var div = this.containerElement.createChild('div', 'settings-info-message'
); | |
| 292 div.createTextChild(Common.UIString('Mappings are inferred automatically.
Please ')); | |
| 293 div.appendChild(UI.createExternalLink( | |
| 294 'https://bugs.chromium.org/p/chromium/issues/entry?template=Defect%20r
eport%20from%20user&components=Platform%3EDevTools%3EAuthoring&comment=DevTools%
20failed%20to%20link%20network%20resource%20to%20filesystem.%0A%0APlatform%3A%20
%3CLinux%2FWin%2FMac%3E%0AChrome%20version%3A%20%3Cyour%20chrome%20version%3E%0A
%0AWhat%20are%20the%20details%20of%20your%20project%3F%0A-%20Source%20code%20(if
%20any)%3A%20http%3A%2F%2Fgithub.com%2Fexample%2Fexample%0A-%20Build%20System%3A
%20gulp%2Fgrunt%2Fwebpack%2Frollup%2F...%0A-%20HTTP%20server%3A%20node%20HTTP%2F
nginx%2Fapache...%0A%0AAssets%20failed%20to%20link%20(or%20incorrectly%20linked)
%3A%0A1.%0A2.%0A3.%0A%0AIf%20possible%2C%20please%20attach%20a%20screenshot%20of
%20network%20sources%20navigator%20which%20should%0Ashow%20which%20resources%20f
ailed%20to%20map', | |
| 295 Common.UIString('report'))); | |
| 296 div.createTextChild(Common.UIString(' any bugs.')); | |
| 297 } | |
| 298 | |
| 299 this._fileSystemsListContainer = this.containerElement.createChild('div', ''
); | |
| 300 | |
| 301 this.containerElement.appendChild( | |
| 302 UI.createTextButton(Common.UIString('Add folder\u2026'), this._addFileSy
stemClicked.bind(this))); | |
| 303 | |
| 304 /** @type {!Map<string, !Element>} */ | |
| 305 this._elementByPath = new Map(); | |
| 306 | |
| 307 /** @type {!Map<string, !Settings.EditFileSystemView>} */ | |
| 308 this._mappingViewByPath = new Map(); | |
| 309 | |
| 310 var fileSystems = Workspace.isolatedFileSystemManager.fileSystems(); | |
| 311 for (var i = 0; i < fileSystems.length; ++i) | |
| 312 this._addItem(fileSystems[i]); | |
| 313 } | |
| 314 | |
| 315 /** | |
| 316 * @return {!Element} | |
| 317 */ | |
| 318 _createFolderExcludePatternInput() { | |
| 319 var p = createElement('p'); | |
| 320 var labelElement = p.createChild('label'); | |
| 321 labelElement.textContent = Common.UIString('Folder exclude pattern'); | |
| 322 var inputElement = p.createChild('input'); | |
| 323 inputElement.type = 'text'; | |
| 324 inputElement.style.width = '270px'; | |
| 325 var folderExcludeSetting = Workspace.isolatedFileSystemManager.workspaceFold
erExcludePatternSetting(); | |
| 326 var setValue = | |
| 327 UI.bindInput(inputElement, folderExcludeSetting.set.bind(folderExcludeSe
tting), regexValidator, false); | |
| 328 folderExcludeSetting.addChangeListener(() => setValue.call(null, folderExclu
deSetting.get())); | |
| 329 setValue(folderExcludeSetting.get()); | |
| 330 return p; | |
| 331 | |
| 332 /** | |
| 333 * @param {string} value | |
| 334 * @return {boolean} | |
| 335 */ | |
| 336 function regexValidator(value) { | |
| 337 var regex; | |
| 338 try { | |
| 339 regex = new RegExp(value); | |
| 340 } catch (e) { | |
| 341 } | |
| 342 return !!regex; | |
| 343 } | |
| 344 } | |
| 345 | |
| 346 /** | |
| 347 * @param {!Workspace.IsolatedFileSystem} fileSystem | |
| 348 */ | |
| 349 _addItem(fileSystem) { | |
| 350 var element = this._renderFileSystem(fileSystem); | |
| 351 this._elementByPath.set(fileSystem.path(), element); | |
| 352 | |
| 353 this._fileSystemsListContainer.appendChild(element); | |
| 354 | |
| 355 var mappingView = new Settings.EditFileSystemView(fileSystem.path()); | |
| 356 this._mappingViewByPath.set(fileSystem.path(), mappingView); | |
| 357 mappingView.element.classList.add('file-system-mapping-view'); | |
| 358 mappingView.show(element); | |
| 359 } | |
| 360 | |
| 361 /** | |
| 362 * @param {!Workspace.IsolatedFileSystem} fileSystem | |
| 363 * @return {!Element} | |
| 364 */ | |
| 365 _renderFileSystem(fileSystem) { | |
| 366 var fileSystemPath = fileSystem.path(); | |
| 367 var lastIndexOfSlash = fileSystemPath.lastIndexOf(Host.isWin() ? '\\' : '/')
; | |
| 368 var folderName = fileSystemPath.substr(lastIndexOfSlash + 1); | |
| 369 | |
| 370 var element = createElementWithClass('div', 'file-system-container'); | |
| 371 var header = element.createChild('div', 'file-system-header'); | |
| 372 | |
| 373 header.createChild('div', 'file-system-name').textContent = folderName; | |
| 374 var path = header.createChild('div', 'file-system-path'); | |
| 375 path.textContent = fileSystemPath; | |
| 376 path.title = fileSystemPath; | |
| 377 | |
| 378 var toolbar = new UI.Toolbar(''); | |
| 379 var button = new UI.ToolbarButton(Common.UIString('Remove'), 'largeicon-dele
te'); | |
| 380 button.addEventListener(UI.ToolbarButton.Events.Click, this._removeFileSyste
mClicked.bind(this, fileSystem)); | |
| 381 toolbar.appendToolbarItem(button); | |
| 382 header.appendChild(toolbar.element); | |
| 383 | |
| 384 return element; | |
| 385 } | |
| 386 | |
| 387 /** | |
| 388 * @param {!Workspace.IsolatedFileSystem} fileSystem | |
| 389 */ | |
| 390 _removeFileSystemClicked(fileSystem) { | |
| 391 Workspace.isolatedFileSystemManager.removeFileSystem(fileSystem); | |
| 392 } | |
| 393 | |
| 394 _addFileSystemClicked() { | |
| 395 Workspace.isolatedFileSystemManager.addFileSystem(); | |
| 396 } | |
| 397 | |
| 398 _fileSystemAdded(event) { | |
| 399 var fileSystem = /** @type {!Workspace.IsolatedFileSystem} */ (event.data); | |
| 400 this._addItem(fileSystem); | |
| 401 } | |
| 402 | |
| 403 _fileSystemRemoved(event) { | |
| 404 var fileSystem = /** @type {!Workspace.IsolatedFileSystem} */ (event.data); | |
| 405 | |
| 406 var mappingView = this._mappingViewByPath.get(fileSystem.path()); | |
| 407 if (mappingView) { | |
| 408 mappingView.dispose(); | |
| 409 this._mappingViewByPath.delete(fileSystem.path()); | |
| 410 } | |
| 411 | |
| 412 var element = this._elementByPath.get(fileSystem.path()); | |
| 413 if (element) { | |
| 414 this._elementByPath.delete(fileSystem.path()); | |
| 415 element.remove(); | |
| 416 } | |
| 417 } | |
| 418 }; | |
| 419 | |
| 420 /** | 274 /** |
| 421 * @unrestricted | 275 * @unrestricted |
| 422 */ | 276 */ |
| 423 Settings.ExperimentsSettingsTab = class extends Settings.SettingsTab { | 277 Settings.ExperimentsSettingsTab = class extends Settings.SettingsTab { |
| 424 constructor() { | 278 constructor() { |
| 425 super(Common.UIString('Experiments'), 'experiments-tab-content'); | 279 super(Common.UIString('Experiments'), 'experiments-tab-content'); |
| 426 | 280 |
| 427 var experiments = Runtime.experiments.allConfigurableExperiments(); | 281 var experiments = Runtime.experiments.allConfigurableExperiments(); |
| 428 if (experiments.length) { | 282 if (experiments.length) { |
| 429 var experimentsSection = this._appendSection(); | 283 var experimentsSection = this._appendSection(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 return; | 398 return; |
| 545 var settings = extension.descriptor()['settings']; | 399 var settings = extension.descriptor()['settings']; |
| 546 if (settings && settings.indexOf(setting.name) !== -1) { | 400 if (settings && settings.indexOf(setting.name) !== -1) { |
| 547 InspectorFrontendHost.bringToFront(); | 401 InspectorFrontendHost.bringToFront(); |
| 548 Settings.SettingsScreen._showSettingsScreen(extension.descriptor()['id']
); | 402 Settings.SettingsScreen._showSettingsScreen(extension.descriptor()['id']
); |
| 549 success = true; | 403 success = true; |
| 550 } | 404 } |
| 551 } | 405 } |
| 552 } | 406 } |
| 553 }; | 407 }; |
| OLD | NEW |