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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/SourcesView.js

Issue 2349343002: DevTools: introduce persistence/ module (Closed)
Patch Set: reupload Created 4 years, 3 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 // 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
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();
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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 */ 813 */
793 handleAction: function(context, actionId) 814 handleAction: function(context, actionId)
794 { 815 {
795 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView); 816 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView);
796 if (!sourcesView) 817 if (!sourcesView)
797 return false; 818 return false;
798 sourcesView._editorContainer.closeAllFiles(); 819 sourcesView._editorContainer.closeAllFiles();
799 return true; 820 return true;
800 } 821 }
801 } 822 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698