diff --git a/background.js b/background.js index d15c663..dfcc120 100644 --- a/background.js +++ b/background.js @@ -166,6 +166,14 @@ chrome.tabs.onAttached.addListener(function(tabId,objects){ } }); +chrome.runtime.onMessage.addListener(function(response){ + if (response.hasOwnProperty('nameChange')){ + var currentWindow = findWindowById(response.nameChange.windowId); + currentWindow.window.name = response.nameChange.name; + saveWindows(); + } +}); + //init chrome.storage.local.get('windows',function(result){ console.log(result); @@ -176,4 +184,4 @@ clearStorage(function(){ createWindowStorage(function(){ populateWindowStorage(); }); -}); \ No newline at end of file +}); diff --git a/popup.js b/popup.js index 20b94c1..a659267 100644 --- a/popup.js +++ b/popup.js @@ -15,6 +15,7 @@ function changeWindowName(windowId,newName,callback){ if (changedWindow.length===1){ changedWindow[0].name = newName; chrome.storage.local.set({"windows":windows},callback); + chrome.runtime.sendMessage({'nameChange':{'windowId':windowId,'name':newName}}); } else{ throw "More than one window has the id "+windowId+". This should never happen."