Fix popup build error

This commit is contained in:
Attila Dusnoki 2017-02-01 09:38:16 +01:00
parent 74c1350518
commit cce362dc39

View file

@ -256,17 +256,7 @@ pub fn get_descriptor_permission_state(permission_name: PermissionName ,
// if the feature is not allowed in non-secure contexcts, // if the feature is not allowed in non-secure contexcts,
// and let the user decide to grant the permission or not. // and let the user decide to grant the permission or not.
if !allowed_in_nonsecure_contexts(&permission_name) { if !allowed_in_nonsecure_contexts(&permission_name) {
if cfg!(target_os = "linux") { return prompt_user(permission_name);
match tinyfiledialogs::message_box_yes_no(DIALOG_TITLE,
&format!("{} {:?} ?", QUERY_DIALOG_MESSAGE, permission_name),
MessageBoxIcon::Question,
YesNo::No) {
YesNo::Yes => return PermissionState::Granted,
YesNo::No => return PermissionState::Denied,
};
} else {
return PermissionState::Denied;
}
} }
// TODO: Step 3: Store the invocation results // TODO: Step 3: Store the invocation results
@ -276,6 +266,23 @@ pub fn get_descriptor_permission_state(permission_name: PermissionName ,
PermissionState::Granted PermissionState::Granted
} }
#[cfg(target_os = "linux")]
fn prompt_user(permission_name: PermissionName) -> PermissionState {
match tinyfiledialogs::message_box_yes_no(DIALOG_TITLE,
&format!("{} {:?} ?", QUERY_DIALOG_MESSAGE, permission_name),
MessageBoxIcon::Question,
YesNo::No) {
YesNo::Yes => return PermissionState::Granted,
YesNo::No => return PermissionState::Denied,
};
}
#[cfg(not(target_os = "linux"))]
fn prompt_user(_permission_name: PermissionName) -> PermissionState {
// TODO popup only supported on linux
PermissionState::Denied
}
// https://w3c.github.io/permissions/#allowed-in-non-secure-contexts // https://w3c.github.io/permissions/#allowed-in-non-secure-contexts
fn allowed_in_nonsecure_contexts(permission_name: &PermissionName) -> bool { fn allowed_in_nonsecure_contexts(permission_name: &PermissionName) -> bool {
match *permission_name { match *permission_name {