Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @implements {WebInspector.TabbedEditorContainerDelegate} | 7 * @implements {WebInspector.TabbedEditorContainerDelegate} |
| 8 * @implements {WebInspector.Searchable} | 8 * @implements {WebInspector.Searchable} |
| 9 * @implements {WebInspector.Replaceable} | 9 * @implements {WebInspector.Replaceable} |
| 10 * @extends {WebInspector.VBox} | 10 * @extends {WebInspector.VBox} |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 this._scriptViewToolbar = new WebInspector.Toolbar("", this._toolbarContaine rElement); | 50 this._scriptViewToolbar = new WebInspector.Toolbar("", this._toolbarContaine rElement); |
| 51 | 51 |
| 52 WebInspector.startBatchUpdate(); | 52 WebInspector.startBatchUpdate(); |
| 53 workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); | 53 workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); |
| 54 WebInspector.endBatchUpdate(); | 54 WebInspector.endBatchUpdate(); |
| 55 | 55 |
| 56 workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this); | 56 workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this); |
| 57 workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved , this._uiSourceCodeRemoved, this); | 57 workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved , this._uiSourceCodeRemoved, this); |
| 58 workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemoved, thi s._projectRemoved.bind(this), this); | 58 workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemoved, thi s._projectRemoved.bind(this), this); |
| 59 | 59 |
| 60 /** | |
| 61 * @param {!Event} event | |
| 62 */ | |
| 60 function handleBeforeUnload(event) | 63 function handleBeforeUnload(event) |
| 61 { | 64 { |
| 62 if (event.returnValue) | 65 if (event.returnValue) |
| 63 return; | 66 return; |
| 64 var unsavedSourceCodes = WebInspector.workspace.unsavedSourceCodes(); | 67 |
| 68 var unsavedSourceCodes = []; | |
| 69 var projects = WebInspector.workspace.projectsForType(WebInspector.proje ctTypes.FileSystem); | |
| 70 for (var i = 0; i < projects.length; ++i) | |
| 71 unsavedSourceCodes = unsavedSourceCodes.concat(projects[i].uiSourceC odes().filter(isUnsaved)); | |
| 72 | |
| 65 if (!unsavedSourceCodes.length) | 73 if (!unsavedSourceCodes.length) |
| 66 return; | 74 return; |
| 67 | 75 |
| 68 event.returnValue = WebInspector.UIString("DevTools have unsaved changes that will be permanently lost."); | 76 event.returnValue = WebInspector.UIString("DevTools have unsaved changes that will be permanently lost."); |
| 69 WebInspector.inspectorView.setCurrentPanel(WebInspector.SourcesPanel.ins tance()); | 77 WebInspector.inspectorView.setCurrentPanel(WebInspector.SourcesPanel.ins tance()); |
| 70 for (var i = 0; i < unsavedSourceCodes.length; ++i) | 78 for (var i = 0; i < unsavedSourceCodes.length; ++i) |
| 71 WebInspector.Revealer.reveal(unsavedSourceCodes[i]); | 79 WebInspector.Revealer.reveal(unsavedSourceCodes[i]); |
| 80 | |
| 81 /** | |
| 82 * @param {!WebInspector.UISourceCode} sourceCode | |
| 83 * @return {boolean} | |
| 84 */ | |
| 85 function isUnsaved(sourceCode) | |
| 86 { | |
| 87 var binding = WebInspector.persistence.binding(sourceCode); | |
| 88 if (binding) | |
| 89 return binding.network.isDirty() || binding.persistent.isDirty() ; | |
|
dgozman
2016/09/22 19:55:54
Only check network.
lushnikov
2016/09/23 21:56:13
Done.
| |
| 90 return sourceCode.isDirty(); | |
| 91 } | |
| 72 } | 92 } |
| 93 | |
| 73 if (!window.opener) | 94 if (!window.opener) |
| 74 window.addEventListener("beforeunload", handleBeforeUnload, true); | 95 window.addEventListener("beforeunload", handleBeforeUnload, true); |
| 75 | 96 |
| 76 this._shortcuts = {}; | 97 this._shortcuts = {}; |
| 77 this.element.addEventListener("keydown", this._handleKeyDown.bind(this), fal se); | 98 this.element.addEventListener("keydown", this._handleKeyDown.bind(this), fal se); |
| 78 } | 99 } |
| 79 | 100 |
| 80 /** @enum {symbol} */ | 101 /** @enum {symbol} */ |
| 81 WebInspector.SourcesView.Events = { | 102 WebInspector.SourcesView.Events = { |
| 82 EditorClosed: Symbol("EditorClosed"), | 103 EditorClosed: Symbol("EditorClosed"), |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 */ | 797 */ |
| 777 handleAction: function(context, actionId) | 798 handleAction: function(context, actionId) |
| 778 { | 799 { |
| 779 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView); | 800 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView); |
| 780 if (!sourcesView) | 801 if (!sourcesView) |
| 781 return false; | 802 return false; |
| 782 sourcesView._editorContainer.closeAllFiles(); | 803 sourcesView._editorContainer.closeAllFiles(); |
| 783 return true; | 804 return true; |
| 784 } | 805 } |
| 785 } | 806 } |
| OLD | NEW |