Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / workspace / Workspace.js
index 55ec257..8f84634 100644 (file)
@@ -228,8 +228,8 @@ WebInspector.ProjectStore.prototype = {
  */
 WebInspector.Project = function(workspace, projectId, projectDelegate)
 {
-    /** @type {!Object.<string, !{uiSourceCode: !WebInspector.UISourceCode, index: number}>} */
-    this._uiSourceCodesMap = {};
+    /** @type {!Map.<string, !{uiSourceCode: !WebInspector.UISourceCode, index: number}>} */
+    this._uiSourceCodesMap = new Map();
     /** @type {!Array.<!WebInspector.UISourceCode>} */
     this._uiSourceCodesList = [];
     this._workspace = workspace;
@@ -295,7 +295,8 @@ WebInspector.Project.prototype = {
      */
     isServiceProject: function()
     {
-        return this._projectDelegate.type() === WebInspector.projectTypes.Debugger || this._projectDelegate.type() === WebInspector.projectTypes.Formatter || this._projectDelegate.type() === WebInspector.projectTypes.LiveEdit;
+        return this._projectDelegate.type() === WebInspector.projectTypes.Debugger || this._projectDelegate.type() === WebInspector.projectTypes.Formatter || this._projectDelegate.type() === WebInspector.projectTypes.LiveEdit ||
+            this._projectDelegate.type() === WebInspector.projectTypes.Service;
     },
 
     /**
@@ -310,7 +311,7 @@ WebInspector.Project.prototype = {
 
         uiSourceCode = new WebInspector.UISourceCode(this, fileDescriptor.parentPath, fileDescriptor.name, fileDescriptor.originURL, fileDescriptor.url, fileDescriptor.contentType);
 
-        this._uiSourceCodesMap[path] = {uiSourceCode: uiSourceCode, index: this._uiSourceCodesList.length};
+        this._uiSourceCodesMap.set(path, {uiSourceCode: uiSourceCode, index: this._uiSourceCodesList.length});
         this._uiSourceCodesList.push(uiSourceCode);
         this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISourceCodeAdded, uiSourceCode);
     },
@@ -324,20 +325,20 @@ WebInspector.Project.prototype = {
         if (!uiSourceCode)
             return;
 
-        var entry = this._uiSourceCodesMap[path];
+        var entry = this._uiSourceCodesMap.get(path);
         var movedUISourceCode = this._uiSourceCodesList[this._uiSourceCodesList.length - 1];
         this._uiSourceCodesList[entry.index] = movedUISourceCode;
-        var movedEntry = this._uiSourceCodesMap[movedUISourceCode.path()];
+        var movedEntry = this._uiSourceCodesMap.get(movedUISourceCode.path());
         movedEntry.index = entry.index;
         this._uiSourceCodesList.splice(this._uiSourceCodesList.length - 1, 1);
-        delete this._uiSourceCodesMap[path];
+        this._uiSourceCodesMap.delete(path);
         this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISourceCodeRemoved, entry.uiSourceCode);
     },
 
     _remove: function()
     {
         this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectRemoved, this);
-        this._uiSourceCodesMap = {};
+        this._uiSourceCodesMap = new Map();
         this._uiSourceCodesList = [];
     },
 
@@ -355,7 +356,7 @@ WebInspector.Project.prototype = {
      */
     uiSourceCode: function(path)
     {
-        var entry = this._uiSourceCodesMap[path];
+        var entry = this._uiSourceCodesMap.get(path);
         return entry ? entry.uiSourceCode : null;
     },
 
@@ -465,8 +466,8 @@ WebInspector.Project.prototype = {
             }
             var oldPath = uiSourceCode.path();
             var newPath = uiSourceCode.parentPath() ? uiSourceCode.parentPath() + "/" + newName : newName;
-            this._uiSourceCodesMap[newPath] = this._uiSourceCodesMap[oldPath];
-            delete this._uiSourceCodesMap[oldPath];
+            this._uiSourceCodesMap.set(newPath, this._uiSourceCodesMap.get(oldPath));
+            this._uiSourceCodesMap.delete(oldPath);
             callback(true, newName, newURL, newOriginURL, newContentType);
         }
     },
@@ -567,7 +568,8 @@ WebInspector.projectTypes = {
     Network: "network",
     Snippets: "snippets",
     FileSystem: "filesystem",
-    ContentScripts: "contentscripts"
+    ContentScripts: "contentscripts",
+    Service: "service"
 }
 
 /**
@@ -598,11 +600,21 @@ WebInspector.Workspace.prototype = {
      */
     unsavedSourceCodes: function()
     {
+        /**
+         * @param {!WebInspector.UISourceCode} sourceCode
+         * @return {boolean}
+         */
         function filterUnsaved(sourceCode)
         {
             return sourceCode.isDirty();
         }
-        return this.uiSourceCodes().filter(filterUnsaved);
+
+        var unsavedSourceCodes = [];
+        var projects = this.projectsForType(WebInspector.projectTypes.FileSystem);
+        for (var i = 0; i < projects.length; ++i)
+            unsavedSourceCodes = unsavedSourceCodes.concat(projects[i].uiSourceCodes().filter(filterUnsaved));
+
+        return unsavedSourceCodes;
     },
 
     /**