| <html> | 
 | <head> | 
 | </head> | 
 |  | 
 | <embed id="pluginEmbed" type="application/x-gwt-hosted-mode" width="10" | 
 | height="10"> | 
 | </embed> | 
 |  | 
 |  | 
 | <script> | 
 | var plugin = document.getElementById('pluginEmbed'); | 
 | var disabledIcon = 'gwt32-gray.png'; | 
 | var enabledIcon = 'gwt32.png'; | 
 |  | 
 |  | 
 | function getHostFromUrl(url) { | 
 |   var hostname = ''; | 
 |   var idx = url.indexOf('://'); | 
 |   if (idx >= 0) { | 
 |     idx += 3; | 
 |     hostname = url.substring(idx); | 
 |   } | 
 |   idx = hostname.indexOf('/'); | 
 |   if (idx >= 0) { | 
 |     hostname = hostname.split('/')[0]; | 
 |   } | 
 |   idx = hostname.indexOf(':'); | 
 |   if (idx >= 0) { | 
 |     hostname = hostname.split(':')[0]; | 
 |   } | 
 |   return hostname; | 
 | } | 
 |  | 
 | function devModeTabListener(tabId, changeInfo, tab) { | 
 |   var search = tab.url.slice(tab.url.indexOf('?')); | 
 |   if (search.indexOf('gwt.codesvr=') >= 0 || search.indexOf('gwt.hosted=') >= 0) { | 
 |     var permission = plugin.getHostPermission(tab.url); | 
 |     var host = getHostFromUrl(tab.url); | 
 |     var popup = 'page_action.html'; | 
 |     var icon = null; | 
 |     console.log("got permission " + permission + " for host " + host); | 
 |  | 
 |     if (permission == 'include') { | 
 |       icon = enabledIcon; | 
 |     } else if (permission == 'exclude') { | 
 |       icon = disabledIcon; | 
 |     } else if (permission == 'unknown') { | 
 |       icon = disabledIcon; | 
 |     } | 
 |     popup += "?permission=" + permission + "&host=" + host; | 
 |     chrome.pageAction.setIcon({'tabId' : tabId, 'path' : icon}); | 
 |     chrome.pageAction.setPopup({'tabId' : tabId, 'popup' : popup}); | 
 |     chrome.pageAction.show(tabId); | 
 |  | 
 |     var hostEntries = window.localStorage.getItem('GWT_DEV_HOSTENTRY') || []; | 
 |     console.log("loading hostentries: " + hostEntries); | 
 |     plugin.loadHostEntries.apply(plugin, JSON.parse(hostEntries)); | 
 |   } else { | 
 |     chrome.pageAction.hide(tabId); | 
 |   } | 
 | }; | 
 |  | 
 | chrome.tabs.onUpdated.addListener(devModeTabListener); | 
 | </script> | 
 | </html> |