| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 var embedder = null; | 5 var embedder = null; |
| 6 | 6 |
| 7 function reportConnected() { | 7 function reportConnected() { |
| 8 window.console.log('Reporting connection to embedder.'); |
| 8 var msg = ['connected']; | 9 var msg = ['connected']; |
| 9 embedder.postMessage(JSON.stringify(msg), '*'); | 10 embedder.postMessage(JSON.stringify(msg), '*'); |
| 10 } | 11 } |
| 11 | 12 |
| 12 window.addEventListener('message', function(e) { | 13 window.addEventListener('message', function(e) { |
| 13 embedder = e.source; | 14 embedder = e.source; |
| 14 var data = JSON.parse(e.data); | 15 var data = JSON.parse(e.data); |
| 15 switch (data[0]) { | 16 switch (data[0]) { |
| 16 case 'connect': { | 17 case 'connect': { |
| 17 reportConnected(); | 18 reportConnected(); |
| 18 break; | 19 break; |
| 19 } | 20 } |
| 20 } | 21 } |
| 21 }); | 22 }); |
| 22 | 23 |
| 24 |
| 25 window.console.log('Script has been successfully injected.'); |
| OLD | NEW |