title: Change chrome extension icon when tab or url changes
body: <p>I'm working on an extension and I want the icon to change when the active tab or url changes. Here's what i have so far:</p>
  
  <p>manifest.json</p>
  
  <pre><code>{
    "manifest_version": 2,
  
    "name": "Link2QR",
    "description": "chrome_extension",
    "version": "1.0",
  
    "browser_action": {     
      "default_icon":"icon.png",    
      "default_popup": "popup.html"
     },
  
    "permissions": [
    "activeTab",
    "https://ajax.googleapis.com/",
    "tabs"
     ],
  
   "content_scripts": [
    {
      "matches": ["&lt;all_urls&gt;"],
      "js": ["content.js"]
     }
   ]
  }
  </code></pre>
  
  <p>content.js</p>
  
  <pre><code>if(onSupportedPageNeedChangeIcon) {
      chrome.runtime.sendMessage({ "newIconPath" : "testimage.png" });
  }
  </code></pre>
  
  <p>popup.js</p>
  
  <pre><code>chrome.runtime.onMessage.addListener(
     function(request, sender, sendResponse) {
     chrome.browserAction.setIcon({
         path: request.newIconPath,
         tabId: sender.tab.id
     });
  });
  </code></pre>