protected void InternalLoadContent(string content, string url, string contentType) { using (var sContentType = new nsACString(contentType)) using (var sUtf8 = new nsACString("UTF8")) { ByteArrayInputStream inputStream = null; try { inputStream = ByteArrayInputStream.Create(System.Text.Encoding.UTF8.GetBytes(content != null ? content : string.Empty)); nsIDocShell docShell = Xpcom.QueryInterface <nsIDocShell> (this.WebBrowser); nsIURI uri = null; if (!string.IsNullOrEmpty(url)) { uri = IOService.CreateNsIUri(url); } nsIDocShellLoadInfo l = null; if (true) { l = Xpcom.QueryInterface <nsIDocShellLoadInfo> (this.WebBrowser); docShell.CreateLoadInfo(ref l); l.SetLoadTypeAttribute(new IntPtr(16)); } docShell.LoadStream(inputStream, uri, sContentType, sUtf8, l); Marshal.ReleaseComObject(docShell); if (l != null) { Marshal.ReleaseComObject(l); } } finally { if (inputStream != null) { inputStream.Close(); } } } }
protected override void OnHandleDestroyed(EventArgs e) { if (BaseWindow != null) { this.Stop(); WindowMediator.UnregisterWindow(this); if (_weakRef != null) { _weakRef.Dispose(); _weakRef = null; } nsIDocShell docShell = Xpcom.QueryInterface <nsIDocShell>(BaseWindow); if (docShell != null && !docShell.IsBeingDestroyed()) { try { var window = Xpcom.QueryInterface <nsIDOMWindow>(docShell); if (window != null) { try { var w = new WebIDL.Window(window, (nsISupports)window); if (!w.Closed) { w.Close(); } } finally { Xpcom.FreeComObject(ref window); } } } finally { Xpcom.FreeComObject(ref docShell); } } if (EventTarget != null) { RemoveFrameEvents(); DetachEvents(); EventTarget.Dispose(); EventTarget = null; } BaseWindow.Destroy(); Xpcom.FreeComObject(ref CommandParams); var webBrowserFocus = this.WebBrowserFocus; this.WebBrowserFocus = null; Xpcom.FreeComObject(ref webBrowserFocus); Xpcom.FreeComObject(ref WebNav); Xpcom.FreeComObject(ref BaseWindow); Xpcom.FreeComObject(ref WebBrowser); if (this.menu != null) { this.menu.MenuItems.Clear(); this.menu.Dispose(); this.menu = null; } #if GTK if (m_wrapper != null) { m_wrapper.Dispose(); m_wrapper = null; } #endif } base.OnHandleDestroyed(e); }
protected override void OnHandleDestroyed(EventArgs e) { if (BaseWindow != null) { this.Stop(); nsIDocShell docShell = Xpcom.QueryInterface <nsIDocShell>(BaseWindow); if (docShell != null && !docShell.IsBeingDestroyed()) { try { var window = Xpcom.QueryInterface <nsIDOMWindow>(docShell); if (window != null) { try { if (!window.GetClosedAttribute()) { window.Close(); } } finally { Xpcom.FreeComObject(ref window); } } } finally { Xpcom.FreeComObject(ref docShell); } } if (EventTarget != null) { //Remove Event Listener foreach (string sEventType in this.DefaultEvents) { using (var eventType = new nsAString(sEventType)) { EventTarget.Instance.RemoveEventListener(eventType, this, true); } } EventTarget.Dispose(); EventTarget = null; } BaseWindow.Destroy(); Xpcom.FreeComObject(ref CommandParams); var webBrowserFocus = this.WebBrowserFocus; this.WebBrowserFocus = null; Xpcom.FreeComObject(ref webBrowserFocus); Xpcom.FreeComObject(ref WebNav); Xpcom.FreeComObject(ref BaseWindow); Xpcom.FreeComObject(ref WebBrowser); #if GTK if (m_wrapper != null) { m_wrapper.Dispose(); } #endif } base.OnHandleDestroyed(e); }
public nsIPrincipal GetDocShellCodebasePrincipal(nsIURI uri, nsIDocShell docShell) { return _ssm.GetSystemPrincipal(); }
public void SetDocShell(nsIDocShell docShell) { throw new NotImplementedException(); }