| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManag
er.Events.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, th
is); | 100 WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManag
er.Events.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, th
is); |
| 101 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._onCu
rrentTargetChanged, this); | 101 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._onCu
rrentTargetChanged, this); |
| 102 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.DebuggerWasEnabled, this._debuggerWasEnabled, this
); | 102 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.DebuggerWasEnabled, this._debuggerWasEnabled, this
); |
| 103 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerReset, this); | 103 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerReset, this); |
| 104 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this); | 104 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this); |
| 105 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this); | 105 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this); |
| 106 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.CallFrameSelected, this._callFrameSelected, this); | 106 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.CallFrameSelected, this._callFrameSelected, this); |
| 107 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame, this._
consoleCommandEvaluatedInSelectedCallFrame, this); | 107 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame, this._
consoleCommandEvaluatedInSelectedCallFrame, this); |
| 108 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this); | 108 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this); |
| 109 WebInspector.targetManager.observeTargets(this); | 109 WebInspector.targetManager.observeTargets(this); |
| 110 new WebInspector.WorkspaceMappingTip(this, this._workspace); |
| 110 } | 111 } |
| 111 | 112 |
| 112 WebInspector.SourcesPanel.minToolbarWidth = 215; | 113 WebInspector.SourcesPanel.minToolbarWidth = 215; |
| 113 | 114 |
| 114 WebInspector.SourcesPanel._infobarSymbol = Symbol("infobar"); | |
| 115 | |
| 116 WebInspector.SourcesPanel.prototype = { | 115 WebInspector.SourcesPanel.prototype = { |
| 117 /** | 116 /** |
| 118 * @param {?WebInspector.Target} target | 117 * @param {?WebInspector.Target} target |
| 119 */ | 118 */ |
| 120 _setTarget: function(target) | 119 _setTarget: function(target) |
| 121 { | 120 { |
| 122 if (!target) | 121 if (!target) |
| 123 return; | 122 return; |
| 124 | 123 |
| 125 if (target.debuggerModel.isPaused()) { | 124 if (target.debuggerModel.isPaused()) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 return true; | 470 return true; |
| 472 }, | 471 }, |
| 473 | 472 |
| 474 /** | 473 /** |
| 475 * @param {!WebInspector.Event} event | 474 * @param {!WebInspector.Event} event |
| 476 */ | 475 */ |
| 477 _editorSelected: function(event) | 476 _editorSelected: function(event) |
| 478 { | 477 { |
| 479 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); | 478 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data
); |
| 480 this._editorChanged(uiSourceCode); | 479 this._editorChanged(uiSourceCode); |
| 481 if (Runtime.experiments.isEnabled("suggestUsingWorkspace")) { | |
| 482 if (this._editorSelectedTimer) | |
| 483 clearTimeout(this._editorSelectedTimer); | |
| 484 this._editorSelectedTimer = setTimeout(this._updateSuggestedMappingI
nfobar.bind(this, uiSourceCode), 3000); | |
| 485 } | |
| 486 }, | 480 }, |
| 487 | 481 |
| 488 /** | 482 /** |
| 489 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 490 */ | |
| 491 _updateSuggestedMappingInfobar: function(uiSourceCode) | |
| 492 { | |
| 493 if (!this.isShowing()) | |
| 494 return; | |
| 495 if (uiSourceCode[WebInspector.SourcesPanel._infobarSymbol]) | |
| 496 return; | |
| 497 | |
| 498 // First try mapping filesystem -> network. | |
| 499 var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode); | |
| 500 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst
em) { | |
| 501 var hasMappings = !!uiSourceCode.url; | |
| 502 if (hasMappings) | |
| 503 return; | |
| 504 | |
| 505 var targets = WebInspector.targetManager.targets(); | |
| 506 for (var i = 0; i < targets.length; ++i) | |
| 507 targets[i].resourceTreeModel.forAllResources(matchResource.bind(
this)); | |
| 508 } | |
| 509 | |
| 510 /** | |
| 511 * @param {!WebInspector.Resource} resource | |
| 512 * @return {boolean} | |
| 513 * @this {WebInspector.SourcesPanel} | |
| 514 */ | |
| 515 function matchResource(resource) | |
| 516 { | |
| 517 if (resource.contentURL().endsWith(uiSourceCode.name())) { | |
| 518 createMappingInfobar.call(this, false); | |
| 519 return true; | |
| 520 } | |
| 521 return false; | |
| 522 } | |
| 523 | |
| 524 // Then map network -> filesystem. | |
| 525 if (uiSourceCode.project().type() === WebInspector.projectTypes.Network
|| uiSourceCode.project().type() === WebInspector.projectTypes.ContentScripts) { | |
| 526 if (this._workspace.uiSourceCodeForURL(uiSourceCode.url) !== uiSourc
eCode) | |
| 527 return; | |
| 528 | |
| 529 var filesystemProjects = this._workspace.projectsForType(WebInspecto
r.projectTypes.FileSystem); | |
| 530 for (var i = 0; i < filesystemProjects.length; ++i) { | |
| 531 var name = uiSourceCode.name(); | |
| 532 var fsUiSourceCodes = filesystemProjects[i].uiSourceCodes(); | |
| 533 for (var j = 0; j < fsUiSourceCodes.length; ++j) { | |
| 534 if (fsUiSourceCodes[j].name() === name) { | |
| 535 createMappingInfobar.call(this, true); | |
| 536 return; | |
| 537 } | |
| 538 } | |
| 539 } | |
| 540 | |
| 541 // There are no matching filesystems. Suggest adding a filesystem in
case of localhost. | |
| 542 var originURL = uiSourceCode.originURL().asParsedURL(); | |
| 543 if (originURL && originURL.host === "localhost") | |
| 544 createWorkspaceInfobar(); | |
| 545 } | |
| 546 | |
| 547 /** | |
| 548 * @param {boolean} isNetwork | |
| 549 * @this {WebInspector.SourcesPanel} | |
| 550 */ | |
| 551 function createMappingInfobar(isNetwork) | |
| 552 { | |
| 553 var title; | |
| 554 if (isNetwork) | |
| 555 title = WebInspector.UIString("Map network resource '%s' to work
space?", uiSourceCode.originURL()); | |
| 556 else | |
| 557 title = WebInspector.UIString("Map workspace resource '%s' to ne
twork?", uiSourceCode.path()); | |
| 558 | |
| 559 var infobar = new WebInspector.UISourceCodeFrame.Infobar(WebInspecto
r.UISourceCodeFrame.Infobar.Level.Info, title); | |
| 560 infobar.createDetailsRowMessage(WebInspector.UIString("You can map f
iles in your workspace to the ones loaded over the network. As a result, changes
made in DevTools will be persisted to disk.")); | |
| 561 infobar.createDetailsRowMessage(WebInspector.UIString("Use context m
enu to establish the mapping at any time.")); | |
| 562 var actionLink = infobar.createDetailsRowMessage("").createChild("a"
); | |
| 563 actionLink.href = ""; | |
| 564 actionLink.onclick = establishTheMapping.bind(this); | |
| 565 actionLink.textContent = WebInspector.UIString("Establish the mappin
g now..."); | |
| 566 appendInfobar(infobar); | |
| 567 } | |
| 568 | |
| 569 /** | |
| 570 * @param {?Event} event | |
| 571 * @this {WebInspector.SourcesPanel} | |
| 572 */ | |
| 573 function establishTheMapping(event) | |
| 574 { | |
| 575 event.consume(true); | |
| 576 if (uiSourceCode.project().type() === WebInspector.projectTypes.File
System) | |
| 577 this._mapFileSystemToNetwork(uiSourceCode); | |
| 578 else | |
| 579 this._mapNetworkToFileSystem(uiSourceCode); | |
| 580 } | |
| 581 | |
| 582 function createWorkspaceInfobar() | |
| 583 { | |
| 584 var infobar = new WebInspector.UISourceCodeFrame.Infobar(WebInspecto
r.UISourceCodeFrame.Infobar.Level.Info, WebInspector.UIString("Serving from the
file system? Add your files into the workspace.")); | |
| 585 infobar.createDetailsRowMessage(WebInspector.UIString("If you add fi
les into your DevTools workspace, your changes will be persisted to disk.")); | |
| 586 infobar.createDetailsRowMessage(WebInspector.UIString("To add a fold
er into the workspace, drag and drop it into the Sources panel.")); | |
| 587 appendInfobar(infobar); | |
| 588 } | |
| 589 | |
| 590 /** | |
| 591 * @param {!WebInspector.UISourceCodeFrame.Infobar} infobar | |
| 592 */ | |
| 593 function appendInfobar(infobar) | |
| 594 { | |
| 595 infobar.createDetailsRowMessage("").createChild("br"); | |
| 596 var rowElement = infobar.createDetailsRowMessage(WebInspector.UIStri
ng("For more information on workspaces, refer to the ")); | |
| 597 var a = rowElement.createChild("a"); | |
| 598 a.textContent = "workspaces documentation"; | |
| 599 a.href = "https://developer.chrome.com/devtools/docs/workspaces"; | |
| 600 rowElement.createTextChild("."); | |
| 601 uiSourceCode[WebInspector.SourcesPanel._infobarSymbol] = infobar; | |
| 602 uiSourceCodeFrame.attachInfobars([infobar]); | |
| 603 } | |
| 604 }, | |
| 605 | |
| 606 /** | |
| 607 * @param {!WebInspector.Event} event | 483 * @param {!WebInspector.Event} event |
| 608 */ | 484 */ |
| 609 _editorClosed: function(event) | 485 _editorClosed: function(event) |
| 610 { | 486 { |
| 611 var wasSelected = /** @type {boolean} */ (event.data.wasSelected); | 487 var wasSelected = /** @type {boolean} */ (event.data.wasSelected); |
| 612 if (wasSelected) | 488 if (wasSelected) |
| 613 this._editorChanged(null); | 489 this._editorChanged(null); |
| 614 }, | 490 }, |
| 615 | 491 |
| 616 /** | 492 /** |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 | 781 |
| 906 _suggestReload: function() | 782 _suggestReload: function() |
| 907 { | 783 { |
| 908 if (window.confirm(WebInspector.UIString("It is recommended to restart i
nspector after making these changes. Would you like to restart it?"))) | 784 if (window.confirm(WebInspector.UIString("It is recommended to restart i
nspector after making these changes. Would you like to restart it?"))) |
| 909 WebInspector.reload(); | 785 WebInspector.reload(); |
| 910 }, | 786 }, |
| 911 | 787 |
| 912 /** | 788 /** |
| 913 * @param {!WebInspector.UISourceCode} uiSourceCode | 789 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 914 */ | 790 */ |
| 915 _mapFileSystemToNetwork: function(uiSourceCode) | 791 mapFileSystemToNetwork: function(uiSourceCode) |
| 916 { | 792 { |
| 917 WebInspector.SelectUISourceCodeForProjectTypesDialog.show(uiSourceCode.n
ame(), [WebInspector.projectTypes.Network, WebInspector.projectTypes.ContentScri
pts], mapFileSystemToNetwork.bind(this), this.editorView.mainElement()) | 793 WebInspector.SelectUISourceCodeForProjectTypesDialog.show(uiSourceCode.n
ame(), [WebInspector.projectTypes.Network, WebInspector.projectTypes.ContentScri
pts], mapFileSystemToNetwork.bind(this), this.editorView.mainElement()) |
| 918 | 794 |
| 919 /** | 795 /** |
| 920 * @param {!WebInspector.UISourceCode} networkUISourceCode | 796 * @param {!WebInspector.UISourceCode} networkUISourceCode |
| 921 * @this {WebInspector.SourcesPanel} | 797 * @this {WebInspector.SourcesPanel} |
| 922 */ | 798 */ |
| 923 function mapFileSystemToNetwork(networkUISourceCode) | 799 function mapFileSystemToNetwork(networkUISourceCode) |
| 924 { | 800 { |
| 925 this._workspace.addMapping(networkUISourceCode, uiSourceCode, WebIns
pector.fileSystemWorkspaceBinding); | 801 this._workspace.addMapping(networkUISourceCode, uiSourceCode, WebIns
pector.fileSystemWorkspaceBinding); |
| 926 this._suggestReload(); | 802 this._suggestReload(); |
| 927 } | 803 } |
| 928 }, | 804 }, |
| 929 | 805 |
| 930 /** | 806 /** |
| 931 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 932 */ | |
| 933 _removeNetworkMapping: function(uiSourceCode) | |
| 934 { | |
| 935 if (confirm(WebInspector.UIString("Are you sure you want to remove netwo
rk mapping?"))) { | |
| 936 this._workspace.removeMapping(uiSourceCode); | |
| 937 this._suggestReload(); | |
| 938 } | |
| 939 }, | |
| 940 | |
| 941 /** | |
| 942 * @param {!WebInspector.UISourceCode} networkUISourceCode | 807 * @param {!WebInspector.UISourceCode} networkUISourceCode |
| 943 */ | 808 */ |
| 944 _mapNetworkToFileSystem: function(networkUISourceCode) | 809 mapNetworkToFileSystem: function(networkUISourceCode) |
| 945 { | 810 { |
| 946 WebInspector.SelectUISourceCodeForProjectTypesDialog.show(networkUISourc
eCode.name(), [WebInspector.projectTypes.FileSystem], mapNetworkToFileSystem.bin
d(this), this.editorView.mainElement()) | 811 WebInspector.SelectUISourceCodeForProjectTypesDialog.show(networkUISourc
eCode.name(), [WebInspector.projectTypes.FileSystem], mapNetworkToFileSystem.bin
d(this), this.editorView.mainElement()) |
| 947 | 812 |
| 948 /** | 813 /** |
| 949 * @param {!WebInspector.UISourceCode} uiSourceCode | 814 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 950 * @this {WebInspector.SourcesPanel} | 815 * @this {WebInspector.SourcesPanel} |
| 951 */ | 816 */ |
| 952 function mapNetworkToFileSystem(uiSourceCode) | 817 function mapNetworkToFileSystem(uiSourceCode) |
| 953 { | 818 { |
| 954 this._workspace.addMapping(networkUISourceCode, uiSourceCode, WebIns
pector.fileSystemWorkspaceBinding); | 819 this._workspace.addMapping(networkUISourceCode, uiSourceCode, WebIns
pector.fileSystemWorkspaceBinding); |
| 955 this._suggestReload(); | 820 this._suggestReload(); |
| 956 } | 821 } |
| 957 }, | 822 }, |
| 958 | 823 |
| 959 /** | 824 /** |
| 825 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 826 */ |
| 827 _removeNetworkMapping: function(uiSourceCode) |
| 828 { |
| 829 if (confirm(WebInspector.UIString("Are you sure you want to remove netwo
rk mapping?"))) { |
| 830 this._workspace.removeMapping(uiSourceCode); |
| 831 this._suggestReload(); |
| 832 } |
| 833 }, |
| 834 |
| 835 /** |
| 960 * @param {!WebInspector.ContextMenu} contextMenu | 836 * @param {!WebInspector.ContextMenu} contextMenu |
| 961 * @param {!WebInspector.UISourceCode} uiSourceCode | 837 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 962 */ | 838 */ |
| 963 _appendUISourceCodeMappingItems: function(contextMenu, uiSourceCode) | 839 _appendUISourceCodeMappingItems: function(contextMenu, uiSourceCode) |
| 964 { | 840 { |
| 965 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst
em) { | 841 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst
em) { |
| 966 var hasMappings = !!uiSourceCode.url; | 842 var hasMappings = !!uiSourceCode.url; |
| 967 if (!hasMappings) | 843 if (!hasMappings) |
| 968 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLow
erCaseMenuTitles() ? "Map to network resource\u2026" : "Map to Network Resource\
u2026"), this._mapFileSystemToNetwork.bind(this, uiSourceCode)); | 844 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLow
erCaseMenuTitles() ? "Map to network resource\u2026" : "Map to Network Resource\
u2026"), this.mapFileSystemToNetwork.bind(this, uiSourceCode)); |
| 969 else | 845 else |
| 970 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLow
erCaseMenuTitles() ? "Remove network mapping" : "Remove Network Mapping"), this.
_removeNetworkMapping.bind(this, uiSourceCode)); | 846 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLow
erCaseMenuTitles() ? "Remove network mapping" : "Remove Network Mapping"), this.
_removeNetworkMapping.bind(this, uiSourceCode)); |
| 971 } | 847 } |
| 972 | 848 |
| 973 /** | 849 /** |
| 974 * @param {!WebInspector.Project} project | 850 * @param {!WebInspector.Project} project |
| 975 */ | 851 */ |
| 976 function filterProject(project) | 852 function filterProject(project) |
| 977 { | 853 { |
| 978 return project.type() === WebInspector.projectTypes.FileSystem; | 854 return project.type() === WebInspector.projectTypes.FileSystem; |
| 979 } | 855 } |
| 980 | 856 |
| 981 if (uiSourceCode.project().type() === WebInspector.projectTypes.Network
|| uiSourceCode.project().type() === WebInspector.projectTypes.ContentScripts) { | 857 if (uiSourceCode.project().type() === WebInspector.projectTypes.Network
|| uiSourceCode.project().type() === WebInspector.projectTypes.ContentScripts) { |
| 982 if (!this._workspace.projects().filter(filterProject).length) | 858 if (!this._workspace.projects().filter(filterProject).length) |
| 983 return; | 859 return; |
| 984 if (this._workspace.uiSourceCodeForURL(uiSourceCode.url) === uiSourc
eCode) | 860 if (this._workspace.uiSourceCodeForURL(uiSourceCode.url) === uiSourc
eCode) |
| 985 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLow
erCaseMenuTitles() ? "Map to file system resource\u2026" : "Map to File System R
esource\u2026"), this._mapNetworkToFileSystem.bind(this, uiSourceCode)); | 861 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLow
erCaseMenuTitles() ? "Map to file system resource\u2026" : "Map to File System R
esource\u2026"), this.mapNetworkToFileSystem.bind(this, uiSourceCode)); |
| 986 } | 862 } |
| 987 }, | 863 }, |
| 988 | 864 |
| 989 /** | 865 /** |
| 990 * @param {!Event} event | 866 * @param {!Event} event |
| 991 * @param {!WebInspector.ContextMenu} contextMenu | 867 * @param {!WebInspector.ContextMenu} contextMenu |
| 992 * @param {!Object} target | 868 * @param {!Object} target |
| 993 */ | 869 */ |
| 994 _appendUISourceCodeItems: function(event, contextMenu, target) | 870 _appendUISourceCodeItems: function(event, contextMenu, target) |
| 995 { | 871 { |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 | 1404 |
| 1529 WebInspector.SourcesPanelFactory.prototype = { | 1405 WebInspector.SourcesPanelFactory.prototype = { |
| 1530 /** | 1406 /** |
| 1531 * @return {!WebInspector.Panel} | 1407 * @return {!WebInspector.Panel} |
| 1532 */ | 1408 */ |
| 1533 createPanel: function() | 1409 createPanel: function() |
| 1534 { | 1410 { |
| 1535 return WebInspector.SourcesPanel.instance(); | 1411 return WebInspector.SourcesPanel.instance(); |
| 1536 } | 1412 } |
| 1537 } | 1413 } |
| OLD | NEW |