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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sources/SourcesView.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/SourcesView.js b/third_party/WebKit/Source/devtools/front_end/sources/SourcesView.js
index 21ee1c4e428476da7854038d60fb4c298a4f892d..e43f951020befc6e56afef9e54c20d9062f0fbf0 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/SourcesView.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/SourcesView.js
@@ -57,11 +57,19 @@ WebInspector.SourcesView = function()
workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this);
workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemoved, this._projectRemoved.bind(this), this);
+ /**
+ * @param {!Event} event
+ */
function handleBeforeUnload(event)
{
if (event.returnValue)
return;
- var unsavedSourceCodes = WebInspector.workspace.unsavedSourceCodes();
+
+ var unsavedSourceCodes = [];
+ var projects = WebInspector.workspace.projectsForType(WebInspector.projectTypes.FileSystem);
+ for (var i = 0; i < projects.length; ++i)
+ unsavedSourceCodes = unsavedSourceCodes.concat(projects[i].uiSourceCodes().filter(isUnsaved));
+
if (!unsavedSourceCodes.length)
return;
@@ -69,7 +77,20 @@ WebInspector.SourcesView = function()
WebInspector.inspectorView.setCurrentPanel(WebInspector.SourcesPanel.instance());
for (var i = 0; i < unsavedSourceCodes.length; ++i)
WebInspector.Revealer.reveal(unsavedSourceCodes[i]);
+
+ /**
+ * @param {!WebInspector.UISourceCode} sourceCode
+ * @return {boolean}
+ */
+ function isUnsaved(sourceCode)
+ {
+ var binding = WebInspector.persistence.binding(sourceCode);
+ if (binding)
+ return binding.network.isDirty();
+ return sourceCode.isDirty();
+ }
}
+
if (!window.opener)
window.addEventListener("beforeunload", handleBeforeUnload, true);

Powered by Google App Engine
This is Rietveld 408576698