diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 0e2a78e34d..22c1300c64 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -25,6 +25,7 @@ import Modal from '../../../Modal'; import { _t } from '../../../languageHandler'; import sdk from '../../../index'; import AppPermission from './AppPermission'; +import AppWarning from './AppWarning'; import MessageSpinner from './MessageSpinner'; import WidgetUtils from '../../../WidgetUtils'; @@ -70,6 +71,17 @@ export default React.createClass({ return scalarUrl && this.props.url.startsWith(scalarUrl); }, + isMixedContent: function() { + const parentContentProtocol = window.location.protocol; + const u = url.parse(this.props.url); + const childContentProtocol = u.protocol; + if (parentContentProtocol === 'https:' && childContentProtocol !== parentContentProtocol) { + console.warn("Refusing to load mixed-content app:", parentContentProtocol, childContentProtocol, window.location, this.props.url); + return true; + } + return false; + }, + componentWillMount: function() { if (!this.isScalarUrl()) { return; @@ -207,6 +219,14 @@ export default React.createClass({ > ); + } else if (this.isMixedContent() == true) { + appTileBody = ( +
+ +
+ ); } else { appTileBody = (
diff --git a/src/components/views/elements/AppWarning.js b/src/components/views/elements/AppWarning.js new file mode 100644 index 0000000000..527ee087d6 --- /dev/null +++ b/src/components/views/elements/AppWarning.js @@ -0,0 +1,25 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { _t } from '../../../languageHandler'; + +function AppWarning(props) { + return ( +
+
+ {_t('Warning!')}/ +
+
+ {props.errorMsg} +
+
+ ); +} + +AppWarning.propTypes = { + errorMsg: PropTypes.string, +}; +AppWarning.defaultProps = { + errorMsg: _t('Error'), +}; + +export default AppWarning;