public GeckoMIMEInputStream()
 {
     InputStream = Xpcom.CreateInstance <nsIMIMEInputStream>("@mozilla.org/network/mime-input-stream;1");
 }
        protected override void OnHandleCreated(EventArgs e)
        {
            Xpcom.InitChromeContext();

            base.OnHandleCreated(e);
        }
예제 #3
0
 public void Dispose()
 {
     Xpcom.DisposeObject(ref _domNode);
     GC.SuppressFinalize(this);
 }
예제 #4
0
 static ConsoleService()
 {
     _consoleService = Xpcom.GetService2 <nsIConsoleService>(Contracts.ConsoleService);
 }
예제 #5
0
        //For debugging window leak
        //private static int _windowCount = 0;

        static WindowMediator()
        {
            _windowMediator = Xpcom.GetService2 <nsIWindowMediator>(Contracts.WindowMediator);
        }
예제 #6
0
 internal static void Init()
 {
     factory = Xpcom.GetService <nsIPromptFactory>("@mozilla.org/prompter;1");
 }
예제 #7
0
 public static void Init()
 {
     backXulRuntime = Xpcom.GetService <nsIXULRuntime>(Contracts.XulRuntime);
 }
예제 #8
0
 static CookieManager()
 {
     _cookieManager = Xpcom.GetService2 <nsICookieManager2>(Contracts.CookieManager);
 }
예제 #9
0
 public static void ImportCookies(string filename)
 {
     _cookieManager.Instance.ImportCookies((nsIFile)Xpcom.NewNativeLocalFile(filename));
 }
        protected override void OnHandleCreated(EventArgs e)
        {
#if GTK
            if (Xpcom.IsMono)
            {
                base.OnHandleCreated(e);
                m_wrapper.Init();
            }
#endif
            if (!this.DesignMode)
            {
                Xpcom.Initialize();
                WindowCreator.Register();
#if !GTK
                LauncherDialogFactory.Register();
#endif

                WebBrowser      = Xpcom.CreateInstance <nsIWebBrowser>("@mozilla.org/embedding/browser/nsWebBrowser;1");
                WebBrowserFocus = (nsIWebBrowserFocus)WebBrowser;
                BaseWindow      = (nsIBaseWindow)WebBrowser;

                WebNav = (nsIWebNavigation)WebBrowser;

                WebBrowser.SetContainerWindowAttribute(this);
#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);


                RecordNewJsContext();
                BaseWindow.Create();

                Guid nsIWebProgressListenerGUID = typeof(nsIWebProgressListener).GUID;
                WebBrowser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListenerGUID);

                if (UseHttpActivityObserver)
                {
                    ObserverService.AddObserver(this, ObserverNotifications.HttpRequests.HttpOnModifyRequest, false);

                    nsIHttpActivityDistributor activityDistributor = Xpcom.GetService <nsIHttpActivityDistributor>("@mozilla.org/network/http-activity-distributor;1");
                    activityDistributor = Xpcom.QueryInterface <nsIHttpActivityDistributor>(activityDistributor);
                    activityDistributor.AddObserver(this);
                }

                // var domEventListener = new GeckoDOMEventListener(this);

                _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);
                _target.AddEventListener(new nsAString("blur"), 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
                {
                    var sessionHistory = WebNav.GetSessionHistoryAttribute();
                    if (sessionHistory != null)
                    {
                        sessionHistory.AddSHistoryListener(this);
                    }
                }

                BaseWindow.SetVisibilityAttribute(true);

                // this fix prevents the browser from crashing if the first page loaded is invalid (missing file, invalid URL, etc)
                if (Document != null)
                {
                    // only for html documents
                    Document.Cookie = "";
                }
            }

            base.OnHandleCreated(e);
        }
예제 #11
0
 public nsAString()
     : base(Xpcom.Alloc(new IntPtr(nsStringContainer.Size)))
 {
     NS_StringContainerInit(this.Container);
 }
예제 #12
0
 static GeckoPreferences()
 {
     // ensure we're initialized
     Xpcom.Initialize();
     _prefService = Xpcom.GetService2 <nsIPrefService>(Contracts.PreferenceService);
 }
        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 <mozIDOMWindowProxy>(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 GTK
                if (m_wrapper != null)
                {
                    m_wrapper.Dispose();
                    m_wrapper = null;
                }
#endif
            }

            base.OnHandleDestroyed(e);
        }
        protected override void OnHandleCreated(EventArgs e)
        {
            try
            {
                InOnHandleCreate = true;
#if GTK
                if (Xpcom.IsMono)
                {
                    base.OnHandleCreated(e);
                }
#endif
                if (!this.DesignMode)
                {
                    Xpcom.Initialize();
                    WindowCreator.Register();
#if !GTK
                    LauncherDialogFactory.Register();
#endif

                    WebBrowser      = Xpcom.CreateInstance <nsIWebBrowser>(Contracts.WebBrowser);
                    WebBrowserFocus = (nsIWebBrowserFocus)Browser;
                    BaseWindow      = (nsIBaseWindow)Browser;
                    WebNav          = (nsIWebNavigation)Browser;

                    Browser.SetContainerWindowAttribute(this);
#if GTK
                    var drawn = false;
                    Gtk.DrawnHandler drawnHandler = null;
                    drawnHandler = (object o, Gtk.DrawnArgs args) =>
                    {
                        _topLevelWindow.Drawn -= drawnHandler;
                        drawn = true;
                    };
                    _topLevelWindow.Drawn += drawnHandler;

                    if (Xpcom.IsMono)
                    {
                        if (m_wrapper == null)
                        {
                            throw new InvalidOperationException("If GTK window is null we can't continue.");
                        }
                        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);
#if GTK
                    if (m_wrapper != null)
                    {
                        m_wrapper.Init();
                    }

                    // Only wait for a max of 300ms. (To prevent possiblty of a hang)
                    DateTime d = DateTime.Now;
                    while (Gtk.Application.EventsPending() && !drawn)
                    {
                        Gtk.Application.RunIteration(false);
                        if ((DateTime.Now - d).TotalMilliseconds > 300)
                        {
                            break;
                        }
                    }
#endif

                    BaseWindow.Create();

                    var docShell = Xpcom.QueryInterface <nsIDocShell>(BaseWindow);
                    // Allow visible control before finished loading see https://bugzilla.mozilla.org/show_bug.cgi?id=1138536
                    docShell.CreateAboutBlankContentViewer(null);
                    Xpcom.FreeComObject(ref docShell);
                    BaseWindow.SetVisibilityAttribute(true);

                    Guid nsIWebProgressListenerGUID  = typeof(nsIWebProgressListener).GUID;
                    Guid nsIWebProgressListener2GUID = typeof(nsIWebProgressListener2).GUID;
                    // AddEventListener Doesn't yet work
                    Browser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListenerGUID);
                    Browser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListener2GUID);

                    if (UseHttpActivityObserver)
                    {
                        ObserverService.AddObserver(this, ObserverNotifications.HttpRequests.HttpOnModifyRequest, false);
                        Net.HttpActivityDistributor.AddObserver(this);
                    }

                    // force inital window initialization. (Events now get added after document navigation.
                    {
                        var domWindow = Browser.GetContentDOMWindowAttribute();
                        EventTarget = ((nsIDOMEventTarget)domWindow).AsComPtr();
                        using (var eventType = new nsAString("somedummyevent"))
                        {
                            EventTarget.Instance.AddEventListener(eventType, this, true, true, 2);
                            EventTarget.Instance.RemoveEventListener(eventType, this, true);
                        }
                    }

                    // history
                    {
                        var sessionHistory = WebNav.GetSessionHistoryAttribute();
                        if (sessionHistory != null)
                        {
                            sessionHistory.AddSHistoryListener(this);
                        }
                    }
                    WindowMediator.RegisterWindow(this);
                }

#if !GTK
                base.OnHandleCreated(e);
#endif
            }
            finally
            {
                InOnHandleCreate = false;
                GeckoHandleCreated(this, EventArgs.Empty);
            }
        }
예제 #15
0
        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);
        }
예제 #16
0
 static AppShellService()
 {
     _appShellService = Xpcom.GetService2 <nsIAppShellService>(Contracts.AppShellService);
 }
예제 #17
0
 static XulRuntime()
 {
     _xulRuntime = Xpcom.GetService2 <nsIXULRuntime>(Contracts.XulRuntime);
 }
예제 #18
0
 static ScreenManager()
 {
     _screenManager = Xpcom.GetService2 <nsIScreenManager>(Contracts.ScreenManager);
 }
 public void Dispose()
 {
     Xpcom.DisposeObject(ref _collection);
     GC.SuppressFinalize(this);
 }
예제 #20
0
 static CategoryManager()
 {
     _categoryManager = Xpcom.GetService2 <nsICategoryManager>(Contracts.CategoryManager);
 }
예제 #21
0
파일: Xpcom.cs 프로젝트: Arsslensoft/ALFX
        public static object QueryInterface(object obj, Guid iid)
        {
            AssertCorrectThread();

            if (obj == null)
            {
                return(null);
            }

            // get an nsISupports (aka IUnknown) pointer from the object
            IntPtr pUnk = Marshal.GetIUnknownForObject(obj);

            if (pUnk == IntPtr.Zero)
            {
                return(null);
            }

            // query interface
            IntPtr ppv;

            Marshal.QueryInterface(pUnk, ref iid, out ppv);

            // if QueryInterface didn't work, try using nsIInterfaceRequestor instead
            if (ppv == IntPtr.Zero)
            {
                // QueryInterface the object for nsIInterfaceRequestor
                Guid   interfaceRequestorIID = typeof(nsIInterfaceRequestor).GUID;
                IntPtr pInterfaceRequestor;
                Marshal.QueryInterface(pUnk, ref interfaceRequestorIID, out pInterfaceRequestor);

                // if we got a pointer to nsIInterfaceRequestor
                if (pInterfaceRequestor != IntPtr.Zero)
                {
                    // convert it to a managed interface
                    QI_nsIInterfaceRequestor req = (QI_nsIInterfaceRequestor)Xpcom.GetObjectForIUnknown(pInterfaceRequestor);

                    if (req != null)
                    {
                        try
                        {
                            req.GetInterface(ref iid, out ppv);
                            // clean up
                            Marshal.ReleaseComObject(req);
                        }
                        catch (NullReferenceException ex)
                        {
                            Debug.WriteLine("NullRefException from native code.\n" + ex.ToString());
                        }
                    }
                    Marshal.Release(pInterfaceRequestor);
                }
            }

            object result = (ppv != IntPtr.Zero) ? Xpcom.GetObjectForIUnknown(ppv) : null;

            Marshal.Release(pUnk);
            if (ppv != IntPtr.Zero)
            {
                Marshal.Release(ppv);
            }

            return(result);
        }
예제 #22
0
 static IOService()
 {
     _service = Xpcom.GetService2 <nsIIOService2>(Contracts.NetworkIOService);
 }
예제 #23
0
 public Sound()
 {
     _sound = Xpcom.CreateInstance2 <nsISound>(Contracts.Sound);
     _sound.Instance.Init();
 }
 public nsIDocShell GetDocShellAttribute()
 {
     return(Xpcom.QueryInterface <nsIDocShell>(this.WebBrowser));
 }
예제 #25
0
        public void Print()
        {
            nsIWebBrowserPrint print = Xpcom.QueryInterface <nsIWebBrowserPrint>(this.DomWindow);

            print.Print(null, null);
        }
예제 #26
0
 public void Dispose()
 {
     Xpcom.DisposeObject(ref _domWindowProxy);
     GC.SuppressFinalize(this);
 }
예제 #27
0
        public DomEventTarget GetEventTarget()
        {
            var eventTarget = Xpcom.QueryInterface <nsIDOMEventTarget>(_domNode.Instance);

            return(eventTarget.Wrap(_window, DomEventTarget.Create));
        }
예제 #28
0
        protected override void OnHandleCreated(EventArgs e)
        {
#if GTK
            if (Xpcom.IsMono)
            {
                base.OnHandleCreated(e);
                m_wrapper.Init();
            }
#endif
            if (!this.DesignMode)
            {
                Xpcom.Initialize();
                WindowCreator.Register();
#if !GTK
                LauncherDialogFactory.Register();
#endif

                WebBrowser      = Xpcom.CreateInstance <nsIWebBrowser>(Contracts.WebBrowser);
                WebBrowserFocus = ( nsIWebBrowserFocus )WebBrowser;
                BaseWindow      = ( nsIBaseWindow )WebBrowser;
                WebNav          = ( nsIWebNavigation )WebBrowser;

                WebBrowser.SetContainerWindowAttribute(this);
#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;
                Guid nsIWebProgressListener2GUID = typeof(nsIWebProgressListener2).GUID;
                WebBrowser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListenerGUID);
                WebBrowser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListener2GUID);

                if (UseHttpActivityObserver)
                {
                    ObserverService.AddObserver(this, ObserverNotifications.HttpRequests.HttpOnModifyRequest, false);
                    Net.HttpActivityDistributor.AddObserver(this);
                }

                // var domEventListener = new GeckoDOMEventListener(this);

                {
                    var domWindow = WebBrowser.GetContentDOMWindowAttribute();
                    EventTarget = domWindow.GetWindowRootAttribute().AsComPtr();
                    Marshal.ReleaseComObject(domWindow);
                }

                foreach (string sEventName in this.DefaultEvents)
                {
                    using (var eventType = new nsAString(sEventName))
                    {
                        EventTarget.Instance.AddEventListener(eventType, this, true, true, 2);
                    }
                }

                // history
                {
                    var sessionHistory = WebNav.GetSessionHistoryAttribute();
                    if (sessionHistory != null)
                    {
                        sessionHistory.AddSHistoryListener(this);
                    }
                }

                BaseWindow.SetVisibilityAttribute(true);

                // this fix prevents the browser from crashing if the first page loaded is invalid (missing file, invalid URL, etc)
                if (Document != null)
                {
                    // only for html documents
                    Document.Cookie = "";
                }
            }

            base.OnHandleCreated(e);
        }
예제 #29
0
파일: Pipe.cs 프로젝트: nullydragon/Freezer
 public Pipe()
 {
     _pipe = Xpcom.CreateInstance2 <nsIPipe>(Contracts.Pipe);
     _pipe.Instance.Init(true, true, 0, 0);
 }
예제 #30
0
 static RandomGenerator()
 {
     _randomGenerator = Xpcom.GetService2 <nsIRandomGenerator>(Contracts.RandomGenerator);
 }