-
Notifications
You must be signed in to change notification settings - Fork 517
Expand file tree
/
Copy pathSecnarioFileTypePolicy.html
More file actions
73 lines (69 loc) · 2.59 KB
/
SecnarioFileTypePolicy.html
File metadata and controls
73 lines (69 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<title>ScenarioFileTypePolicy</title>
<script>
document.addEventListener('DOMContentLoaded', () => {
async function saveFile() {
let ext = document.getElementById("extensionText");
// Show the save file picker
const newHandle = await window.showSaveFilePicker({suggestedName:`sample_file.${ext.value}`});
// Write the content to the selected file
const writable = await newHandle.createWritable();
await writable.write("sample sentence");
await writable.close();
}
document.getElementById('showSaveFilePickerButton').addEventListener('click', saveFile);
});
function enable_smartscreen() {
window.chrome.webview.postMessage("enable_smartscreen");
}
function disable_smartscreen() {
window.chrome.webview.postMessage("disable_smartscreen");
}
function allow_exe() {
window.chrome.webview.postMessage("allow_exe");
}
function block_exe() {
window.chrome.webview.postMessage("block_exe");
}
function clear_exe_policy() {
window.chrome.webview.postMessage("clear_exe_policy");
}
</script>
</head>
<body>
<h1>File Type Policy API Demo Page</h1>
<p>Two customized example rules in this demo:</p>
<p>1. Smoothly save *.eml file without file extension warning</p>
<p>2. Intentionally block save *.iso file</p>
<p>3. Block or bypass *.exe file based on configuration</p>
<p>4. Block or bypass *.exe file based on popup response</p>
<p>
<button onclick="allow_exe()">Allow exe</button>
</p>
<p>
<button onclick="block_exe()">Block exe</button>
</p>
<p>
<button onclick="clear_exe_policy()">Clear exe policy</button>
</p>
<h2>File Type Policy API for Save File</h2>
<p>
Please enter a file extension: <input type="text" id="extensionText" placeholder="try eml or iso" />
<button id="showSaveFilePickerButton">save</button>
</p>
<br>
<hr />
<h2>File Type Policy API for download</h2>
<br />
<button onclick="enable_smartscreen()">Enable Smartscreen</button>
<br />
<br />
<button onclick="disable_smartscreen()">Disable Smartscreen</button>
<br />
<a href="https://appassets.example/sample.exe" id="download_exe" download>Download exe file</a>
<br />
<a href="https://appassets.example/sample.emlx" id="download_emlx" download>Download emlx file</a>
</body>
</html>