namespace Cef3 { using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; using Cef3.Interop; /// /// Class used to represent a frame in the browser window. When used in the /// browser process the methods of this class may be called on any thread unless /// otherwise indicated in the comments. When used in the render process the /// methods of this class may only be called on the main thread. /// public sealed unsafe partial class CefFrame { /// /// True if this object is currently attached to a valid frame. /// public bool IsValid { get { return cef_frame_t.is_valid(_self) != 0; } } /// /// Execute undo in this frame. /// public void Undo() { cef_frame_t.undo(_self); } /// /// Execute redo in this frame. /// public void Redo() { cef_frame_t.redo(_self); } /// /// Execute cut in this frame. /// public void Cut() { cef_frame_t.cut(_self); } /// /// Execute copy in this frame. /// public void Copy() { cef_frame_t.copy(_self); } /// /// Execute paste in this frame. /// public void Paste() { cef_frame_t.paste(_self); } /// /// Execute delete in this frame. /// public void Delete() { cef_frame_t.del(_self); } /// /// Execute select all in this frame. /// public void SelectAll() { cef_frame_t.select_all(_self); } /// /// Save this frame's HTML source to a temporary file and open it in the /// default text viewing application. This method can only be called from the /// browser process. /// public void ViewSource() { cef_frame_t.view_source(_self); } /// /// Retrieve this frame's HTML source as a string sent to the specified /// visitor. /// public void GetSource(CefStringVisitor visitor) { if (visitor == null) throw new ArgumentNullException("visitor"); cef_frame_t.get_source(_self, visitor.ToNative()); } /// /// Retrieve this frame's display text as a string sent to the specified /// visitor. /// public void GetText(CefStringVisitor visitor) { if (visitor == null) throw new ArgumentNullException("visitor"); cef_frame_t.get_text(_self, visitor.ToNative()); } /// /// Load the request represented by the |request| object. /// public void LoadRequest(CefRequest request) { if (request == null) throw new ArgumentNullException("request"); cef_frame_t.load_request(_self, request.ToNative()); } /// /// Load the specified |url|. /// public void LoadUrl(string url) { fixed (char* url_str = url) { var n_url = new cef_string_t(url_str, url != null ? url.Length : 0); cef_frame_t.load_url(_self, &n_url); } } /// /// Load the contents of |string_val| with the specified dummy |url|. |url| /// should have a standard scheme (for example, http scheme) or behaviors like /// link clicks and web security restrictions may not behave as expected. /// public void LoadString(string content, string url) { fixed (char* content_str = content) fixed (char* url_str = url) { var n_content = new cef_string_t(content_str, content != null ? content.Length : 0); var n_url = new cef_string_t(url_str, url != null ? url.Length : 0); cef_frame_t.load_string(_self, &n_content, &n_url); } } /// /// Execute a string of JavaScript code in this frame. The |script_url| /// parameter is the URL where the script in question can be found, if any. /// The renderer may request this URL to show the developer the source of the /// error. The |start_line| parameter is the base line number to use for error /// reporting. /// public void ExecuteJavaScript(string code, string url, int line) { fixed (char* code_str = code) fixed (char* url_str = url) { var n_code = new cef_string_t(code_str, code != null ? code.Length : 0); var n_url = new cef_string_t(url_str, url != null ? url.Length : 0); cef_frame_t.execute_java_script(_self, &n_code, &n_url, line); } } /// /// Returns true if this is the main (top-level) frame. /// public bool IsMain { get { return cef_frame_t.is_main(_self) != 0; } } /// /// Returns true if this is the focused frame. /// public bool IsFocused { get { return cef_frame_t.is_focused(_self) != 0; } } /// /// Returns the name for this frame. If the frame has an assigned name (for /// example, set via the iframe "name" attribute) then that value will be /// returned. Otherwise a unique name will be constructed based on the frame /// parent hierarchy. The main (top-level) frame will always have an empty name /// value. /// public string Name { get { var n_result = cef_frame_t.get_name(_self); return cef_string_userfree.ToString(n_result); } } /// /// Returns the globally unique identifier for this frame. /// public long Identifier { get { return cef_frame_t.get_identifier(_self); } } /// /// Returns the parent of this frame or NULL if this is the main (top-level) /// frame. /// public CefFrame Parent { get { return CefFrame.FromNativeOrNull( cef_frame_t.get_parent(_self) ); } } /// /// Returns the URL currently loaded in this frame. /// public string Url { get { var n_result = cef_frame_t.get_url(_self); return cef_string_userfree.ToString(n_result); } } /// /// Returns the browser that this frame belongs to. /// public CefBrowser Browser { get { return CefBrowser.FromNative( cef_frame_t.get_browser(_self) ); } } /// /// Get the V8 context associated with the frame. This method can only be /// called from the render process. /// public CefV8Context V8Context { get { return CefV8Context.FromNative( cef_frame_t.get_v8context(_self) ); } } /// /// Visit the DOM document. This method can only be called from the render /// process. /// public void VisitDom(CefDomVisitor visitor) { if (visitor == null) throw new ArgumentNullException("visitor"); cef_frame_t.visit_dom(_self, visitor.ToNative()); } } }