This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1157140 - Add MozChromeEvent and MozContentEvent to control the a…
…udio channels in System app r=alive, dkuo
- Loading branch information
Showing
5 changed files
with
592 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* global AudioChannelController */ | ||
/* global BaseModule */ | ||
'use strict'; | ||
|
||
(function() { | ||
/** | ||
* SystemWindow is a placeholder for the system app's mozbrowser iframe | ||
* but with no actual UI. | ||
* We will use mozChromeEvent/mozContentEvent to communicate with shell.js | ||
* to use the actual mozbrowser iframe of the system app. | ||
*/ | ||
var SystemWindow = function() {}; | ||
|
||
SystemWindow.EVENTS = [ | ||
'mozChromeEvent' | ||
]; | ||
|
||
BaseModule.create(SystemWindow, { | ||
name: 'SystemWindow', | ||
DEBUG: false, | ||
// The fake app window ID of System app. | ||
instanceID: null, | ||
// The audio channels belong to System app. | ||
audioChannels: null, | ||
// Know an AppWindow object is for System app or other apps. | ||
isSystem: true, | ||
|
||
/** | ||
* Initial the module. | ||
*/ | ||
_start: function() { | ||
this.instanceID = 'systemAppID'; | ||
this.audioChannels = new Map(); | ||
// Get System app's audio channels. | ||
this._sendContentEvent({ type: 'system-audiochannel-list' }); | ||
}, | ||
|
||
/** | ||
* Handle MozChromeEvent. | ||
* | ||
* @param {Event} evt The event to handle. | ||
*/ | ||
_handle_mozChromeEvent: function(evt) { | ||
var detail = evt.detail; | ||
switch (detail.type) { | ||
case 'system-audiochannel-list': | ||
detail.audioChannels.forEach((name) => { | ||
this.audioChannels.set( | ||
name, new AudioChannelController(this, { name: name }) | ||
); | ||
}); | ||
break; | ||
} | ||
}, | ||
|
||
/** | ||
* Send MozContentEvent to control the audio chanenl in System app. | ||
* | ||
* @param {Object} detail The arguments for passing to Gecko. | ||
* @param {Object} detail.type The operation for the audio channel. | ||
*/ | ||
_sendContentEvent: function(detail) { | ||
var evt = new CustomEvent('mozContentEvent', { detail: detail }); | ||
window.dispatchEvent(evt); | ||
} | ||
}); | ||
}()); |
Oops, something went wrong.