| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var windowLoaded = false; |
| 6 var messaged = false; |
| 7 var iframeI18n = undefined; |
| 8 var appWindow = undefined; |
| 9 |
| 10 chrome.app.runtime.onLaunched.addListener(function() { |
| 11 chrome.app.window.create('window.html', { |
| 12 id: "mainwin", |
| 13 innerBounds: { |
| 14 width: 700, |
| 15 height: 600 |
| 16 } |
| 17 }, function(win) { |
| 18 appWindow = win; |
| 19 appWindow.contentWindow.onload = function() { |
| 20 windowLoaded = true; |
| 21 chrome.test.log('Window loaded: ' + windowLoaded); |
| 22 chrome.test.log('Iframe i18n: ' + iframeI18n); |
| 23 // If the message already arrived, report the i18n state. |
| 24 if (messaged) { |
| 25 appWindow.contentWindow.reportChromeI18nState( |
| 26 chrome.i18n != undefined, iframeI18n); |
| 27 } |
| 28 }; |
| 29 }); |
| 30 }); |
| 31 |
| 32 function initialize() { |
| 33 var iframe = document.createElement('iframe'); |
| 34 iframe.src = '/iframe.html'; |
| 35 iframe.style.display = 'none'; |
| 36 |
| 37 document.body.appendChild(iframe); |
| 38 |
| 39 window.addEventListener('message', function(e) { |
| 40 messaged = true; |
| 41 iframeI18n = e.data; |
| 42 if (windowLoaded) { |
| 43 appWindow.contentWindow.reportChromeI18nState( |
| 44 chrome.i18n != undefined, iframeI18n); |
| 45 } |
| 46 }); |
| 47 }; |
| 48 |
| 49 initialize(); |
| OLD | NEW |