Bug 989198, Patch 4: Dispatch both chrome event and key event for hardward keys, and add new permission, r=fabrice.

---
 b2g/chrome/content/shell.js       |   13 ++++++++-----
 dom/apps/PermissionsTable.jsm     |    6 ++++++
 testing/mochitest/manifest.webapp |    3 ++-
 3 files changed, 16 insertions(+), 6 deletions(-)
This commit is contained in:
Gina Yeh 2014-10-14 15:09:36 +08:00
parent 4d98afa8b4
commit 3e0ef2f1a8
3 changed files with 16 additions and 6 deletions

View File

@ -324,6 +324,8 @@ var shell = {
chromeEventHandler.addEventListener('keydown', this, true);
chromeEventHandler.addEventListener('keypress', this, true);
chromeEventHandler.addEventListener('keyup', this, true);
chromeEventHandler.addEventListener('mozbrowserbeforekeydown', this, true);
chromeEventHandler.addEventListener('mozbrowserbeforekeyup', this, true);
window.addEventListener('MozApplicationManifest', this);
window.addEventListener('mozfullscreenchange', this);
@ -356,6 +358,8 @@ var shell = {
window.removeEventListener('keydown', this, true);
window.removeEventListener('keypress', this, true);
window.removeEventListener('keyup', this, true);
window.removeEventListener('mozbrowserbeforekeydown', this, true);
window.removeEventListener('mozbrowserbeforekeyup', this, true);
window.removeEventListener('MozApplicationManifest', this);
window.removeEventListener('mozfullscreenchange', this);
window.removeEventListener('sizemodechange', this);
@ -420,17 +424,14 @@ var shell = {
return;
}
// If we didn't return, then the key event represents a hardware key
// and we need to prevent it from propagating to Gaia
evt.stopImmediatePropagation();
evt.preventDefault(); // Prevent keypress events (when #501496 is fixed).
// If it is a key down or key up event, we send a chrome event to Gaia.
// If it is a keypress event we just ignore it.
switch (evt.type) {
case 'mozbrowserbeforekeydown':
case 'keydown':
type = type + '-press';
break;
case 'mozbrowserbeforekeyup':
case 'keyup':
type = type + '-release';
break;
@ -473,6 +474,8 @@ var shell = {
case 'keydown':
case 'keyup':
case 'keypress':
case 'mozbrowserbeforekeydown':
case 'mozbrowserbeforekeyup':
this.filterHardwareKeys(evt);
break;
case 'mozfullscreenchange':

View File

@ -493,6 +493,12 @@ this.PermissionsTable = { geolocation: {
trusted: DENY_ACTION,
privileged: DENY_ACTION,
certified: ALLOW_ACTION
},
"before-after-keyboard-event": {
app: DENY_ACTION,
trusted: DENY_ACTION,
privileged: DENY_ACTION,
certified: ALLOW_ACTION
}
};

View File

@ -27,7 +27,8 @@
"network-events":{},
"embed-apps":{},
"audio-channel-content":{},
"audio-channel-alarm":{}
"audio-channel-alarm":{},
"before-after-keyboard-event":{}
},
"locales": {
"en-US": {