Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 chrome.app.runtime.onLaunched.addListener(function() { | |
| 6 chrome.app.window.create('main.html', {}, function(win) { | |
| 7 // The following key events handler will prevent the default behavior for | |
| 8 // the ESC key, thus will prevent the ESC key to leave fullscreen. | |
| 9 win.contentWindow.document.addEventListener('keydown', function(e) { | |
| 10 e.preventDefault(); | |
| 11 }); | |
| 12 win.contentWindow.document.addEventListener('keyup', function(e) { | |
| 13 e.preventDefault(); | |
| 14 }); | |
| 15 | |
| 16 chrome.test.sendMessage('Launched', function(reply) { | |
| 17 var doc = win.contentWindow.document; | |
| 18 | |
| 19 switch (reply) { | |
| 20 case 'window': | |
| 21 doc.addEventListener('keydown', function(e) { | |
| 22 if (e.keyCode != 66) // 'b' | |
| 23 return; | |
| 24 doc.removeEventListener('keydown', arguments.callee); | |
| 25 setTimeout(function() { | |
|
koz (OOO until 15th September)
2013/11/22 00:33:11
nit: Add a comment explaining why we setTimeout()
| |
| 26 chrome.test.sendMessage('B_KEY_RECEIVED'); | |
| 27 }); | |
| 28 }); | |
| 29 win.fullscreen(); | |
| 30 break; | |
| 31 | |
| 32 case 'dom': | |
| 33 doc.addEventListener('keydown', function() { | |
| 34 doc.removeEventListener('keydown', arguments.callee); | |
| 35 | |
| 36 doc.addEventListener('keydown', function(e) { | |
| 37 if (e.keyCode != 66) // 'b' | |
| 38 return; | |
| 39 doc.removeEventListener('keydown', arguments.callee); | |
| 40 setTimeout(function() { | |
| 41 chrome.test.sendMessage('B_KEY_RECEIVED'); | |
| 42 }); | |
| 43 }); | |
| 44 | |
| 45 doc.body.webkitRequestFullscreen(); | |
| 46 }); | |
| 47 break; | |
| 48 } | |
| 49 }); | |
| 50 }); | |
| 51 }); | |
| OLD | NEW |