nsIWebBrowserChrome nsIWindowCreator.CreateChromeWindow(nsIWebBrowserChrome parent, UInt32 chromeFlags)
			{
				Trace.TraceInformation("nsIWindowCreator.CreateChromeWindow");

				var browser = parent as WebBrowser;
				if (browser == null)
				{
					Trace.TraceWarning("Can't get Browser object");
					return null;
				}

				var e = new CreateWindowEventArgs((ChromeFlags)chromeFlags, null);
				browser.Events.Raise(EventKey.CreateWindow, e);
				return !e.Cancel ? e.Window : null;
			}
			nsIWebBrowserChrome nsIWindowCreator2.CreateChromeWindow2(nsIWebBrowserChrome parent, UInt32 chromeFlags, UInt32 contextFlags, nsIURI uri, out Boolean cancel)
			{
				Trace.TraceInformation("nsIWindowCreator2.CreateChromeWindow2");

				var browser = parent as WebBrowser;
				if (browser == null)
				{
					Trace.TraceWarning("Can't get Browser object");

					cancel = true;
					return null;
				}

				var e = new CreateWindowEventArgs((ChromeFlags)chromeFlags, uri.ToUri());
				browser.Events.Raise(EventKey.CreateWindow, e);
				cancel = e.Cancel;
				return !e.Cancel ? e.Window : null;
			}
Esempio n. 3
0
        public static nsIWebBrowserChrome GetProxy(Mono.WebBrowser.IWebBrowser control, nsIWebBrowserChrome obj)
        {
            object o = Base.GetProxyForObject(control, typeof(nsIWebBrowserChrome).GUID, obj);

            return(o as nsIWebBrowserChrome);
        }
            public nsIWebBrowserChrome CreateChromeWindow(nsIWebBrowserChrome parent, uint chromeFlags)
            {
                // for chrome windows, we can use the AppShellService to create the window using some built-in xulrunner code
                GeckoWindowFlags flags = (GeckoWindowFlags)chromeFlags;
                if ((flags & GeckoWindowFlags.OpenAsChrome) != 0)
                {
                      // obtain the services we need
                      nsIAppShellService appShellService = Xpcom.GetService<nsIAppShellService>("@mozilla.org/appshell/appShellService;1");
                      object appShell = Xpcom.GetService(new Guid("2d96b3df-c051-11d1-a827-0040959a28c9"));

                      // create the child window
                      nsIXULWindow xulChild = appShellService.CreateTopLevelWindow(null, null, chromeFlags, -1, -1, appShell);

                      // this little gem allows the GeckoWebBrowser to be properly activated when it gains the focus again
                      if (parent is GeckoWebBrowser && (flags & GeckoWindowFlags.OpenAsDialog) != 0)
                      {
                        EventHandler gotFocus = null;
                        gotFocus = delegate (object sender, EventArgs e)
                        {
                            (sender as GeckoWebBrowser).GotFocus -= gotFocus;
                            (sender as GeckoWebBrowser).WebBrowserFocus.Activate();
                        };
                        (parent as GeckoWebBrowser).GotFocus += gotFocus;
                      }

                      // return the chrome
                      return Xpcom.QueryInterface<nsIWebBrowserChrome>(xulChild);
                }

                GeckoWebBrowser browser = parent as GeckoWebBrowser;
                if (browser != null)
                {
                    GeckoCreateWindowEventArgs e = new GeckoCreateWindowEventArgs((GeckoWindowFlags)chromeFlags);
                    browser.OnCreateWindow(e);

                    if (e.WebBrowser != null)
                    {
                        // set flags
                        ((nsIWebBrowserChrome)e.WebBrowser).SetChromeFlags((int)chromeFlags);
                        return e.WebBrowser;
                    }

                    System.Media.SystemSounds.Beep.Play();

                    // prevents crash
                    return new GeckoWebBrowser();
                }
                return null;
            }
Esempio n. 5
0
		public static nsIWebBrowserChrome GetProxy (Mono.WebBrowser.IWebBrowser control, nsIWebBrowserChrome obj)
		{
			object o = Base.GetProxyForObject (control, typeof(nsIWebBrowserChrome).GUID, obj);
			return o as nsIWebBrowserChrome;
		}
Esempio n. 6
0
			public nsIWebBrowserChrome CreateChromeWindow(nsIWebBrowserChrome parent, uint chromeFlags)
			{
				GeckoWebBrowser browser = parent as GeckoWebBrowser;
				if (browser != null)
				{
					GeckoCreateWindowEventArgs e = new GeckoCreateWindowEventArgs((GeckoWindowFlags)chromeFlags);
					browser.OnCreateWindow(e);
					
					if (e.WebBrowser != null)
					{
						// set flags
						((nsIWebBrowserChrome)e.WebBrowser).SetChromeFlags((int)chromeFlags);
						return e.WebBrowser;
					}
					
					System.Media.SystemSounds.Beep.Play();
					
					// prevents crash
					return new GeckoWebBrowser();
				}
				return null;
			}
			nsIWebBrowserChrome nsIWindowCreator2.CreateChromeWindow(nsIWebBrowserChrome parent, UInt32 chromeFlags)
			{
				return ((nsIWindowCreator)this).CreateChromeWindow(parent, chromeFlags);
			}
Esempio n. 8
0
			public nsIWebBrowserChrome CreateChromeWindow2(nsIWebBrowserChrome parent, uint chromeFlags, uint contextFlags, nsIURI uri, ref bool cancel)
			{
				return DoCreateChromeWindow(parent, chromeFlags, contextFlags, uri, ref cancel);
			}
Esempio n. 9
0
			public nsIWebBrowserChrome CreateChromeWindow(nsIWebBrowserChrome parent, uint chromeFlags)
			{
				bool cancel = false;
				return DoCreateChromeWindow(parent, chromeFlags, 0, null, ref cancel);
			}
Esempio n. 10
0
			private nsIWebBrowserChrome DoCreateChromeWindow(nsIWebBrowserChrome parent, uint chromeFlags, uint contextFlags, nsIURI uri, ref bool cancel)
			{
				var url = "";
				if (uri != null)
					url = (nsString.Get(uri.GetSpecAttribute)).ToString();
				else
					url = "about:blank";

				// for chrome windows, we can use the AppShellService to create the window using some built-in xulrunner code
				GeckoWindowFlags flags = (GeckoWindowFlags)chromeFlags;
				if ((flags & GeckoWindowFlags.OpenAsChrome) != 0)
				{
				      // obtain the services we need
				     // nsIAppShellService appShellService = Xpcom.GetService<nsIAppShellService>("@mozilla.org/appshell/appShellService;1");
				      
				      // create the child window
				      nsIXULWindow xulChild = AppShellService.CreateTopLevelWindow(null, null, chromeFlags, -1, -1);
				      
				      // this little gem allows the GeckoWebBrowser to be properly activated when it gains the focus again
				      if (parent is GeckoWebBrowser && (flags & GeckoWindowFlags.OpenAsDialog) != 0)
				      {
						EventHandler gotFocus = null;
						gotFocus = delegate (object sender, EventArgs e)
						{
							var geckoWebBrowser = (GeckoWebBrowser)sender;
							geckoWebBrowser.GotFocus -= gotFocus;
							
							if (geckoWebBrowser.WebBrowserFocus != null)
								geckoWebBrowser.WebBrowserFocus.Activate();
						};
						(parent as GeckoWebBrowser).GotFocus += gotFocus;
				      }
				      
				      // return the chrome
				      return Xpcom.QueryInterface<nsIWebBrowserChrome>(xulChild);
				}
				
				GeckoWebBrowser browser = parent as GeckoWebBrowser;
				if (browser != null)
				{
					var e = new GeckoCreateWindow2EventArgs(flags, url);
					if (uri != null) // called by CreateChromeWindow2()
						browser.OnCreateWindow2(e);
					browser.OnCreateWindow(e);

					if (e.Cancel)
					{
					    cancel = true;
					    return null;
					}

					if (e.WebBrowser != null)
					{
						// set flags
						((nsIWebBrowserChrome)e.WebBrowser).SetChromeFlagsAttribute(chromeFlags);
						return e.WebBrowser;
					}
					
					nsIXULWindow xulChild = AppShellService.CreateTopLevelWindow(null, null, chromeFlags, e.InitialWidth, e.InitialHeight);
					return Xpcom.QueryInterface<nsIWebBrowserChrome>(xulChild);									
				}
				return null;
			}
            public nsIWebBrowserChrome CreateChromeWindow2(nsIWebBrowserChrome parent, uint chromeFlags, uint contextFlags, nsIURI uri, ref bool cancel)
            {
                GeckoWebBrowser browser = parent as GeckoWebBrowser;
                if (browser != null)
                {
                    var url = "";
                    if (uri != null)
                    {
                        url = (nsString.Get(uri.GetSpecAttribute)).ToString();
                    }
                    else
                    {
                        url = "about:blank";
                    }

                    GeckoCreateWindow2EventArgs e = new GeckoCreateWindow2EventArgs((GeckoWindowFlags)chromeFlags, url);
                    e.WebBrowser = browser;

                    browser.OnCreateWindow2(e);

                    if (e.Cancel)
                    {
                        cancel = true;
                        return null;
                    }
                }

                return CreateChromeWindow(parent, chromeFlags);
            }
            public nsIWebBrowserChrome CreateChromeWindow(nsIWebBrowserChrome parent, uint chromeFlags)
            {
                // for chrome windows, we can use the AppShellService to create the window using some built-in xulrunner code
                GeckoWindowFlags flags = (GeckoWindowFlags)chromeFlags;
                if ((flags & GeckoWindowFlags.OpenAsChrome) != 0)
                {
                    // obtain the services we need
                    // nsIAppShellService appShellService = Xpcom.GetService<nsIAppShellService>("@mozilla.org/appshell/appShellService;1");

                    // create the child window
                    nsIXULWindow xulChild = AppShellService.CreateTopLevelWindow(null, null, chromeFlags, -1, -1);

                    // this little gem allows the GeckoWebBrowser to be properly activated when it gains the focus again
                    if (parent is GeckoWebBrowser && (flags & GeckoWindowFlags.OpenAsDialog) != 0)
                    {
                        EventHandler gotFocus = null;
                        gotFocus = delegate(object sender, EventArgs e)
                        {
                            var geckoWebBrowser = (GeckoWebBrowser)sender;
                            geckoWebBrowser.GotFocus -= gotFocus;

                            if (geckoWebBrowser.WebBrowserFocus != null)
                                geckoWebBrowser.WebBrowserFocus.Activate();
                        };
                        (parent as GeckoWebBrowser).GotFocus += gotFocus;
                    }

                    // return the chrome
                    return Xpcom.QueryInterface<nsIWebBrowserChrome>(xulChild);
                }

                GeckoWebBrowser browser = parent as GeckoWebBrowser;
                if (browser != null)
                {
                    GeckoCreateWindowEventArgs e = new GeckoCreateWindowEventArgs((GeckoWindowFlags)chromeFlags);
                    browser.OnCreateWindow(e);

                    if (e.WebBrowser != null)
                    {
                        // set flags
                        ((nsIWebBrowserChrome)e.WebBrowser).SetChromeFlagsAttribute(chromeFlags);
                        return e.WebBrowser;
                    }

                    //nsIAppShellService appShellService = Xpcom.GetService<nsIAppShellService>(Contracts.AppShellService);
                    nsIXULWindow xulChild = AppShellService.CreateTopLevelWindow(null, null, chromeFlags, -1, -1);
                    return Xpcom.QueryInterface<nsIWebBrowserChrome>(xulChild);
                }
                return null;
            }