| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Glue code that runs on the page referencing dart web components. | 5 // Glue code that runs on the page referencing dart web components. |
| 6 // Some logic has to be placed here rather than on the background page | 6 // Some logic has to be placed here rather than on the background page |
| 7 // because of chrome security restrictions. | 7 // because of chrome security restrictions. |
| 8 | 8 |
| 9 // Port used to send requests to the background page to proxy urls. | 9 // Port used to send requests to the background page to proxy urls. |
| 10 var proxyPort = null; | 10 var proxyPort = null; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Replace the contents of the existing document with the | 54 // Replace the contents of the existing document with the |
| 55 // proxied content at the url with an additional .html added. | 55 // proxied content at the url with an additional .html added. |
| 56 // We prefer this versus redirecting to the page with an extra | 56 // We prefer this versus redirecting to the page with an extra |
| 57 // .html so that refreshing this page does the right thing. | 57 // .html so that refreshing this page does the right thing. |
| 58 var newDoc = document.open("text/html", "replace"); | 58 var newDoc = document.open("text/html", "replace"); |
| 59 newDoc.write(content); | 59 newDoc.write(content); |
| 60 newDoc.close(); | 60 newDoc.close(); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 }, 100); | 63 }, 100); |
| 64 } else if (msg.type == 'MESSAGES') { |
| 65 var messages = msg.messages; |
| 66 for (var i = 0; i < messages.length; i++) { |
| 67 var level = messages[i][0]; |
| 68 var message = messages[i][1]; |
| 69 if (level == 'SEVERE') { |
| 70 window.console.error(message); |
| 71 } else if (level == 'WARNING') { |
| 72 window.console.warn(message); |
| 73 } else { |
| 74 window.console.info(message); |
| 75 } |
| 76 } |
| 64 } | 77 } |
| 65 }) | 78 }) |
| 66 | 79 |
| 67 } | 80 } |
| 68 | 81 |
| 69 document.addEventListener("DOMContentLoaded", function() { | 82 document.addEventListener("DOMContentLoaded", function() { |
| 70 // Don't re-run the compiler on code we just generated. | 83 // Don't re-run the compiler on code we just generated. |
| 71 if (document.childNodes.length > 1 && | 84 if (document.childNodes.length > 1 && |
| 72 document.childNodes[1] instanceof Comment && | 85 document.childNodes[1] instanceof Comment && |
| 73 document.childNodes[1].nodeValue.indexOf( | 86 document.childNodes[1].nodeValue.indexOf( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 84 }); | 97 }); |
| 85 | 98 |
| 86 window.addEventListener("message", function(event) { | 99 window.addEventListener("message", function(event) { |
| 87 if (event.source != window) | 100 if (event.source != window) |
| 88 return; | 101 return; |
| 89 | 102 |
| 90 if (event.data.type == "PARSE") { | 103 if (event.data.type == "PARSE") { |
| 91 onRequestParse(); | 104 onRequestParse(); |
| 92 } | 105 } |
| 93 }, false); | 106 }, false); |
| OLD | NEW |