1 module webkit2webextension.Frame; 2 3 private import glib.Str; 4 private import gobject.ObjectG; 5 private import javascriptcore.Context; 6 private import javascriptcore.Value; 7 private import webkit2webextension.DOMObject; 8 private import webkit2webextension.ScriptWorld; 9 private import webkit2webextension.c.functions; 10 public import webkit2webextension.c.types; 11 12 13 /** */ 14 public class Frame : ObjectG 15 { 16 /** the main Gtk struct */ 17 protected WebKitFrame* webKitFrame; 18 19 /** Get the main Gtk struct */ 20 public WebKitFrame* getFrameStruct(bool transferOwnership = false) 21 { 22 if (transferOwnership) 23 ownedRef = false; 24 return webKitFrame; 25 } 26 27 /** the main Gtk struct as a void* */ 28 protected override void* getStruct() 29 { 30 return cast(void*)webKitFrame; 31 } 32 33 /** 34 * Sets our main struct and passes it to the parent class. 35 */ 36 public this (WebKitFrame* webKitFrame, bool ownedRef = false) 37 { 38 this.webKitFrame = webKitFrame; 39 super(cast(GObject*)webKitFrame, ownedRef); 40 } 41 42 43 /** */ 44 public static GType getType() 45 { 46 return webkit_frame_get_type(); 47 } 48 49 /** 50 * Gets the process-unique identifier of this #WebKitFrame. No other 51 * frame in the same web process will have the same ID; however, frames 52 * in other web processes may. 53 * 54 * Returns: the identifier of @frame 55 * 56 * Since: 2.26 57 */ 58 public ulong getId() 59 { 60 return webkit_frame_get_id(webKitFrame); 61 } 62 63 /** 64 * Gets the JavaScript execution context of @frame for the given #WebKitScriptWorld. 65 * 66 * Deprecated: Use webkit_frame_get_js_context_for_script_world() instead. 67 * 68 * Params: 69 * world = a #WebKitScriptWorld 70 * 71 * Returns: the JavaScript context of @frame for @world 72 * 73 * Since: 2.2 74 */ 75 public JSGlobalContextRef getJavascriptContextForScriptWorld(ScriptWorld world) 76 { 77 return webkit_frame_get_javascript_context_for_script_world(webKitFrame, (world is null) ? null : world.getScriptWorldStruct()); 78 } 79 80 /** 81 * Gets the global JavaScript execution context. Use this function to bridge 82 * between the WebKit and JavaScriptCore APIs. 83 * 84 * Deprecated: Use webkit_frame_get_js_context() instead. 85 * 86 * Returns: the global JavaScript context of @frame 87 * 88 * Since: 2.2 89 */ 90 public JSGlobalContextRef getJavascriptGlobalContext() 91 { 92 return webkit_frame_get_javascript_global_context(webKitFrame); 93 } 94 95 /** 96 * Get the JavaScript execution context of @frame. Use this function to bridge 97 * between the WebKit and JavaScriptCore APIs. 98 * 99 * Returns: the #JSCContext for the JavaScript execution context of @frame. 100 * 101 * Since: 2.22 102 */ 103 public Context getJsContext() 104 { 105 auto __p = webkit_frame_get_js_context(webKitFrame); 106 107 if(__p is null) 108 { 109 return null; 110 } 111 112 return ObjectG.getDObject!(Context)(cast(JSCContext*) __p, true); 113 } 114 115 /** 116 * Get the JavaScript execution context of @frame for the given #WebKitScriptWorld. 117 * 118 * Params: 119 * world = a #WebKitScriptWorld 120 * 121 * Returns: the #JSCContext for the JavaScript execution context of @frame for @world. 122 * 123 * Since: 2.22 124 */ 125 public Context getJsContextForScriptWorld(ScriptWorld world) 126 { 127 auto __p = webkit_frame_get_js_context_for_script_world(webKitFrame, (world is null) ? null : world.getScriptWorldStruct()); 128 129 if(__p is null) 130 { 131 return null; 132 } 133 134 return ObjectG.getDObject!(Context)(cast(JSCContext*) __p, true); 135 } 136 137 /** 138 * Get a #JSCValue referencing the given DOM object. The value is created in the JavaScript execution 139 * context of @frame. 140 * 141 * Params: 142 * domObject = a #WebKitDOMObject 143 * 144 * Returns: the #JSCValue referencing @dom_object. 145 * 146 * Since: 2.22 147 */ 148 public Value getJsValueForDomObject(DOMObject domObject) 149 { 150 auto __p = webkit_frame_get_js_value_for_dom_object(webKitFrame, (domObject is null) ? null : domObject.getDOMObjectStruct()); 151 152 if(__p is null) 153 { 154 return null; 155 } 156 157 return ObjectG.getDObject!(Value)(cast(JSCValue*) __p, true); 158 } 159 160 /** 161 * Get a #JSCValue referencing the given DOM object. The value is created in the JavaScript execution 162 * context of @frame for the given #WebKitScriptWorld. 163 * 164 * Params: 165 * domObject = a #WebKitDOMObject 166 * world = a #WebKitScriptWorld 167 * 168 * Returns: the #JSCValue referencing @dom_object 169 * 170 * Since: 2.22 171 */ 172 public Value getJsValueForDomObjectInScriptWorld(DOMObject domObject, ScriptWorld world) 173 { 174 auto __p = webkit_frame_get_js_value_for_dom_object_in_script_world(webKitFrame, (domObject is null) ? null : domObject.getDOMObjectStruct(), (world is null) ? null : world.getScriptWorldStruct()); 175 176 if(__p is null) 177 { 178 return null; 179 } 180 181 return ObjectG.getDObject!(Value)(cast(JSCValue*) __p, true); 182 } 183 184 /** 185 * Gets the current active URI of @frame. 186 * 187 * Returns: the current active URI of @frame or %NULL if nothing has been 188 * loaded yet. 189 * 190 * Since: 2.2 191 */ 192 public string getUri() 193 { 194 return Str.toString(webkit_frame_get_uri(webKitFrame)); 195 } 196 197 /** 198 * Gets whether @frame is the main frame of a #WebKitWebPage 199 * 200 * Returns: %TRUE if @frame is a main frame or %FALSE otherwise 201 * 202 * Since: 2.2 203 */ 204 public bool isMainFrame() 205 { 206 return webkit_frame_is_main_frame(webKitFrame) != 0; 207 } 208 }