Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: chrome/third_party/jstemplate/compile.py

Issue 7086003: Apply content-security-policy to chrome://plugins page. This involves (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # A python script that combines the javascript files needed by jstemplate into 6 # A python script that combines the javascript files needed by jstemplate into
7 # a single file. 7 # a single file. Writes to standard output; you are responsible for putting
8 # the file into the tree where it belongs.
8 9
9 import httplib 10 import httplib
11 import sys
10 import urllib 12 import urllib
11 13
12 srcs ="util.js jsevalcontext.js jstemplate.js exports.js".split() 14 srcs ="util.js jsevalcontext.js jstemplate.js exports.js".split()
13 out = "jstemplate_compiled.js"
14 15
15 # Wrap the output in an anonymous function to prevent poluting the global 16 # Wrap the output in an anonymous function to prevent poluting the global
16 # namespace. 17 # namespace.
17 output_wrapper = "(function(){%s})()" 18 output_wrapper = "(function(){%s})()"
18 19
19 # Define the parameters for the POST request and encode them in a URL-safe 20 # Define the parameters for the POST request and encode them in a URL-safe
20 # format. See http://code.google.com/closure/compiler/docs/api-ref.html for API 21 # format. See http://code.google.com/closure/compiler/docs/api-ref.html for API
21 # reference. 22 # reference.
22 params = urllib.urlencode( 23 params = urllib.urlencode(
23 map(lambda src: ('js_code', file(src).read()), srcs) + 24 map(lambda src: ('js_code', file(src).read()), srcs) +
24 [ 25 [
25 ('compilation_level', 'ADVANCED_OPTIMIZATIONS'), 26 ('compilation_level', 'ADVANCED_OPTIMIZATIONS'),
26 ('output_format', 'text'), 27 ('output_format', 'text'),
27 ('output_info', 'compiled_code'), 28 ('output_info', 'compiled_code'),
28 ]) 29 ])
29 30
30 # Always use the following value for the Content-type header. 31 # Always use the following value for the Content-type header.
31 headers = {'Content-type': 'application/x-www-form-urlencoded'} 32 headers = {'Content-type': 'application/x-www-form-urlencoded'}
32 conn = httplib.HTTPConnection('closure-compiler.appspot.com') 33 conn = httplib.HTTPConnection('closure-compiler.appspot.com')
33 conn.request('POST', '/compile', params, headers) 34 conn.request('POST', '/compile', params, headers)
34 response = conn.getresponse() 35 response = conn.getresponse()
35 out_file = file(out, 'w') 36 sys.stdout.write(output_wrapper % response.read())
36 out_file.write(output_wrapper % response.read())
37 out_file.close()
38 conn.close() 37 conn.close()
OLDNEW
« no previous file with comments | « chrome/third_party/jstemplate/README.chromium ('k') | chrome/third_party/jstemplate/jstemplate_compiled.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698