summaryrefslogtreecommitdiffstats
path: root/chrome/third_party
diff options
context:
space:
mode:
authortsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-31 20:41:14 +0000
committertsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-31 20:41:14 +0000
commit5d9d12c06c3bcd820f08701bdb5996cb91d966fa (patch)
treeecca12d674176e0a87bad077a4be47c9a60b6cc0 /chrome/third_party
parent77e0acde52ef5b2470b5c417590725faa998d5ae (diff)
downloadchromium_src-5d9d12c06c3bcd820f08701bdb5996cb91d966fa.zip
chromium_src-5d9d12c06c3bcd820f08701bdb5996cb91d966fa.tar.gz
chromium_src-5d9d12c06c3bcd820f08701bdb5996cb91d966fa.tar.bz2
Apply content-security-policy to chrome://plugins page. This involves
converting all inline javascript to external .js files, since CSP can't determine whether inline script is legitimate or an XSS. We move the jstemplate_compiled.js file to the share resources directory, since several WEBUI components will need this, and update the compile.py script that produces it to write to this new location. We move the javascript out of plugins.html to plugins.js; note that the sections at line 130 and line 251 are new. Review URL: http://codereview.chromium.org/7086003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87358 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/third_party')
-rw-r--r--chrome/third_party/jstemplate/README.chromium15
-rwxr-xr-xchrome/third_party/jstemplate/compile.py9
-rw-r--r--chrome/third_party/jstemplate/jstemplate_compiled.js13
3 files changed, 15 insertions, 22 deletions
diff --git a/chrome/third_party/jstemplate/README.chromium b/chrome/third_party/jstemplate/README.chromium
index 153d6a6..439ac77 100644
--- a/chrome/third_party/jstemplate/README.chromium
+++ b/chrome/third_party/jstemplate/README.chromium
@@ -10,8 +10,15 @@ output with an incremental change to the original input data."
Uncalled functions have been removed from util.js to make the resulting
javascript smaller.
-compile.py is a simple program used to generate the single compiled
-jsfile.
+compile.py is a simple program used to generate the single compiled jsfile.
+
+NOTE: output is now simply written to stdout so as to allow you to redirect
+it to a location required by the shared resource bundle.
+
+See IDR_SHARED_JS_JSTEMPLATE_COMPILED's file attribute in shared_resources.grd
+to determine the correct location for the output.
+
+The jstemplate_compiled.js file which formerly resided in this directory is
+no longer used.
+
-jstemplate_compiled.js is the output after passing the code through
-compile.sh.
diff --git a/chrome/third_party/jstemplate/compile.py b/chrome/third_party/jstemplate/compile.py
index 3d16d96..ddfc4fe 100755
--- a/chrome/third_party/jstemplate/compile.py
+++ b/chrome/third_party/jstemplate/compile.py
@@ -4,13 +4,14 @@
# found in the LICENSE file.
# A python script that combines the javascript files needed by jstemplate into
-# a single file.
+# a single file. Writes to standard output; you are responsible for putting
+# the file into the tree where it belongs.
import httplib
+import sys
import urllib
srcs ="util.js jsevalcontext.js jstemplate.js exports.js".split()
-out = "jstemplate_compiled.js"
# Wrap the output in an anonymous function to prevent poluting the global
# namespace.
@@ -32,7 +33,5 @@ headers = {'Content-type': 'application/x-www-form-urlencoded'}
conn = httplib.HTTPConnection('closure-compiler.appspot.com')
conn.request('POST', '/compile', params, headers)
response = conn.getresponse()
-out_file = file(out, 'w')
-out_file.write(output_wrapper % response.read())
-out_file.close()
+sys.stdout.write(output_wrapper % response.read())
conn.close()
diff --git a/chrome/third_party/jstemplate/jstemplate_compiled.js b/chrome/third_party/jstemplate/jstemplate_compiled.js
deleted file mode 100644
index afe2769..0000000
--- a/chrome/third_party/jstemplate/jstemplate_compiled.js
+++ /dev/null
@@ -1,13 +0,0 @@
-(function(){function j(a,b){for(var c in b)a[c]=b[c]}function l(){return Function.prototype.call.apply(Array.prototype.slice,arguments)}function m(a,b){var c=l(arguments,2);return function(){return b.apply(a,c)}}var n=9;function o(a,b){b=new p(b);for(b.f=[a];b.f.length;){a=b.f.shift();b.g(a);for(a=a.firstChild;a;a=a.nextSibling)a.nodeType==1&&b.f.push(a)}}function p(a){this.g=a}function q(a,b,c){a.setAttribute(b,c)}function r(a,b){a.removeAttribute(b)}function s(a){a.style.display=""}
-function t(a){a.style.display="none"};var u=":",v=/\s*;\s*/;function w(){this.i.apply(this,arguments)}w.prototype.i=function(a,b){var c=this;if(!c.a)c.a={};b?j(c.a,b.a):j(c.a,x);c.a.$this=a;c.a.$context=c;c.d=typeof a!="undefined"&&a!=null?a:"";if(!b)c.a.$top=c.d};var x={};(function(a,b){x[a]=b})("$default",null);var y=[];function z(a){for(var b in a.a)delete a.a[b];a.d=null;y.push(a)}function A(a,b,c){try{return b.call(c,a.a,a.d)}catch(e){return x.$default}}
-function B(a,b,c,e){if(y.length>0){var d=y.pop();w.call(d,b,a);a=d}else a=new w(b,a);a.a.$index=c;a.a.$count=e;return a}var C="a_",E="b_",F="with (a_) with (b_) return ",G={};function H(a){if(!G[a])try{G[a]=new Function(C,E,F+a)}catch(b){}return G[a]}function I(a){return a}function J(a){var b=[];a=a.split(v);for(var c=0,e=a.length;c<e;++c){var d=a[c].indexOf(u);if(!(d<0)){var f;f=a[c].substr(0,d).replace(/^\s+/,"").replace(/\s+$/,"");d=H(a[c].substr(d+1));b.push(f,d)}}return b}
-function K(a){var b=[];a=a.split(v);for(var c=0,e=a.length;c<e;++c)if(a[c]){var d=H(a[c]);b.push(d)}return b};var L="jsinstance",aa="jsts",M="*",N="div",ba="id";function ca(a,b){var c=new O;P(b);c.j=b?b.nodeType==n?b:b.ownerDocument||document:document;var e=m(c,c.e,a,b);a=c.h=[];b=c.k=[];c.c=[];e();for(var d,f,g;a.length;){d=a[a.length-1];e=b[b.length-1];if(e>=d.length){e=a.pop();e.length=0;c.c.push(e);b.pop()}else{f=d[e++];g=d[e++];d=d[e++];b[b.length-1]=e;f.call(c,g,d)}}}function O(){}var da=0,Q={};Q[0]={};var R={},S={},T=[];function P(a){a.__jstcache||o(a,function(b){U(b)})}
-var V=[["jsselect",H],["jsdisplay",H],["jsvalues",J],["jsvars",J],["jseval",K],["transclude",I],["jscontent",H],["jsskip",H]];
-function U(a){if(a.__jstcache)return a.__jstcache;var b=a.getAttribute("jstcache");if(b!=null)return a.__jstcache=Q[b];b=T.length=0;for(var c=V.length;b<c;++b){var e=V[b][0],d=a.getAttribute(e);S[e]=d;d!=null&&T.push(e+"="+d)}if(T.length==0){a.setAttribute("jstcache","0");return a.__jstcache=Q[0]}var f=T.join("&");if(b=R[f]){a.setAttribute("jstcache",b);return a.__jstcache=Q[b]}var g={};b=0;for(c=V.length;b<c;++b){d=V[b];e=d[0];var i=d[1];d=S[e];if(d!=null)g[e]=i(d)}b=""+ ++da;a.setAttribute("jstcache",
-b);Q[b]=g;R[f]=b;return a.__jstcache=g}function W(a,b){a.h.push(b);a.k.push(0)}function X(a){return a.c.length?a.c.pop():[]}O.prototype.e=function(a,b){var c=this,e=Y(c,b),d=e.transclude;if(d)if(e=Z(d)){b.parentNode.replaceChild(e,b);b=X(c);b.push(c.e,a,e);W(c,b)}else b.parentNode.removeChild(b);else(e=e.jsselect)?ea(c,a,b,e):c.b(a,b)};
-O.prototype.b=function(a,b){var c=this,e=Y(c,b),d=e.jsdisplay;if(d){if(!A(a,d,b)){t(b);return}s(b)}(d=e.jsvars)&&fa(c,a,b,d);(d=e.jsvalues)&&ga(c,a,b,d);if(d=e.jseval)for(var f=0,g=d.length;f<g;++f)A(a,d[f],b);if(d=e.jsskip)if(A(a,d,b))return;if(e=e.jscontent){a=""+A(a,e,b);if(b.innerHTML!=a){for(;b.firstChild;)b.firstChild.parentNode.removeChild(b.firstChild);c=c.j.createTextNode(a);b.appendChild(c)}}else{e=X(c);for(b=b.firstChild;b;b=b.nextSibling)b.nodeType==1&&e.push(c.e,a,b);e.length&&W(c,e)}};
-function ea(a,b,c,e){e=A(b,e,c);var d=c.getAttribute(L),f=false;if(d)if(d.charAt(0)==M){var g=d.substr(1);d=parseInt(g,10);f=true}else d=parseInt(d,10);var i=e!=null&&typeof e=="object"&&typeof e.length=="number";g=i?e.length:1;var h=i&&g==0;if(i)if(h)if(d)c.parentNode.removeChild(c);else{c.setAttribute(L,"*0");t(c)}else{s(c);if(d===null||d===""||f&&d<g-1){f=X(a);d=d||0;for(i=g-1;d<i;++d){var k=c.cloneNode(true);c.parentNode.insertBefore(k,c);$(k,e,d);h=B(b,e[d],d,g);f.push(a.b,h,k,z,h,null)}$(c,
-e,d);h=B(b,e[d],d,g);f.push(a.b,h,c,z,h,null);W(a,f)}else if(d<g){f=e[d];$(c,e,d);h=B(b,f,d,g);f=X(a);f.push(a.b,h,c,z,h,null);W(a,f)}else c.parentNode.removeChild(c)}else if(e==null)t(c);else{s(c);h=B(b,e,0,1);f=X(a);f.push(a.b,h,c,z,h,null);W(a,f)}}function fa(a,b,c,e){a=0;for(var d=e.length;a<d;a+=2){var f=e[a],g=A(b,e[a+1],c);b.a[f]=g}}
-function ga(a,b,c,e){a=0;for(var d=e.length;a<d;a+=2){var f=e[a],g=A(b,e[a+1],c);if(f.charAt(0)=="$")b.a[f]=g;else if(f.charAt(0)=="."){f=f.substr(1).split(".");for(var i=c,h=f.length,k=0,ha=h-1;k<ha;++k){var D=f[k];i[D]||(i[D]={});i=i[D]}i[f[h-1]]=g}else if(f)if(typeof g=="boolean")g?q(c,f,f):r(c,f);else c.setAttribute(f,""+g)}}function Y(a,b){if(b.__jstcache)return b.__jstcache;if(a=b.getAttribute("jstcache"))return b.__jstcache=Q[a];return U(b)}
-function Z(a,b){var c=document;if(a=b?ia(c,a,b):c.getElementById(a)){P(a);a=a.cloneNode(true);a.removeAttribute(ba);return a}else return null}function ia(a,b,c,e){var d=a.getElementById(b);if(d)return d;c=c();e=e||aa;if(d=a.getElementById(e))d=d;else{d=a.createElement(N);d.id=e;t(d);d.style.position="absolute";a.body.appendChild(d)}e=a.createElement(N);d.appendChild(e);e.innerHTML=c;return d=a.getElementById(b)}function $(a,b,c){c==b.length-1?q(a,L,M+c):q(a,L,""+c)};window.jstGetTemplate=Z;window.JsEvalContext=w;window.jstProcess=ca;
-})() \ No newline at end of file