Bug 1217303 - Remove mozContentEvent and mozChromeEvent about controlling System's audio channel. r=baku

This commit is contained in:
Evan Tseng 2015-10-23 16:07:39 +08:00
parent b27f8a98d3
commit 7b016329dd

View File

@ -403,17 +403,14 @@ var shell = {
webNav.QueryInterface(Ci.nsIDocShell).windowDraggingAllowed = true;
#endif
this.allowedAudioChannels = new Map();
let audioChannels = systemAppFrame.allowedAudioChannels;
audioChannels && audioChannels.forEach(function(audioChannel) {
this.allowedAudioChannels.set(audioChannel.name, audioChannel);
audioChannel.addEventListener('activestatechanged', this);
// Set all audio channels as unmuted by default
// because some audio in System app will be played
// before AudioChannelService[1] is Gaia is loaded.
// [1]: https://github.com/mozilla-b2g/gaia/blob/master/apps/system/js/audio_channel_service.js
audioChannel.setMuted(false);
}.bind(this));
});
// On firefox mulet, shell.html is loaded in a tab
// and we have to listen on the chrome event handler
@ -683,18 +680,6 @@ var shell = {
case 'unload':
this.stop();
break;
case 'activestatechanged':
var channel = evt.target;
// TODO: We should get the `isActive` state from evt.isActive.
// Then we don't need to do `channel.isActive()` here.
channel.isActive().onsuccess = function(evt) {
SystemAppProxy._sendCustomEvent('mozSystemWindowChromeEvent', {
type: 'system-audiochannel-state-changed',
name: channel.name,
isActive: evt.target.result
});
}.bind(this);
break;
}
},
@ -904,11 +889,6 @@ var CustomEventManager = {
case 'inputregistry-remove':
KeyboardHelper.handleEvent(detail);
break;
case 'system-audiochannel-list':
case 'system-audiochannel-mute':
case 'system-audiochannel-volume':
SystemAppMozBrowserHelper.handleEvent(detail);
break;
case 'do-command':
DoCommandHelper.handleEvent(detail.cmd);
break;
@ -1076,63 +1056,6 @@ var KeyboardHelper = {
}
};
var SystemAppMozBrowserHelper = {
handleEvent: function systemAppMozBrowser_handleEvent(detail) {
let request;
let name;
switch (detail.type) {
case 'system-audiochannel-list':
let audioChannels = [];
shell.allowedAudioChannels.forEach(function(value, name) {
audioChannels.push(name);
});
SystemAppProxy._sendCustomEvent('mozSystemWindowChromeEvent', {
type: 'system-audiochannel-list',
audioChannels: audioChannels
});
break;
case 'system-audiochannel-mute':
name = detail.name;
let isMuted = detail.isMuted;
request = shell.allowedAudioChannels.get(name).setMuted(isMuted);
request.onsuccess = function() {
SystemAppProxy._sendCustomEvent('mozSystemWindowChromeEvent', {
type: 'system-audiochannel-mute-onsuccess',
name: name,
isMuted: isMuted
});
};
request.onerror = function() {
SystemAppProxy._sendCustomEvent('mozSystemWindowChromeEvent', {
type: 'system-audiochannel-mute-onerror',
name: name,
isMuted: isMuted
});
};
break;
case 'system-audiochannel-volume':
name = detail.name;
let volume = detail.volume;
request = shell.allowedAudioChannels.get(name).setVolume(volume);
request.onsuccess = function() {
sSystemAppProxy._sendCustomEvent('mozSystemWindowChromeEvent', {
type: 'system-audiochannel-volume-onsuccess',
name: name,
volume: volume
});
};
request.onerror = function() {
SystemAppProxy._sendCustomEvent('mozSystemWindowChromeEvent', {
type: 'system-audiochannel-volume-onerror',
name: name,
volume: volume
});
};
break;
}
}
};
// This is the backend for Gaia's screenshot feature. Gaia requests a
// screenshot by sending a mozContentEvent with detail.type set to
// 'take-screenshot'. Then we take a screenshot and send a