public void NavigateComplete2(object pDisp, ref object url)
 {
     UnsafeNativeMethods.IWebBrowser2 webBrowser = (UnsafeNativeMethods.IWebBrowser2)pDisp;
     if (this._parent.AxIWebBrowser2 == webBrowser)
     {
         if (this._parent.DocumentStream != null)
         {
             Invariant.Assert(this._parent.NavigatingToAboutBlank && string.Compare((string)url, "about:blank", StringComparison.OrdinalIgnoreCase) == 0);
             try
             {
                 UnsafeNativeMethods.IHTMLDocument nativeHTMLDocument = this._parent.NativeHTMLDocument;
                 if (nativeHTMLDocument != null)
                 {
                     UnsafeNativeMethods.IPersistStreamInit          persistStreamInit = nativeHTMLDocument as UnsafeNativeMethods.IPersistStreamInit;
                     System.Runtime.InteropServices.ComTypes.IStream pstm = new ManagedIStream(this._parent.DocumentStream);
                     persistStreamInit.Load(pstm);
                 }
                 return;
             }
             finally
             {
                 this._parent.DocumentStream = null;
             }
         }
         string text = (string)url;
         if (this._parent.NavigatingToAboutBlank)
         {
             Invariant.Assert(string.Compare(text, "about:blank", StringComparison.OrdinalIgnoreCase) == 0);
             text = null;
         }
         Uri uri = string.IsNullOrEmpty(text) ? null : new Uri(text);
         NavigationEventArgs e = new NavigationEventArgs(uri, null, null, null, null, true);
         this._parent.OnNavigated(e);
     }
 }
Exemple #2
0
        public void NavigateComplete2(object pDisp, ref object url)
        {
            Debug.Assert(url == null || url is string, "invalid url type");

            // Events only fired for top level navigation.
            UnsafeNativeMethods.IWebBrowser2 axIWebBrowser2 = (UnsafeNativeMethods.IWebBrowser2)pDisp;
            if (_parent.AxIWebBrowser2 == axIWebBrowser2)
            {
                // If we are loading from stream.
                if (_parent.DocumentStream != null)
                {
                    Invariant.Assert(_parent.NavigatingToAboutBlank &&
                                     (String.Compare((string)url, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase) == 0));

                    try
                    {
                        UnsafeNativeMethods.IHTMLDocument nativeHTMLDocument = _parent.NativeHTMLDocument;
                        if (nativeHTMLDocument != null)
                        {
                            UnsafeNativeMethods.IPersistStreamInit psi = nativeHTMLDocument as UnsafeNativeMethods.IPersistStreamInit;
                            Debug.Assert(psi != null, "The Document does not implement IPersistStreamInit");

                            System.Runtime.InteropServices.ComTypes.IStream iStream =
                                new MS.Internal.IO.Packaging.ManagedIStream(_parent.DocumentStream);

                            psi.Load(iStream);
                        }
                    }
                    finally
                    {
                        _parent.DocumentStream = null;
                    }
                }
                else
                {
                    string urlString = (string)url;
                    // When source set to null or navigating to stream/string, we navigate to "about:blank"
                    // internally. Make sure we pass null in the event args.
                    if (_parent.NavigatingToAboutBlank)
                    {
                        Invariant.Assert(String.Compare(urlString, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase) == 0);
                        urlString = null;
                    }
                    Uri source            = (String.IsNullOrEmpty(urlString) ? null : new Uri(urlString));
                    NavigationEventArgs e = new NavigationEventArgs(source, null, null, null, null, true);

                    _parent.OnNavigated(e);
                }
            }
        }