Chromium Code Reviews| 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 chrome.app.runtime.onLaunched.addListener(function() { | 5 chrome.app.runtime.onLaunched.addListener(function() { |
| 6 chrome.app.window.create('main.html', {}, function(win) { | 6 chrome.app.window.create('main.html', {}, function(win) { |
| 7 // The following key events handler should have no effect because the | 7 // The following key events handler should have no effect because the |
| 8 // application does not have the 'overrideEscFullscreen' permission. | 8 // application does not have the 'overrideEscFullscreen' permission. |
| 9 win.contentWindow.document.addEventListener('keydown', function(e) { | 9 win.contentWindow.document.addEventListener('keydown', function(e) { |
| 10 e.preventDefault(); | 10 e.preventDefault(); |
| 11 }); | 11 }); |
| 12 win.contentWindow.document.addEventListener('keyup', function(e) { | 12 win.contentWindow.document.addEventListener('keyup', function(e) { |
| 13 e.preventDefault(); | 13 e.preventDefault(); |
| 14 }); | 14 }); |
| 15 | 15 |
| 16 chrome.test.sendMessage('Launched', function(reply) { | 16 chrome.test.sendMessage('Launched', function(reply) { |
| 17 win.contentWindow.document.addEventListener('keydown', function(e) { | |
| 18 if (e.keyCode != 90) // 'z' | |
|
koz (OOO until 15th September)
2014/01/08 23:29:25
'z' is 122, 'Z' is 90. Consider using 'Z'.charCode
mlamouri (slow - plz ping)
2014/01/09 17:08:46
keyCode and charCode are not the same thing and I
| |
| 19 return; | |
| 20 | |
| 21 chrome.test.sendMessage('KEY_RECEIVED'); | |
|
koz (OOO until 15th September)
2014/01/08 23:29:25
nit: The other messages are in camel case so this
mlamouri (slow - plz ping)
2014/01/09 17:08:46
Done.
| |
| 22 }); | |
| 23 | |
| 17 switch (reply) { | 24 switch (reply) { |
| 18 case 'window': | 25 case 'window': |
| 19 win.fullscreen(); | 26 win.fullscreen(); |
| 20 break; | 27 break; |
| 21 case 'dom': | 28 case 'dom': |
| 22 win.contentWindow.document.addEventListener('keydown', function() { | 29 win.contentWindow.document.addEventListener('keydown', function() { |
| 23 win.contentWindow.document.removeEventListener('keydown', | 30 win.contentWindow.document.removeEventListener('keydown', |
| 24 arguments.callee); | 31 arguments.callee); |
| 25 win.contentWindow.document.body.webkitRequestFullscreen(); | 32 win.contentWindow.document.body.webkitRequestFullscreen(); |
| 26 }); | 33 }); |
| 27 break; | 34 break; |
| 28 } | 35 } |
| 29 }); | 36 }); |
| 30 }); | 37 }); |
| 31 }); | 38 }); |
| OLD | NEW |