1 module webkit2.SecurityManager; 2 3 private import glib.Str; 4 private import gobject.ObjectG; 5 private import webkit2.c.functions; 6 public import webkit2.c.types; 7 8 9 /** 10 * The #WebKitSecurityManager defines security settings for URI 11 * schemes in a #WebKitWebContext. Get it from the context with 12 * webkit_web_context_get_security_manager(), and use it to register a 13 * URI scheme with a certain security level, or to check if it already 14 * has it. 15 */ 16 public class SecurityManager : ObjectG 17 { 18 /** the main Gtk struct */ 19 protected WebKitSecurityManager* webKitSecurityManager; 20 21 /** Get the main Gtk struct */ 22 public WebKitSecurityManager* getSecurityManagerStruct(bool transferOwnership = false) 23 { 24 if (transferOwnership) 25 ownedRef = false; 26 return webKitSecurityManager; 27 } 28 29 /** the main Gtk struct as a void* */ 30 protected override void* getStruct() 31 { 32 return cast(void*)webKitSecurityManager; 33 } 34 35 /** 36 * Sets our main struct and passes it to the parent class. 37 */ 38 public this (WebKitSecurityManager* webKitSecurityManager, bool ownedRef = false) 39 { 40 this.webKitSecurityManager = webKitSecurityManager; 41 super(cast(GObject*)webKitSecurityManager, ownedRef); 42 } 43 44 45 /** */ 46 public static GType getType() 47 { 48 return webkit_security_manager_get_type(); 49 } 50 51 /** 52 * Register @scheme as a CORS (Cross-origin resource sharing) enabled scheme. 53 * This means that CORS requests are allowed. See W3C CORS specification 54 * http://www.w3.org/TR/cors/. 55 * 56 * Params: 57 * scheme = a URI scheme 58 */ 59 public void registerUriSchemeAsCorsEnabled(string scheme) 60 { 61 webkit_security_manager_register_uri_scheme_as_cors_enabled(webKitSecurityManager, Str.toStringz(scheme)); 62 } 63 64 /** 65 * Register @scheme as a display isolated scheme. This means that pages cannot 66 * display these URIs unless they are from the same scheme. 67 * 68 * Params: 69 * scheme = a URI scheme 70 */ 71 public void registerUriSchemeAsDisplayIsolated(string scheme) 72 { 73 webkit_security_manager_register_uri_scheme_as_display_isolated(webKitSecurityManager, Str.toStringz(scheme)); 74 } 75 76 /** 77 * Register @scheme as an empty document scheme. This means that 78 * they are allowed to commit synchronously. 79 * 80 * Params: 81 * scheme = a URI scheme 82 */ 83 public void registerUriSchemeAsEmptyDocument(string scheme) 84 { 85 webkit_security_manager_register_uri_scheme_as_empty_document(webKitSecurityManager, Str.toStringz(scheme)); 86 } 87 88 /** 89 * Register @scheme as a local scheme. This means that other non-local pages 90 * cannot link to or access URIs of this scheme. 91 * 92 * Params: 93 * scheme = a URI scheme 94 */ 95 public void registerUriSchemeAsLocal(string scheme) 96 { 97 webkit_security_manager_register_uri_scheme_as_local(webKitSecurityManager, Str.toStringz(scheme)); 98 } 99 100 /** 101 * Register @scheme as a no-access scheme. This means that pages loaded 102 * with this URI scheme cannot access pages loaded with any other URI scheme. 103 * 104 * Params: 105 * scheme = a URI scheme 106 */ 107 public void registerUriSchemeAsNoAccess(string scheme) 108 { 109 webkit_security_manager_register_uri_scheme_as_no_access(webKitSecurityManager, Str.toStringz(scheme)); 110 } 111 112 /** 113 * Register @scheme as a secure scheme. This means that mixed 114 * content warnings won't be generated for this scheme when 115 * included by an HTTPS page. 116 * 117 * Params: 118 * scheme = a URI scheme 119 */ 120 public void registerUriSchemeAsSecure(string scheme) 121 { 122 webkit_security_manager_register_uri_scheme_as_secure(webKitSecurityManager, Str.toStringz(scheme)); 123 } 124 125 /** 126 * Whether @scheme is considered as a CORS enabled scheme. 127 * See also webkit_security_manager_register_uri_scheme_as_cors_enabled(). 128 * 129 * Params: 130 * scheme = a URI scheme 131 * 132 * Returns: %TRUE if @scheme is a CORS enabled scheme or %FALSE otherwise. 133 */ 134 public bool uriSchemeIsCorsEnabled(string scheme) 135 { 136 return webkit_security_manager_uri_scheme_is_cors_enabled(webKitSecurityManager, Str.toStringz(scheme)) != 0; 137 } 138 139 /** 140 * Whether @scheme is considered as a display isolated scheme. 141 * See also webkit_security_manager_register_uri_scheme_as_display_isolated(). 142 * 143 * Params: 144 * scheme = a URI scheme 145 * 146 * Returns: %TRUE if @scheme is a display isolated scheme or %FALSE otherwise. 147 */ 148 public bool uriSchemeIsDisplayIsolated(string scheme) 149 { 150 return webkit_security_manager_uri_scheme_is_display_isolated(webKitSecurityManager, Str.toStringz(scheme)) != 0; 151 } 152 153 /** 154 * Whether @scheme is considered as an empty document scheme. 155 * See also webkit_security_manager_register_uri_scheme_as_empty_document(). 156 * 157 * Params: 158 * scheme = a URI scheme 159 * 160 * Returns: %TRUE if @scheme is an empty document scheme or %FALSE otherwise. 161 */ 162 public bool uriSchemeIsEmptyDocument(string scheme) 163 { 164 return webkit_security_manager_uri_scheme_is_empty_document(webKitSecurityManager, Str.toStringz(scheme)) != 0; 165 } 166 167 /** 168 * Whether @scheme is considered as a local scheme. 169 * See also webkit_security_manager_register_uri_scheme_as_local(). 170 * 171 * Params: 172 * scheme = a URI scheme 173 * 174 * Returns: %TRUE if @scheme is a local scheme or %FALSE otherwise. 175 */ 176 public bool uriSchemeIsLocal(string scheme) 177 { 178 return webkit_security_manager_uri_scheme_is_local(webKitSecurityManager, Str.toStringz(scheme)) != 0; 179 } 180 181 /** 182 * Whether @scheme is considered as a no-access scheme. 183 * See also webkit_security_manager_register_uri_scheme_as_no_access(). 184 * 185 * Params: 186 * scheme = a URI scheme 187 * 188 * Returns: %TRUE if @scheme is a no-access scheme or %FALSE otherwise. 189 */ 190 public bool uriSchemeIsNoAccess(string scheme) 191 { 192 return webkit_security_manager_uri_scheme_is_no_access(webKitSecurityManager, Str.toStringz(scheme)) != 0; 193 } 194 195 /** 196 * Whether @scheme is considered as a secure scheme. 197 * See also webkit_security_manager_register_uri_scheme_as_secure(). 198 * 199 * Params: 200 * scheme = a URI scheme 201 * 202 * Returns: %TRUE if @scheme is a secure scheme or %FALSE otherwise. 203 */ 204 public bool uriSchemeIsSecure(string scheme) 205 { 206 return webkit_security_manager_uri_scheme_is_secure(webKitSecurityManager, Str.toStringz(scheme)) != 0; 207 } 208 }