Skip to content

Commit

Permalink
New media permission, show dialog when not enabled for voice msg
Browse files Browse the repository at this point in the history
UI now in separate renderer:
  - the permissions popup
  - settings dialog
  - debug log dialog
  - about window

Couple bug fixes:
  - About Window: Fix 'escape' to close window
  - Remove outdated dist/copy tasks from Gruntfile

Eslintified settings_view.js
  • Loading branch information
scottnonnenberg-signal committed Jul 3, 2018
1 parent 9d9a797 commit ad43878
Show file tree
Hide file tree
Showing 33 changed files with 1,193 additions and 384 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ts/**/*.js
!js/expiring_messages.js
!js/views/attachment_view.js
!js/views/backbone_wrapper_view.js
!js/views/clear_data_view.js
!js/views/conversation_search_view.js
!js/views/conversation_view.js
!js/views/debug_log_view.js
Expand Down
8 changes: 3 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@ module.exports = function(grunt) {
'!js/expiring_messages.js',
'!js/modules/**/*.js',
'!js/Mp3LameEncoder.min.js',
'!js/settings_start.js',
'!js/signal_protocol_store.js',
'!js/views/clear_data_view.js',
'!js/views/conversation_search_view.js',
'!js/views/conversation_view.js',
'!js/views/debug_log_view.js',
'!js/views/file_input_view.js',
'!js/views/message_view.js',
'!js/views/settings_view.js',
'!js/models/conversations.js',
'!js/models/messages.js',
'!js/WebAudioRecorderMp3.js',
Expand All @@ -134,10 +137,6 @@ module.exports = function(grunt) {
},
},
watch: {
dist: {
files: ['<%= dist.src %>', '<%= dist.res %>'],
tasks: ['copy_dist'],
},
libtextsecure: {
files: ['./libtextsecure/*.js', './libtextsecure/storage/*.js'],
tasks: ['concat:libtextsecure'],
Expand Down Expand Up @@ -461,7 +460,6 @@ module.exports = function(grunt) {
grunt.registerTask('dev', ['default', 'watch']);
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('test', ['unit-tests', 'lib-unit-tests']);
grunt.registerTask('copy_dist', ['gitinfo', 'copy:res', 'copy:src']);
grunt.registerTask('date', ['gitinfo', 'getExpireTime']);
grunt.registerTask('default', [
'exec:build-protobuf',
Expand Down
24 changes: 24 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@
"message": "Report an Issue",
"description": "Item under the Help menu, takes you to GitHub new issue form (title case)"
},
"signalDesktopPreferences": {
"message": "Signal Desktop Preferences",
"description": "Title of the window that pops up with Signal Desktop preferences in it"
},
"aboutSignalDesktop": {
"message": "About Signal Desktop",
"description": "Item under the Help menu, which opens a small about window"
Expand Down Expand Up @@ -610,6 +614,18 @@
}
}
},
"audioPermissionNeeded": {
"message": "To send audio messages, allow Signal Desktop to access your microphone.",
"description": "Shown if the user attempts to send an audio message without audio permssions turned on"
},
"allowAccess": {
"message": "Allow Access",
"description": "Button shown in popup asking to enable microphon/video permissions to send audio messages"
},
"showSettings": {
"message": "Show Settings",
"description": "A button shown in dialog requesting the user to turn on audio permissions"
},
"audio": {
"message": "Audio",
"description": "Shown in a quotation of a message containing an audio attachment if no text was originally provided with that attachment"
Expand Down Expand Up @@ -795,6 +811,14 @@
"message": "Theme",
"description": "Header for theme settings"
},
"permissions": {
"message": "Permissions",
"description": "Header for permissions section of settings"
},
"mediaPermissionsDescription": {
"message": "Allow access to camera and microphone",
"description": "Description of the media permission description"
},
"clearDataHeader": {
"message": "Clear Data",
"description": "Header in the settings dialog for the section dealing with data deletion"
Expand Down
106 changes: 44 additions & 62 deletions about.html
Original file line number Diff line number Diff line change
@@ -1,68 +1,50 @@
<html>
<head>
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
<style>

body {
text-align: center;
background-color: #2090EA;
color: white;
font-size: 14px;
}

img {
margin-top: 1em;
}

a {
color: white;
}

</style>
<meta http-equiv="Content-Security-Policy"
content="default-src 'none';
child-src 'self';
connect-src 'self' https: wss:;
font-src 'self';
form-action 'self';
frame-src 'none';
img-src 'self' blob: data:;
media-src 'self' blob:;
object-src 'none';
script-src 'self';
style-src 'self' 'unsafe-inline';"
>
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
<style>
body {
text-align: center;
background-color: #2090EA;
color: white;
font-size: 14px;
}

img {
margin-top: 1em;
}

a {
color: white;
}
</style>
</head>
<body>

<img src='images/icon_250.png'>

<div>
<script>
document.write('v', window.getVersion());
</script>
</div>
<div>
<script>
const states = [];

if (window.getEnvironment() !== 'production') {
states.push(window.getEnvironment());
}
if (window.getAppInstance()) {
states.push(window.getAppInstance());
}

document.write(states.join(' - '));
</script>
</div>
<div>
<a href="https://signal.org">signal.org</a>
</div>
<br>
<div>
<a class="privacy" href="https://signal.org/legal">Terms &amp; Privacy Policy</a>
</div>

<script type='text/javascript' src='node_modules/jquery/dist/jquery.js'></script>
<script>
$(document).on('keyup', function(e) {
if (e.keyCode === 27) {
window.closeAbout();
}
});

$('.privacy').text(window.i18n('privacyPolicy'));
</script>


<img src='images/icon_250.png'>

<div class='version'></div>
<div class='environment'></div>
<div>
<a href="https://signal.org">signal.org</a>
</div>
<br>
<div>
<a class="privacy" href="https://signal.org/legal">Terms &amp; Privacy Policy</a>
</div>

<script type='text/javascript' src='node_modules/jquery/dist/jquery.js'></script>
<script type='text/javascript' src='js/about_start.js'></script>
</body>

</html>
4 changes: 3 additions & 1 deletion about_preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ window.getEnvironment = () => config.environment;
window.getVersion = () => config.version;
window.getAppInstance = () => config.appInstance;

window.closeAbout = () => ipc.send('close-about');
window.closeAbout = () => ipcRenderer.send('close-about');

window.i18n = i18n.setup(locale, localeMessages);

require('./js/logging');
36 changes: 26 additions & 10 deletions app/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,44 @@
const PERMISSIONS = {
// Allowed
fullscreen: true, // required to show videos in full-screen
media: true, // required for access to microphone, used for voice notes
notifications: true, // required to show OS notifications for new messages

// Off by default, can be enabled by user
media: false, // required for access to microphone, used for voice notes

// Not allowed
geolocation: false,
midiSysex: false,
openExternal: false, // we don't need this; we open links via 'will-navigate' event
pointerLock: false,
};

function _permissionHandler(webContents, permission, callback) {
if (PERMISSIONS[permission]) {
console.log(`Approving request for permission '${permission}'`);
return callback(true);
}
function _createPermissionHandler(userConfig) {
return (webContents, permission, callback) => {
// We default 'media' permission to false, but the user can override that
if (permission === 'media' && userConfig.get('mediaPermissions')) {
return true;
}

if (PERMISSIONS[permission]) {
console.log(`Approving request for permission '${permission}'`);
return callback(true);
}

console.log(`Denying request for permission '${permission}'`);
return callback(false);
console.log(`Denying request for permission '${permission}'`);
return callback(false);
};
}

function installPermissionsHandler({ session }) {
session.defaultSession.setPermissionRequestHandler(_permissionHandler);
function installPermissionsHandler({ session, userConfig }) {
// Setting the permission request handler to null first forces any permissions to be
// requested again. Without this, revoked permissions might still be available if
// they've already been used successfully.
session.defaultSession.setPermissionRequestHandler(null);

session.defaultSession.setPermissionRequestHandler(
_createPermissionHandler(userConfig)
);
}

module.exports = {
Expand Down
Loading

0 comments on commit ad43878

Please sign in to comment.