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

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

Issue 2349343002: DevTools: introduce persistence/ module (Closed)
Patch Set: DevTools: add persistence/ module 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 660ef8337440a1872046011e3ed7ef307a75da60..542fad929c7fbf4516a3d24b6fbcf59ed6cd97fc 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() || binding.persistent.isDirty();
dgozman 2016/09/22 19:55:54 Only check network.
lushnikov 2016/09/23 21:56:13 Done.
+ return sourceCode.isDirty();
+ }
}
+
if (!window.opener)
window.addEventListener("beforeunload", handleBeforeUnload, true);

Powered by Google App Engine
This is Rietveld 408576698