Upgraded the devmode Chrome extension to manifest version 2.

To do this, we need to replace all inline javascript with code in a separate js file. Also, changed the options page to use the DirectInstall linker so that GWT bootstrap doesn't use eval() or inline javascript.

Also, recompiled the Linux binaries. Not tested on other platforms yet.

For more about manifest version 2, see:
http://developer.chrome.com/extensions/manifestVersion.html

Review at http://gwt-code-reviews.appspot.com/1840803


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@11305 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/config.mk b/config.mk
index 1e9e244..db7ffff 100644
--- a/config.mk
+++ b/config.mk
@@ -85,6 +85,7 @@
 BASECFLAGS= $(DEBUGCFLAGS) -O2 -fPIC $(INC) -rdynamic
 ARCHCFLAGS= -m$(FLAG32BIT)
 ALLARCHCFLAGS= -m$(FLAG32BIT)
+#CXX=clang # for better build error messages
 endif
 ifeq ($(shell uname),Darwin)
 OS=mac
diff --git a/npapi/DevModeOptions/build.xml b/npapi/DevModeOptions/build.xml
index 53d9900..d24a181 100644
--- a/npapi/DevModeOptions/build.xml
+++ b/npapi/DevModeOptions/build.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <project name="DevModeOptions" default="prebuilt" basedir=".">
   <!-- Arguments to gwtc and devmode targets -->
-  <property name="gwt.args" value="" />
+  <property name="gwt.args" value="-style PRETTY" />
 
   <!-- Configure path to GWT SDK -->
   <property name="gwt.sdk" location="../../../build/staging/gwt-0.0.0" />
diff --git a/npapi/DevModeOptions/java/com/google/gwt/devmodeoptions/DevModeOptions.google.xml b/npapi/DevModeOptions/java/com/google/gwt/devmodeoptions/DevModeOptions.google.xml
index 338e4a9..547834c 100644
--- a/npapi/DevModeOptions/java/com/google/gwt/devmodeoptions/DevModeOptions.google.xml
+++ b/npapi/DevModeOptions/java/com/google/gwt/devmodeoptions/DevModeOptions.google.xml
@@ -1,4 +1,4 @@
 <!-- A fragment of DevModeOptions.gwt.xml used by the Google build.
      This should be kept in sync with DevModeOptions.gwt.xml. -->
 <set-property name='user.agent' value='safari' />
-<add-linker name="xsiframe" />
+<add-linker name="direct_install" />
diff --git a/npapi/DevModeOptions/java/com/google/gwt/devmodeoptions/DevModeOptions.gwt.xml b/npapi/DevModeOptions/java/com/google/gwt/devmodeoptions/DevModeOptions.gwt.xml
index da92655..6fa77fd 100644
--- a/npapi/DevModeOptions/java/com/google/gwt/devmodeoptions/DevModeOptions.gwt.xml
+++ b/npapi/DevModeOptions/java/com/google/gwt/devmodeoptions/DevModeOptions.gwt.xml
@@ -12,5 +12,5 @@
 
 <!-- The rest should be kept in sync with DevModeOptions.google.xml -->
   <set-property name='user.agent' value='safari' />
-  <add-linker name="xsiframe" />
+  <add-linker name="direct_install" />
 </module>
diff --git a/npapi/manifest-template.json b/npapi/manifest-template.json
index 9c6a1b8..91677a8 100644
--- a/npapi/manifest-template.json
+++ b/npapi/manifest-template.json
@@ -1,6 +1,8 @@
 {
   "name": "GWT Developer Plugin",
   "version": "GWT_DEV_PLUGIN_VERSION",
+  "manifest_version": 2,
+
   "description": "A plugin to enable debugging with GWT's Development Mode",
   "update_url": "https://dl-ssl.google.com/gwt/plugins/chrome/updates.xml",
   "icons": {
@@ -10,8 +12,11 @@
     "64": "gwt64.png",
     "128": "gwt128.png"
   },
+
   "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDi6RrEy9YllRLM8bGBcIEk5ECAG2z+8ngTz7wwzRAQJpOzDp1Alq8fQFjH0+dzxok4RFLrWKHjxGqvXzWyWyTEo2nY3ScHLN/RoANMs8pl9X6TygRyO+3naqZOtLCrYHfV49JKXnYoFVbY5eBVYxHYY3BHAOKJj9onyAM4UPmMzQIDAQAB",
-  "background_page": "background.html",
+  "background": {
+     "page": "background.html"
+   },
   "options_page" : "DevModeOptions.html",
   "page_action" : {
     "default_icon" : "gwt32.png",
diff --git a/npapi/prebuilt/gwt-dev-plugin/Linux_x86-gcc3/libGwtDevPlugin.so b/npapi/prebuilt/gwt-dev-plugin/Linux_x86-gcc3/libGwtDevPlugin.so
index a25d124..9c39145 100755
--- a/npapi/prebuilt/gwt-dev-plugin/Linux_x86-gcc3/libGwtDevPlugin.so
+++ b/npapi/prebuilt/gwt-dev-plugin/Linux_x86-gcc3/libGwtDevPlugin.so
Binary files differ
diff --git a/npapi/prebuilt/gwt-dev-plugin/Linux_x86_64-gcc3/libGwtDevPlugin.so b/npapi/prebuilt/gwt-dev-plugin/Linux_x86_64-gcc3/libGwtDevPlugin.so
index c0e4546..4ec8b6d 100755
--- a/npapi/prebuilt/gwt-dev-plugin/Linux_x86_64-gcc3/libGwtDevPlugin.so
+++ b/npapi/prebuilt/gwt-dev-plugin/Linux_x86_64-gcc3/libGwtDevPlugin.so
Binary files differ
diff --git a/npapi/prebuilt/gwt-dev-plugin/background.html b/npapi/prebuilt/gwt-dev-plugin/background.html
index 73f674d..4f14a8c 100644
--- a/npapi/prebuilt/gwt-dev-plugin/background.html
+++ b/npapi/prebuilt/gwt-dev-plugin/background.html
@@ -6,88 +6,5 @@
 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.substring(0,idx);
-  }
-  idx = hostname.indexOf('@');
-  if( idx >= 0)
-  {
-    hostname = hostname.substring(idx+1);
-  }
-  idx = hostname.indexOf(':');
-  if (idx >= 0) {
-    hostname = hostname.substring(0,idx);
-  }
-  return hostname;
-}
-
-function getCodeServerFromUrl(url) {
-  var idx = url.indexOf('?');
-  if (idx < 0) {
-    return '';
-  }
-  url = url.substring(idx+1);
-  idx = url.indexOf('gwt.codesvr=');
-  if( idx < 0 ) {
-    return '';
-  }
-  url = url.substring(idx+12);
-  var colon = url.indexOf(':');
-  var amp   = url.indexOf('&');
-  if( amp < 0 || colon < amp ) {
-    amp = colon;
-  }
-  return amp < 0 ? url : url.substring(0,amp);
-}
-
-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 code = getCodeServerFromUrl(tab.url);
-    var popup = 'page_action.html';
-    var icon = null;
-    console.log("got permission " + permission + " for host " + host + '/ code ' + code);
-
-    var idObject = {};
-    plugin.testJsIdentity( idObject, idObject );
-
-    if (permission == 'include') {
-      icon = enabledIcon;
-    } else if (permission == 'exclude') {
-      icon = disabledIcon;
-    } else if (permission == 'unknown') {
-      icon = disabledIcon;
-    }
-    popup += "?permission=" + permission + "&host=" + host + "&codeserver=" + code;
-    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>
+<script src="background.js"></script>
 </html>
diff --git a/npapi/prebuilt/gwt-dev-plugin/background.js b/npapi/prebuilt/gwt-dev-plugin/background.js
new file mode 100644
index 0000000..c9908a3
--- /dev/null
+++ b/npapi/prebuilt/gwt-dev-plugin/background.js
@@ -0,0 +1,81 @@
+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.substring(0,idx);
+  }
+  idx = hostname.indexOf('@');
+  if( idx >= 0)
+  {
+    hostname = hostname.substring(idx+1);
+  }
+  idx = hostname.indexOf(':');
+  if (idx >= 0) {
+    hostname = hostname.substring(0,idx);
+  }
+  return hostname;
+}
+
+function getCodeServerFromUrl(url) {
+  var idx = url.indexOf('?');
+  if (idx < 0) {
+    return '';
+  }
+  url = url.substring(idx+1);
+  idx = url.indexOf('gwt.codesvr=');
+  if( idx < 0 ) {
+    return '';
+  }
+  url = url.substring(idx+12);
+  var colon = url.indexOf(':');
+  var amp   = url.indexOf('&');
+  if( amp < 0 || colon < amp ) {
+    amp = colon;
+  }
+  return amp < 0 ? url : url.substring(0,amp);
+}
+
+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 code = getCodeServerFromUrl(tab.url);
+    var popup = 'page_action.html';
+    var icon = null;
+    console.log("got permission " + permission + " for host " + host + '/ code ' + code);
+
+    var idObject = {};
+    plugin.testJsIdentity( idObject, idObject );
+
+    if (permission == 'include') {
+      icon = enabledIcon;
+    } else if (permission == 'exclude') {
+      icon = disabledIcon;
+    } else if (permission == 'unknown') {
+      icon = disabledIcon;
+    }
+    popup += "?permission=" + permission + "&host=" + host + "&codeserver=" + code;
+    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);
diff --git a/npapi/prebuilt/gwt-dev-plugin/manifest.json b/npapi/prebuilt/gwt-dev-plugin/manifest.json
index a60ccf8..53a6a1a 100644
--- a/npapi/prebuilt/gwt-dev-plugin/manifest.json
+++ b/npapi/prebuilt/gwt-dev-plugin/manifest.json
@@ -1,6 +1,8 @@
 {
   "name": "GWT Developer Plugin",
-  "version": "1.0.10242",
+  "version": "1.0.11303",
+  "manifest_version": 2,
+
   "description": "A plugin to enable debugging with GWT's Development Mode",
   "update_url": "https://dl-ssl.google.com/gwt/plugins/chrome/updates.xml",
   "icons": {
@@ -10,8 +12,11 @@
     "64": "gwt64.png",
     "128": "gwt128.png"
   },
+
   "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDi6RrEy9YllRLM8bGBcIEk5ECAG2z+8ngTz7wwzRAQJpOzDp1Alq8fQFjH0+dzxok4RFLrWKHjxGqvXzWyWyTEo2nY3ScHLN/RoANMs8pl9X6TygRyO+3naqZOtLCrYHfV49JKXnYoFVbY5eBVYxHYY3BHAOKJj9onyAM4UPmMzQIDAQAB",
-  "background_page": "background.html",
+  "background": {
+     "page": "background.html"
+   },
   "options_page" : "DevModeOptions.html",
   "page_action" : {
     "default_icon" : "gwt32.png",
diff --git a/npapi/prebuilt/gwt-dev-plugin/page_action.html b/npapi/prebuilt/gwt-dev-plugin/page_action.html
index 4094828..eeaf556 100644
--- a/npapi/prebuilt/gwt-dev-plugin/page_action.html
+++ b/npapi/prebuilt/gwt-dev-plugin/page_action.html
@@ -4,45 +4,12 @@
       width: 20em;
     }
   </style>
-  <script>
-    function getParam(key) {
-      var idx = window.location.search.indexOf(key + "=");
-      var value = '';
-      if (idx >= 0) {
-        idx += key.length + 1;
-        value = window.location.search.substring(idx).split('&')[0];
-      }
-      return value;
-    }
-
-    function init() {
-      var permission = getParam('permission');
-      var host = getParam('host');
-      var code = getParam('codeserver');
-      var message='';
-
-      if (permission == 'include') {
-        message = 'The web and code server (' + host + '/' + code + ') is allowed to use the plugin';
-      } else if (permission == 'exclude') {
-        message = 'The web and code server (' + host + '/' + code + ') has been been blacklisted.';
-      } else if (permission == 'unknown') {
-        message = 'The web and code server (' + host + '/' + code + ') is unknown to the plugin.';
-      }
-
-      document.getElementById('message').innerText = message;
-    }
-
-    function updateConfiguration() {
-      var url = 'DevModeOptions.html?host=' + getParam('host') + '&codeserver=' + getParam('codeserver');
-      url = chrome.extension.getURL(url);
-      chrome.tabs.create({'url' : url});
-    }
-  </script>
+  <script src="page_action.js"></script>
 </head>
-<body onload='javascript:init()'>
+<body>
   <h3>GWT Developer Plugin</h3>
   <div id='message'></div>
   <br/>
-  <button onclick= "updateConfiguration()">Update Your Configuration</button>
+  <button id="updateConfiguration">Update Your Configuration</button>
   </p>
 </body>
diff --git a/npapi/prebuilt/gwt-dev-plugin/page_action.js b/npapi/prebuilt/gwt-dev-plugin/page_action.js
new file mode 100644
index 0000000..b63e9b7
--- /dev/null
+++ b/npapi/prebuilt/gwt-dev-plugin/page_action.js
@@ -0,0 +1,35 @@
+function getParam(key) {
+  var idx = window.location.search.indexOf(key + "=");
+  var value = '';
+  if (idx >= 0) {
+    idx += key.length + 1;
+    value = window.location.search.substring(idx).split('&')[0];
+  }
+  return value;
+}
+
+function init() {
+  var permission = getParam('permission');
+  var host = getParam('host');
+  var code = getParam('codeserver');
+  var message='';
+
+  if (permission == 'include') {
+    message = 'The web and code server (' + host + '/' + code + ') is allowed to use the plugin';
+  } else if (permission == 'exclude') {
+    message = 'The web and code server (' + host + '/' + code + ') has been been blacklisted.';
+  } else if (permission == 'unknown') {
+    message = 'The web and code server (' + host + '/' + code + ') is unknown to the plugin.';
+  }
+
+  document.getElementById('message').innerText = message;
+  document.getElementById("updateConfiguration").onclick = updateConfiguration
+}
+
+function updateConfiguration() {
+  var url = 'DevModeOptions.html?host=' + getParam('host') + '&codeserver=' + getParam('codeserver');
+  url = chrome.extension.getURL(url);
+  chrome.tabs.create({'url' : url});
+}
+
+window.onload = init;