Chromium Code Reviews| Index: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| index ad8fa35a7bbcbbf690141ca3007118df8013784f..bc72044eb60d3127e31f984f728f6c7dd3bf53c8 100644 |
| --- a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| +++ b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| @@ -69,6 +69,10 @@ class OldEmitter implements Emitter { |
| return getBuffer(compiler.deferredLoadTask.mainOutputUnit); |
| } |
| + String useCspOrNonCspVersion(String cspVersion, String nonCspVersion) { |
| + return compiler.useContentSecurityPolicy ? cspVersion : nonCspVersion; |
| + } |
| + |
| /** |
| * List of expressions and statements that will be included in the |
| * precompiled function. |
| @@ -490,14 +494,14 @@ class OldEmitter implements Emitter { |
| var hasOwnProperty = Object.prototype.hasOwnProperty; |
| - if (typeof dart_precompiled == "function") { |
| - constructors = dart_precompiled(collectedClasses); |
| - } else { |
| - var combinedConstructorFunction = |
| + ${useCspOrNonCspVersion(''' |
|
floitsch
2014/12/17 15:03:38
There is an easier nicer solution:
`if (#) { ...
zarah
2014/12/18 08:22:16
Done.
|
| + constructors = dart_precompiled(collectedClasses); |
| + ''',''' |
| + var combinedConstructorFunction = |
| "function \$reflectable(fn){fn.$reflectableField=1;return fn};\\n"+ |
| "var \$desc;\\n"; |
| - var constructorsList = []; |
| - } |
| + var constructorsList = []; |
| + ''')} |
| for (var cls in collectedClasses) { |
| var desc = collectedClasses[cls]; |
| @@ -529,21 +533,23 @@ class OldEmitter implements Emitter { |
| })(functionSignature); |
| } |
| - if (typeof dart_precompiled != "function") { |
| - combinedConstructorFunction += defineClass(cls, fields); |
| - constructorsList.push(cls); |
| - } |
| + ${useCspOrNonCspVersion(''' |
| + ''', ''' |
| + combinedConstructorFunction += defineClass(cls, fields); |
| + constructorsList.push(cls); |
| + ''')} |
| if (supr) pendingClasses[cls] = supr; |
| } |
| - if (typeof dart_precompiled != "function") { |
| - combinedConstructorFunction += |
| - "return [\\n " + constructorsList.join(",\\n ") + "\\n]"; |
| - var constructors = |
| - new Function("\$collectedClasses", combinedConstructorFunction) |
| - (collectedClasses); |
| - combinedConstructorFunction = null; |
| - } |
| + ${useCspOrNonCspVersion(''' |
| + ''',''' |
| + combinedConstructorFunction += |
| + "return [\\n " + constructorsList.join(",\\n ") + "\\n]"; |
| + var constructors = |
| + new Function("\$collectedClasses", combinedConstructorFunction) |
| + (collectedClasses); |
| + combinedConstructorFunction = null; |
| + ''')} |
| for (var i = 0; i < constructors.length; i++) { |
| var constructor = constructors[i]; |