| 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 * @implements {Sources.TabbedEditorContainerDelegate} | 5 * @implements {Sources.TabbedEditorContainerDelegate} |
| 6 * @implements {UI.Searchable} | 6 * @implements {UI.Searchable} |
| 7 * @implements {UI.Replaceable} | 7 * @implements {UI.Replaceable} |
| 8 * @unrestricted | 8 * @unrestricted |
| 9 */ | 9 */ |
| 10 Sources.SourcesView = class extends UI.VBox { | 10 Sources.SourcesView = class extends UI.VBox { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * @param {!Event} event | 65 * @param {!Event} event |
| 66 */ | 66 */ |
| 67 function handleBeforeUnload(event) { | 67 function handleBeforeUnload(event) { |
| 68 if (event.returnValue) | 68 if (event.returnValue) |
| 69 return; | 69 return; |
| 70 | 70 |
| 71 var unsavedSourceCodes = []; | 71 var unsavedSourceCodes = []; |
| 72 var projects = Workspace.workspace.projectsForType(Workspace.projectTypes.
FileSystem); | 72 var projects = Workspace.workspace.projectsForType(Workspace.projectTypes.
FileSystem); |
| 73 for (var i = 0; i < projects.length; ++i) | 73 for (var i = 0; i < projects.length; ++i) { |
| 74 unsavedSourceCodes = unsavedSourceCodes.concat(projects[i].uiSourceCodes
().filter(isUnsaved)); | 74 unsavedSourceCodes = |
| 75 unsavedSourceCodes.concat(projects[i].uiSourceCodes().filter(sourceC
ode => sourceCode.isDirty())); |
| 76 } |
| 75 | 77 |
| 76 if (!unsavedSourceCodes.length) | 78 if (!unsavedSourceCodes.length) |
| 77 return; | 79 return; |
| 78 | 80 |
| 79 event.returnValue = Common.UIString('DevTools have unsaved changes that wi
ll be permanently lost.'); | 81 event.returnValue = Common.UIString('DevTools have unsaved changes that wi
ll be permanently lost.'); |
| 80 UI.viewManager.showView('sources'); | 82 UI.viewManager.showView('sources'); |
| 81 for (var i = 0; i < unsavedSourceCodes.length; ++i) | 83 for (var i = 0; i < unsavedSourceCodes.length; ++i) |
| 82 Common.Revealer.reveal(unsavedSourceCodes[i]); | 84 Common.Revealer.reveal(unsavedSourceCodes[i]); |
| 83 | |
| 84 /** | |
| 85 * @param {!Workspace.UISourceCode} sourceCode | |
| 86 * @return {boolean} | |
| 87 */ | |
| 88 function isUnsaved(sourceCode) { | |
| 89 var binding = Persistence.persistence.binding(sourceCode); | |
| 90 if (binding) | |
| 91 return binding.network.isDirty(); | |
| 92 return sourceCode.isDirty(); | |
| 93 } | |
| 94 } | 85 } |
| 95 | 86 |
| 96 if (!window.opener) | 87 if (!window.opener) |
| 97 window.addEventListener('beforeunload', handleBeforeUnload, true); | 88 window.addEventListener('beforeunload', handleBeforeUnload, true); |
| 98 | 89 |
| 99 this._shortcuts = {}; | 90 this._shortcuts = {}; |
| 100 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal
se); | 91 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal
se); |
| 101 } | 92 } |
| 102 | 93 |
| 103 /** | 94 /** |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 * @return {boolean} | 752 * @return {boolean} |
| 762 */ | 753 */ |
| 763 handleAction(context, actionId) { | 754 handleAction(context, actionId) { |
| 764 var sourcesView = UI.context.flavor(Sources.SourcesView); | 755 var sourcesView = UI.context.flavor(Sources.SourcesView); |
| 765 if (!sourcesView) | 756 if (!sourcesView) |
| 766 return false; | 757 return false; |
| 767 sourcesView._editorContainer.closeAllFiles(); | 758 sourcesView._editorContainer.closeAllFiles(); |
| 768 return true; | 759 return true; |
| 769 } | 760 } |
| 770 }; | 761 }; |
| OLD | NEW |