public static IntPtr WebBrowserGetInterface <T>(T geckoWebBrowser, nsIWebBrowser instance, ref Guid uuid) where T : IGeckoWebBrowser { object obj = geckoWebBrowser; // note: when a new window is created, gecko calls GetInterface on the webbrowser to get a DOMWindow in order // to set the starting url if (instance != null) { if (uuid == typeof(nsIDOMWindow).GUID) { obj = instance.GetContentDOMWindowAttribute(); } else if (uuid == typeof(nsIDOMDocument).GUID) { obj = instance.GetContentDOMWindowAttribute().GetDocumentAttribute(); } } IntPtr ppv, pUnk = Marshal.GetIUnknownForObject(obj); Marshal.QueryInterface(pUnk, ref uuid, out ppv); Marshal.Release(pUnk); return(ppv); }
public void AddHandler(NavigationRequestedEventHandler value) { if (Events[WebBrowser.NavigationRequestedEvent] == null) { if (owner.Navigation != null) { nsIWebBrowser browser = (nsIWebBrowser)owner.navigation.navigation; browser.setParentURIContentListener(this); } } Events.AddHandler(WebBrowser.NavigationRequestedEvent, value); }
private void Main_Load(object sender, EventArgs e) { // this.WindowState = System.Windows.Forms.FormWindowState.Maximized; sUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0.1 Waterfox/52.0.1"; referrer = "http://google.com"; // default browser settings GeckoPreferences.Default["media.peerconnection.enabled"] = false; GeckoPreferences.Default["network.proxy.http_port"] = 80; GeckoPreferences.Default["network.proxy.http"] = "localhost"; GeckoPreferences.Default["network.proxy.ssl_port"] = 80; GeckoPreferences.Default["network.proxy.ssl"] = "localhost"; GeckoPreferences.Default["general.useragent.override"] = sUserAgent; GeckoPreferences.User["browser.cache.disk.enable"] = false; Gecko.GeckoPreferences.User["network.http.pipelining"] = true; GeckoPreferences.User["browser.xul.error_pages.enabled"] = true; Gecko.GeckoPreferences.Default["browser.cache.disk.enable"] = false; Gecko.GeckoPreferences.User["browser.cache.disk.enable"] = false; GeckoPreferences.Default["browser.xul.error_pages.enabled"] = true; textbox_navigate.Items.Equals(geckoWebBrowser1.History); var field = typeof(GeckoWebBrowser).GetField("WebBrowser", BindingFlags.Instance | BindingFlags.NonPublic); nsIWebBrowser nsIWebBrowser = (nsIWebBrowser)field.GetValue(geckoWebBrowser1); //this might be null if called right before initialization of browser Xpcom.QueryInterface <nsILoadContext>(nsIWebBrowser).SetPrivateBrowsing(true); geckoWebBrowser1.Navigate("http://google.com", (Gecko.GeckoLoadFlags.ReplaceHistory | Gecko.GeckoLoadFlags.BypassCache | Gecko.GeckoLoadFlags.BypassProxy), referrer, null, null); //home page // disable buttons button_skip.Enabled = false; button_clearurl.Enabled = false; button_clearproxies.Enabled = false; button_clearuseragents.Enabled = false; button_addref.Enabled = false; button_addurl.Enabled = false; button_adduseragent.Enabled = false; button_setref.Enabled = false; button_stop.Enabled = false; onepage = 0; }
void nsIWebBrowserChrome.SetWebBrowserAttribute(nsIWebBrowser aWebBrowser) { }
protected override void OnHandleCreated(EventArgs e) { if (!this.DesignMode) { Xpcom.Initialize(); #if !NO_CUSTOM_PROMPT_SERVICE PromptServiceFactory.Register(); #endif WindowCreator.Register(); //CertificateDialogsFactory.Register(); //ToolTipTextProviderFactory.Register(); WebBrowser = Xpcom.CreateInstance<nsIWebBrowser>("@mozilla.org/embedding/browser/nsWebBrowser;1"); WebBrowserFocus = (nsIWebBrowserFocus)WebBrowser; BaseWindow = (nsIBaseWindow)WebBrowser; WebNav = (nsIWebNavigation)WebBrowser; WebBrowser.SetContainerWindow(this); //int type = ((this.ChromeFlags & (int)GeckoWindowFlags.OpenAsChrome) != 0) ? nsIDocShellTreeItemConstants.typeChromeWrapper : nsIDocShellTreeItemConstants.typeContentWrapper; //nsIDocShellTreeItem shellTreeItem = Xpcom.QueryInterface<nsIDocShellTreeItem>(WebBrowser); //if (shellTreeItem != null) // shellTreeItem.SetItemType(type); //else //{ // nsIDocShellTreeItem19 treeItem19 = Xpcom.QueryInterface<nsIDocShellTreeItem19>(WebBrowser); // if (treeItem19 != null) // treeItem19.SetItemType(type); //} BaseWindow.InitWindow(this.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height); BaseWindow.Create(); Guid nsIWebProgressListenerGUID = typeof(nsIWebProgressListener).GUID; WebBrowser.AddWebBrowserListener(this, ref nsIWebProgressListenerGUID); nsIDOMEventTarget target = Xpcom.QueryInterface<nsIDOMWindow2>(WebBrowser.GetContentDOMWindow()).GetWindowRoot(); target.AddEventListener(new nsAString("submit"), this, true); target.AddEventListener(new nsAString("keydown"), this, true); target.AddEventListener(new nsAString("keyup"), this, true); target.AddEventListener(new nsAString("mousemove"), this, true); target.AddEventListener(new nsAString("mouseover"), this, true); target.AddEventListener(new nsAString("mouseout"), this, true); target.AddEventListener(new nsAString("mousedown"), this, true); target.AddEventListener(new nsAString("mouseup"), this, true); target.AddEventListener(new nsAString("click"), this, true); // history WebNav.GetSessionHistory().AddSHistoryListener(this); BaseWindow.SetVisibility(true); if ((this.ChromeFlags & (int)GeckoWindowFlags.OpenAsChrome) == 0) { // navigating to about:blank allows drag & drop to work properly before a page has been loaded into the browser Navigate("about:blank"); } // this fix prevents the browser from crashing if the first page loaded is invalid (missing file, invalid URL, etc) Document.Cookie = ""; } base.OnHandleCreated(e); }
void nsIWebBrowserChrome.SetWebBrowser(nsIWebBrowser webBrowser) { this.WebBrowser = webBrowser; }
void nsIWebBrowserChrome.SetWebBrowserAttribute(nsIWebBrowser webBrowser) { this.WebBrowser = webBrowser; }
protected override void OnHandleCreated(EventArgs e) { #if GTK if (Xpcom.IsMono) { base.OnHandleCreated(e); m_wrapper.Init(); } #endif if (!this.DesignMode) { Xpcom.Initialize(); #if !NO_CUSTOM_PROMPT_SERVICE PromptServiceFactory.Register(); #endif WindowCreator.Register(); LauncherDialogFactory.Register(); //CertificateDialogsFactory.Register(); //ToolTipTextProviderFactory.Register(); WebBrowser = Xpcom.CreateInstance<nsIWebBrowser>("@mozilla.org/embedding/browser/nsWebBrowser;1"); WebBrowserFocus = (nsIWebBrowserFocus)WebBrowser; BaseWindow = (nsIBaseWindow)WebBrowser; WebNav = (nsIWebNavigation)WebBrowser; WebBrowser.SetContainerWindowAttribute(this); //int type = ((this.ChromeFlags & (int)GeckoWindowFlags.OpenAsChrome) != 0) ? nsIDocShellTreeItemConstants.typeChromeWrapper : nsIDocShellTreeItemConstants.typeContentWrapper; //nsIDocShellTreeItem shellTreeItem = Xpcom.QueryInterface<nsIDocShellTreeItem>(WebBrowser); //if (shellTreeItem != null) // shellTreeItem.SetItemType(type); //else //{ // nsIDocShellTreeItem19 treeItem19 = Xpcom.QueryInterface<nsIDocShellTreeItem19>(WebBrowser); // if (treeItem19 != null) // treeItem19.SetItemType(type); //} #if GTK if (Xpcom.IsMono) BaseWindow.InitWindow(m_wrapper.BrowserWindow.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height); else #endif BaseWindow.InitWindow(this.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height); BaseWindow.Create(); Guid nsIWebProgressListenerGUID = typeof(nsIWebProgressListener).GUID; WebBrowser.AddWebBrowserListener(this, ref nsIWebProgressListenerGUID); nsIDOMEventTarget target = Xpcom.QueryInterface<nsIDOMWindow>(WebBrowser.GetContentDOMWindowAttribute()).GetWindowRootAttribute(); target.AddEventListener(new nsAString("submit"), this, true, true, 2); target.AddEventListener(new nsAString("keydown"), this, true, true, 2); target.AddEventListener(new nsAString("keyup"), this, true, true, 2); target.AddEventListener(new nsAString("keypress"), this, true, true, 2); target.AddEventListener(new nsAString("mousemove"), this, true, true, 2); target.AddEventListener(new nsAString("mouseover"), this, true, true, 2); target.AddEventListener(new nsAString("mouseout"), this, true, true, 2); target.AddEventListener(new nsAString("mousedown"), this, true, true, 2); target.AddEventListener(new nsAString("mouseup"), this, true, true, 2); target.AddEventListener(new nsAString("click"), this, true, true, 2); target.AddEventListener(new nsAString("dblclick"), this, true, true, 2); target.AddEventListener(new nsAString("compositionstart"), this, true, true, 2); target.AddEventListener(new nsAString("compositionend"), this, true, true, 2); target.AddEventListener(new nsAString("contextmenu"), this, true, true, 2); target.AddEventListener(new nsAString("DOMMouseScroll"), this, true, true, 2); target.AddEventListener(new nsAString("focus"), this, true, true, 2); // Load event added here rather than DOMDocument as DOMDocument recreated when navigating // ths losing attached listener. target.AddEventListener(new nsAString("load"), this, true, true, 2); target.AddEventListener(new nsAString("change"), this, true, true, 2); // history if (WebNav.GetSessionHistoryAttribute() != null) WebNav.GetSessionHistoryAttribute().AddSHistoryListener(this); BaseWindow.SetVisibilityAttribute(true); // this fix prevents the browser from crashing if the first page loaded is invalid (missing file, invalid URL, etc) Document.Cookie = ""; } base.OnHandleCreated(e); }
public static nsIWebBrowser GetProxy(Mono.WebBrowser.IWebBrowser control, nsIWebBrowser obj) { object o = Base.GetProxyForObject(control, typeof(nsIWebBrowser).GUID, obj); return(o as nsIWebBrowser); }
void nsIWebBrowserChrome.SetWebBrowserAttribute(nsIWebBrowser aWebBrowser) { }
private void AssignWebBrowser(nsIWebBrowser webBrowser) { m_WebBrowser = webBrowser; m_BaseWindow = (nsIBaseWindow)m_WebBrowser; m_WebNavigation = new Lazy<nsIWebNavigation>(() => (nsIWebNavigation)m_WebBrowser); m_WebProgress = new Lazy<nsIWebProgress>(() => XpcomHelper.RequestInterface<nsIWebProgress>(m_WebBrowser)); m_WebBrowserFocus = new Lazy<nsIWebBrowserFocus>(() => (nsIWebBrowserFocus)m_WebBrowser); m_CommandManager = new Lazy<nsICommandManager>(() => XpcomHelper.RequestInterface<nsICommandManager>(m_WebBrowser)); m_ClipboardCommands = new Lazy<ClipboardCommands>(() => new ClipboardCommands(XpcomHelper.RequestInterface<nsIClipboardCommands>(m_WebBrowser))); m_DocShell = new Lazy<nsIDocShell>(() => XpcomHelper.RequestInterface<nsIDocShell>(m_WebBrowser)); m_WebBrowser.ContainerWindow = this; Size containerSize = Container.GetInnerSize(); BaseWindow.InitWindow(Container.GetHandle(), null, 0, 0, containerSize.Width, containerSize.Height); BaseWindow.Create(); m_WebBrowser.AddWebBrowserListener(this, typeof(nsIWebProgressListener).GUID); m_WebBrowser.ParentURIContentListener = this; BaseWindow.Visibility = true; }
public static nsIWebBrowser GetProxy (Mono.WebBrowser.IWebBrowser control, nsIWebBrowser obj) { object o = Base.GetProxyForObject (control, typeof(nsIWebBrowser).GUID, obj); return o as nsIWebBrowser; }