Commits

Anonymous committed 7abbd65

Fixs issue #27

Comments (0)

Files changed (3)

BackgroundMsgSupport.js

 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
-* 
+*
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
-* 
+*
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
-
 var backgroundMsgSupport = {
 	launchFolderSelect : function(index, url,  callback){
-		chrome.extension.sendRequest({key: 'launchFolderSelect', index: index, url: url}, callback);
+		chrome.extension.sendMessage({key: 'launchFolderSelect', index: index, url: url, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	launchFileSelect : function(url, op, callback){
-		chrome.extension.sendRequest({key: 'launchFileSelect', url: url, op: op}, callback);
+		chrome.extension.sendMessage({key: 'launchFileSelect', url: url, op: op, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	getProjectTypes : function(callback){
-		chrome.extension.sendRequest({key : 'ProjectTypes'}, callback);
+		chrome.extension.sendMessage({key : 'ProjectTypes', tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	checkResources : function(resources, callback){
-		chrome.extension.sendRequest({key : 'checkResources', resources: resources}, callback);
+		chrome.extension.sendMessage({key : 'checkResources', resources: resources, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	checkResourceContent : function(url, content, callback){
-		chrome.extension.sendRequest({key : 'checkResourceContent', url: url, content:content}, callback);
+		chrome.extension.sendMessage({key : 'checkResourceContent', url: url, content:content, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	updateResource : function(url, content, callback){
-		chrome.extension.sendRequest({key : 'updateResource', url: url, content:content}, callback);
+		chrome.extension.sendMessage({key : 'updateResource', url: url, content:content, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	pageChanged : function(callback){
-		chrome.extension.sendRequest({key: 'pageChanged'}, callback);
+		chrome.extension.sendMessage({key: 'pageChanged', tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	unwatchDirectory : function(callback){
-		chrome.extension.sendRequest({key: 'unwatchDirectory'}, callback); 
+		chrome.extension.sendMessage({key: 'unwatchDirectory', tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	loadProject : function(type, path, url, urlPathMap, callback){
-		chrome.extension.sendRequest({key: 'loadProject', type: type, path: path, url: url, urlPathMap: urlPathMap}, callback);
+		chrome.extension.sendMessage({key: 'loadProject', type: type, path: path, url: url, urlPathMap: urlPathMap, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	setResourceOptions : function(url, exactMatch, callback){
-		chrome.extension.sendRequest({key: 'setResourceOptions', url: url, exactMatch: exactMatch}, callback);
+		chrome.extension.sendMessage({key: 'setResourceOptions', url: url, exactMatch: exactMatch, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	removeDependency : function(url, index, callback){
-		chrome.extension.sendRequest({key: 'removeDependency', url: url, index: index}, callback);
+		chrome.extension.sendMessage({key: 'removeDependency', url: url, index: index, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	setCustomPathData : function(url, data, callback){
-		chrome.extension.sendRequest({key: 'setCustomPathData', url:url, data: data}, callback);
+		chrome.extension.sendMessage({key: 'setCustomPathData', url:url, data: data, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	clearResource : function(url, callback){
-		chrome.extension.sendRequest({key: 'clearResource', url:url}, callback);
+		chrome.extension.sendMessage({key: 'clearResource', url:url, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	getPreference : function(prefKey, callback){
-		chrome.extension.sendRequest({key:'getPreference', prefKey: prefKey}, callback);
+		chrome.extension.sendMessage({key:'getPreference', prefKey: prefKey, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	},
 	setPreference : function(prefObj, callback){
-		chrome.extension.sendRequest({key: 'setPreference', prefObj: prefObj}, callback);
+		chrome.extension.sendMessage({key: 'setPreference', prefObj: prefObj, tabId : chrome.devtools.inspectedWindow.tabId}, callback);
 	}
 }
 $.ajaxSettings.accepts.text = "*/*"
 var projectManager = new ProjectManager();
-chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
-    
-    if (request.key == 'ProjectTypes'){
+chrome.extension.onMessage.addListener(function(message, sender, sendResponse) {
+
+
+    if (message.key == 'ProjectTypes'){
         //var cleanResponse = [];
         //for (var i = 0; i < ProjectTypes.length){
         //  cleanResponse.push({name: ProjectTypes[i].name, locationType: ProjectTypes[i].locationType});
         //}
         sendResponse(ProjectTypes);
     }
-    else if (request.key == 'launchFolderSelect'){
-        projectManager.launchFolderSelect(sender.tab.id, request.url, request.index, sendResponse);
+    else if (message.key == 'launchFolderSelect'){
+        projectManager.launchFolderSelect(message.tabId, message.url, message.index, sendResponse);
     }
-    else if (request.key == 'launchFileSelect'){
-        projectManager.launchFileSelect(sender.tab.id, request.url, request.op, sendResponse);
+    else if (message.key == 'launchFileSelect'){
+        projectManager.launchFileSelect(message.tabId, message.url, message.op, sendResponse);
     }
-    else if (request.key == 'checkResources'){
-        projectManager.checkResources(sender.tab.id, request.resources, sendResponse);
+    else if (message.key == 'checkResources'){
+        projectManager.checkResources(message.tabId, message.resources, sendResponse);
     }
-    else if (request.key == 'checkResourceContent'){
-        projectManager.checkResourceContent(sender.tab.id, request.url, request.content, sendResponse);
+    else if (message.key == 'checkResourceContent'){
+        projectManager.checkResourceContent(message.tabId, message.url, message.content, sendResponse);
     }
-    else if (request.key == 'updateResource'){
-        projectManager.updateResource(sender.tab.id, request.url, request.content, sendResponse);
+    else if (message.key == 'updateResource'){
+        projectManager.updateResource(message.tabId, message.url, message.content, sendResponse);
     }
-    else if (request.key == 'pageChanged'){
-        projectManager.resetProject(sender.tab.id, sendResponse);
+    else if (message.key == 'pageChanged'){
+        projectManager.resetProject(message.tabId, sendResponse);
     }
-    else if (request.key == 'loadProject'){
-        projectManager.loadProject(sender.tab.id, request.type, request.path, request.url, request.urlPathMap, sendResponse);
+    else if (message.key == 'loadProject'){
+        projectManager.loadProject(message.tabId, message.type, message.path, message.url, message.urlPathMap, sendResponse);
     }
-    else if (request.key == 'unwatchDirectory'){
-        projectManager.unwatchDirectory(sender.tab.id, sendResponse);
+    else if (message.key == 'unwatchDirectory'){
+        projectManager.unwatchDirectory(message.tabId, sendResponse);
     }
-    else if (request.key == 'setResourceOptions'){
-        projectManager.setResourceOptions(sender.tab.id, request.url, request.exactMatch, sendResponse);
+    else if (message.key == 'setResourceOptions'){
+        projectManager.setResourceOptions(message.tabId, message.url, message.exactMatch, sendResponse);
     }
-    else if (request.key == 'removeDependency'){
-        projectManager.removeDependency(sender.tab.id, request.url, Number(request.index), sendResponse);
+    else if (message.key == 'removeDependency'){
+        projectManager.removeDependency(message.tabId, message.url, Number(message.index), sendResponse);
     }
-    else if (request.key == 'setCustomPathData'){
-        projectManager.setCustomPathData(sender.tab.id, request.url, request.data, sendResponse);
+    else if (message.key == 'setCustomPathData'){
+        projectManager.setCustomPathData(message.tabId, message.url, message.data, sendResponse);
     }
-    else if (request.key == 'clearResource'){
-        projectManager.clearResource(sender.tab.id, request.url, sendResponse);
+    else if (message.key == 'clearResource'){
+        projectManager.clearResource(message.tabId, message.url, sendResponse);
     }
-    else if (request.key == 'getPreference'){
-        chrome.storage.local.get(request.prefKey, sendResponse);
+    else if (message.key == 'getPreference'){
+        chrome.storage.local.get(message.prefKey, sendResponse);
     }
-    else if (request.key == 'setPreference'){
-        chrome.storage.local.set(request.prefObj, sendResponse);
+    else if (message.key == 'setPreference'){
+        chrome.storage.local.set(message.prefObj, sendResponse);
     }
     else{
         sendResponse({});
     }
-    
+
+  return true;
+
 });
 chrome.extension.onConnect.addListener(function(port){
     projectManager.watchDirectory(port);
   "background": {"page" :"background.html"},
   "icons": {"48": "tools_small.png",
             "128": "tools.png" },
-  "permissions": ["http://*/", "https://*/", "storage"],
+  "permissions": ["http://*/", "https://*/", "storage", "tabs"],
   "plugins": [
     { "path": "NPAPIFileIOforChrome.plugin", "public": false },
     { "path": "npNPAPIFileIOforChrome.dll", "public": false },
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.