-
-
Notifications
You must be signed in to change notification settings - Fork 833
Add support for Jitsi screensharing in electron app #1355
Changes from 1 commit
5357454
aa82be1
b047f1c
7f1d883
6e49926
24de01e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ limitations under the License. | |
import url from 'url'; | ||
import React from 'react'; | ||
import MatrixClientPeg from '../../../MatrixClientPeg'; | ||
import PlatformPeg from '../../../PlatformPeg'; | ||
import ScalarAuthClient from '../../../ScalarAuthClient'; | ||
import SdkConfig from '../../../SdkConfig'; | ||
import Modal from '../../../Modal'; | ||
|
@@ -127,6 +128,30 @@ export default React.createClass({ | |
loading: false, | ||
}); | ||
}); | ||
window.addEventListener('message', this._onMessage, false); | ||
}, | ||
|
||
componentWillUnmount() { | ||
window.removeEventListener('message', this._onMessage); | ||
}, | ||
|
||
_onMessage(event) { | ||
if (!PlatformPeg.get().isElectron() || this.props.type !== 'jitsi') { | ||
return; | ||
} | ||
if (!event.origin) { | ||
event.origin = event.originalEvent.origin; | ||
} | ||
|
||
if (this.state.widgetUrl.indexOf(event.origin) === -1) { | ||
return; | ||
} | ||
|
||
if (event.data.widgetAction === 'jitsi_iframe_loaded') { | ||
const iframe = this.refs.appFrame.contentWindow | ||
.document.querySelector('iframe[id^="jitsiConferenceFrame"]'); | ||
PlatformPeg.get().setupScreenSharingForIframe(iframe); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method should exist in all platforms, so impl in BasePlatform as a no-op so other platforms inherit it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it did, you wouldn't need the isElectron check above :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dbkr - which is preferred? Implement the method in all platforms and just leave it as a stub in every platform other than electron? I would guess so. Alternatively checking if the function exists and is a function could be a compromise...? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dbkr says the former. |
||
} | ||
}, | ||
|
||
_canUserModify: function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this looks for the widget url anywhere rather than just at the start? Granted it it seems unlikely that you'd have a malicious origin hanging out in the widget url somewhere, but still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/me points at
!this.state.widgetUrl.startsWith(event.origin)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.