chrome_types/
content_settings.rs

1use crate::sys::content_settings::camera::SetCameraContentSetting;
2use crate::sys::content_settings::clipboard::SetClipboardContentSetting;
3use crate::sys::content_settings::cookies::SetCookiesContentSetting;
4use crate::sys::content_settings::fullscreen::SetFullscreenContentSetting;
5use crate::sys::content_settings::javascript::SetJavascriptContentSetting;
6use crate::sys::content_settings::location::SetLocationContentSetting;
7use crate::sys::content_settings::microphone::SetMicrophoneContentSetting;
8use crate::sys::{CHROME, Chrome};
9use wasm_bindgen::prelude::*;
10
11pub async fn allow_camera(pattern: &str) -> Result<(), JsValue> {
12  let details = SetCameraContentSetting::allow(pattern);
13  CHROME
14    .with(Chrome::content_settings)
15    .camera()
16    .set(details)
17    .await
18}
19
20pub async fn block_camera(pattern: &str) -> Result<(), JsValue> {
21  let details = SetCameraContentSetting::block(pattern);
22  CHROME
23    .with(Chrome::content_settings)
24    .camera()
25    .set(details)
26    .await
27}
28
29pub async fn allow_clipboard(pattern: &str) -> Result<(), JsValue> {
30  let details = SetClipboardContentSetting::allow(pattern);
31  CHROME
32    .with(Chrome::content_settings)
33    .clipboard()
34    .set(details)
35    .await
36}
37
38pub async fn block_clipboard(pattern: &str) -> Result<(), JsValue> {
39  let details = SetClipboardContentSetting::block(pattern);
40  CHROME
41    .with(Chrome::content_settings)
42    .clipboard()
43    .set(details)
44    .await
45}
46
47pub async fn allow_cookies(pattern: &str) -> Result<(), JsValue> {
48  let details = SetCookiesContentSetting::allow(pattern);
49  CHROME
50    .with(Chrome::content_settings)
51    .cookies()
52    .set(details)
53    .await
54}
55
56pub async fn block_cookies(pattern: &str) -> Result<(), JsValue> {
57  let details = SetCookiesContentSetting::block(pattern);
58  CHROME
59    .with(Chrome::content_settings)
60    .cookies()
61    .set(details)
62    .await
63}
64
65pub async fn allow_fullscreen(pattern: &str) -> Result<(), JsValue> {
66  let details = SetFullscreenContentSetting::allow(pattern);
67  CHROME
68    .with(Chrome::content_settings)
69    .fullscreen()
70    .set(details)
71    .await
72}
73
74pub async fn allow_javascript(pattern: &str) -> Result<(), JsValue> {
75  let details = SetJavascriptContentSetting::allow(pattern);
76  CHROME
77    .with(Chrome::content_settings)
78    .javascript()
79    .set(details)
80    .await
81}
82
83pub async fn block_javascript(pattern: &str) -> Result<(), JsValue> {
84  let details = SetJavascriptContentSetting::block(pattern);
85  CHROME
86    .with(Chrome::content_settings)
87    .javascript()
88    .set(details)
89    .await
90}
91
92pub async fn allow_location(pattern: &str) -> Result<(), JsValue> {
93  let details = SetLocationContentSetting::allow(pattern);
94  CHROME
95    .with(Chrome::content_settings)
96    .location()
97    .set(details)
98    .await
99}
100
101pub async fn block_location(pattern: &str) -> Result<(), JsValue> {
102  let details = SetLocationContentSetting::block(pattern);
103  CHROME
104    .with(Chrome::content_settings)
105    .location()
106    .set(details)
107    .await
108}
109
110pub async fn allow_microphone(pattern: &str) -> Result<(), JsValue> {
111  let details = SetMicrophoneContentSetting::allow(pattern);
112  CHROME
113    .with(Chrome::content_settings)
114    .microphone()
115    .set(details)
116    .await
117}
118
119pub async fn block_microphone(pattern: &str) -> Result<(), JsValue> {
120  let details = SetMicrophoneContentSetting::block(pattern);
121  CHROME
122    .with(Chrome::content_settings)
123    .microphone()
124    .set(details)
125    .await
126}