Exemple #1
0
        static private ContentType GetMimeTypeFromUrlMon(Uri uriSource)
        {
            ContentType mimeType = ContentType.Empty;

            if (uriSource != null)
            {
                int    retValue;
                string mimeTypeString;

                retValue = MS.Win32.Compile.UnsafeNativeMethods.FindMimeFromData(null,
                                                                                 BindUriHelper.UriToString(uriSource),
                                                                                 IntPtr.Zero,
                                                                                 0,
                                                                                 null,
                                                                                 0,
                                                                                 out mimeTypeString,
                                                                                 0);

                // For PreSharp 56031,
                // This return value must be checked as the function
                // will not throw an exception on failure.
                // the expected return value is S_OK.
                if (retValue == 0 && mimeTypeString != null)
                {
                    mimeType = new ContentType(mimeTypeString);
                }
            }

            return(mimeType);
        }
Exemple #2
0
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        #region Preparing DOM

        // Load XML from a URI; this runs on caller thread of BeginQuery (Refresh/InitialLoad)
        private void LoadFromSource()
        {
            // convert the Source into an absolute URI
            Uri sourceUri = this.Source;

            if (sourceUri.IsAbsoluteUri == false)
            {
                Uri baseUri = (_baseUri != null) ? _baseUri : BindUriHelper.BaseUri;
                sourceUri = BindUriHelper.GetResolvedUri(baseUri, sourceUri);
            }

            // create a request to load the content
            // Ideally we would want to use RegisterPrefix and WebRequest.Create.
            // However, these two functions regress 700k working set in System.dll and System.xml.dll
            //  which is mostly for logging and config.
            // Call PackWebRequestFactory.CreateWebRequest to bypass the regression if possible
            //  by calling Create on PackWebRequest if uri is pack scheme
            WebRequest request = PackWebRequestFactory.CreateWebRequest(sourceUri);

            if (request == null)
            {
                throw new Exception(SR.Get(SRID.WebRequestCreationFailed));
            }

            // load it on a worker thread ?
            if (IsAsynchronous)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(CreateDocFromExternalSourceAsynch),
                                             request);
            }
            else
            {
                CreateDocFromExternalSource(request);
            }
        }
        internal static SecurityZone MapUrlToZone(Uri uri)
        {
            EnsureSecurityManager();

            int targetZone;

            _securityManager.MapUrlToZone(BindUriHelper.UriToString(uri), out targetZone, 0);

            // The enum is directly mappable, but taking no chances...
            switch (targetZone)
            {
            case NativeMethods.URLZONE_LOCAL_MACHINE:
                return(SecurityZone.MyComputer);

            case NativeMethods.URLZONE_INTERNET:
                return(SecurityZone.Internet);

            case NativeMethods.URLZONE_INTRANET:
                return(SecurityZone.Intranet);

            case NativeMethods.URLZONE_TRUSTED:
                return(SecurityZone.Trusted);

            case NativeMethods.URLZONE_UNTRUSTED:
                return(SecurityZone.Untrusted);
            }

            return(SecurityZone.NoZone);
        }
        private static bool IsZoneElevationSettingPrompt(Uri target)
        {
            Invariant.Assert(_secMgr != null);

            // Was this due to a prompt ?

            int policy = NativeMethods.URLPOLICY_DISALLOW;

            unsafe
            {
                String targetString = BindUriHelper.UriToString(target);
                new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); // BlessedAssert:
                try
                {
                    _secMgr.ProcessUrlAction(targetString,
                                             NativeMethods.URLACTION_FEATURE_ZONE_ELEVATION,
                                             (byte *)&policy,
                                             Marshal.SizeOf(typeof(int)),
                                             null,
                                             0,
                                             NativeMethods.PUAF_NOUI,
                                             0);
                }
                finally
                {
                    CodeAccessPermission.RevertAssert();
                }
            }

            return(policy == NativeMethods.URLPOLICY_QUERY);
        }
 private static LaunchResult CheckBlockNavigation(Uri originatingUri, Uri destinationUri, bool fEnabled)
 {
     if (fEnabled)
     {
         if (UnsafeNativeMethods.CoInternetIsFeatureZoneElevationEnabled(
                 BindUriHelper.UriToString(originatingUri),
                 BindUriHelper.UriToString(destinationUri),
                 _secMgr,
                 NativeMethods.GET_FEATURE_FROM_PROCESS) == NativeMethods.S_FALSE)
         {
             return(LaunchResult.Launched);
         }
         else
         {
             if (IsZoneElevationSettingPrompt(destinationUri))
             {
                 // url action is query, and we got a "no" answer back.
                 // we can assume user responded No.
                 return(LaunchResult.NotLaunchedDueToPrompt);
             }
             else
             {
                 return(LaunchResult.NotLaunched);
             }
         }
     }
     else
     {
         return(LaunchResult.Launched);
     }
 }
Exemple #6
0
        internal static string GetCookie(Uri uri, bool throwIfNoCookie)
        {
            // Always demand in order to prevent any cross-domain information leak.
            SecurityHelper.DemandWebPermission(uri);

            UInt32 size      = 0;
            string uriString = BindUriHelper.UriToString(uri);

            if (UnsafeNativeMethods.InternetGetCookieEx(uriString, null, null, ref size, 0, IntPtr.Zero))
            {
                Debug.Assert(size > 0);
                size++;
                System.Text.StringBuilder sb = new System.Text.StringBuilder((int)size);
                // PresentationHost intercepts InternetGetCookieEx(). It will set the INTERNET_COOKIE_THIRD_PARTY
                // flag if necessary.
                if (UnsafeNativeMethods.InternetGetCookieEx(uriString, null, sb, ref size, 0, IntPtr.Zero))
                {
                    return(sb.ToString());
                }
            }
            if (!throwIfNoCookie && Marshal.GetLastWin32Error() == NativeMethods.ERROR_NO_MORE_ITEMS)
            {
                return(null);
            }
            throw new Win32Exception(/*uses last error code*/);
        }
Exemple #7
0
        internal static int MapUrlToZoneWrapper(Uri uri)
        {
            int pdwZone = 0;
            int num     = 0;

            num = UnsafeNativeMethods.CoInternetCreateSecurityManager(null, out var ppISecurityManager, 0);
            if (MS.Win32.NativeMethods.Failed(num))
            {
                throw new Win32Exception(num);
            }
            UnsafeNativeMethods.IInternetSecurityManager internetSecurityManager = (MS.Win32.UnsafeNativeMethods.IInternetSecurityManager)ppISecurityManager;
            string pwszUrl = BindUriHelper.UriToString(uri);

            if (uri.IsFile)
            {
                internetSecurityManager.MapUrlToZone(pwszUrl, out pdwZone, 1);
            }
            else
            {
                internetSecurityManager.MapUrlToZone(pwszUrl, out pdwZone, 0);
            }
            if (pdwZone < 0)
            {
                throw new SecurityException(SR.Get("Invalid_URI"));
            }
            internetSecurityManager = null;
            ppISecurityManager      = null;
            return(pdwZone);
        }
Exemple #8
0
        private FixedDocument _LoadDocument()
        {
            FixedDocument fixedDocument = null;
            Uri           uri           = this._ResolveUri();

            if (uri != null)
            {
                ContentType contentType = null;
                Stream      stream      = WpfWebRequestHelper.CreateRequestAndGetResponseStream(uri, out contentType);
                if (stream == null)
                {
                    throw new ApplicationException(SR.Get("DocumentReferenceNotFound"));
                }
                ParserContext parserContext = new ParserContext();
                parserContext.BaseUri = uri;
                if (BindUriHelper.IsXamlMimeType(contentType))
                {
                    XpsValidatingLoader xpsValidatingLoader = new XpsValidatingLoader();
                    fixedDocument = (xpsValidatingLoader.Load(stream, ((IUriContext)this).BaseUri, parserContext, contentType) as FixedDocument);
                }
                else
                {
                    if (!MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(contentType))
                    {
                        throw new ApplicationException(SR.Get("DocumentReferenceUnsupportedMimeType"));
                    }
                    fixedDocument = (XamlReader.LoadBaml(stream, parserContext, null, true) as FixedDocument);
                }
                fixedDocument.DocumentReference = this;
            }
            return(fixedDocument);
        }
        internal static LaunchResult SafeLaunchBrowserOnlyIfPossible(Uri originatingUri, Uri destinationUri, string targetName, bool fIsTopLevel)
        {
            LaunchResult launchResult = LaunchResult.NotLaunched;
            bool         flag         = destinationUri.Scheme == Uri.UriSchemeHttp || destinationUri.Scheme == Uri.UriSchemeHttps || destinationUri.IsFile;
            bool         flag2        = string.Compare(destinationUri.Scheme, Uri.UriSchemeMailto, StringComparison.OrdinalIgnoreCase) == 0;

            if (!BrowserInteropHelper.IsInitialViewerNavigation && SecurityHelper.CallerHasUserInitiatedNavigationPermission() && ((fIsTopLevel && flag) || flag2))
            {
                if (flag)
                {
                    IBrowserCallbackServices browserCallbackServices = (Application.Current != null) ? Application.Current.BrowserCallbackServices : null;
                    if (browserCallbackServices != null)
                    {
                        launchResult = AppSecurityManager.CanNavigateToUrlWithZoneCheck(originatingUri, destinationUri);
                        if (launchResult == LaunchResult.Launched)
                        {
                            browserCallbackServices.DelegateNavigation(BindUriHelper.UriToString(destinationUri), targetName, AppSecurityManager.GetHeaders(destinationUri));
                            launchResult = LaunchResult.Launched;
                        }
                    }
                }
                else if (flag2)
                {
                    UnsafeNativeMethods.ShellExecute(new HandleRef(null, IntPtr.Zero), null, BindUriHelper.UriToString(destinationUri), null, null, 0);
                    launchResult = LaunchResult.Launched;
                }
            }
            return(launchResult);
        }
        internal static int MapUrlToZone(Uri url)
        {
            EnsureSecurityManager();
            int zone;

            _secMgr.MapUrlToZone(BindUriHelper.UriToString(url), out zone, 0);
            return(zone);
        }
        internal static int MapUrlToZone(Uri url)
        {
            AppSecurityManager.EnsureSecurityManager();
            int result;

            AppSecurityManager._secMgr.MapUrlToZone(BindUriHelper.UriToString(url), out result, 0);
            return(result);
        }
Exemple #12
0
        ParseGuidFromUri(Uri uri)
        {
            string fileName = System.IO.Path.GetFileNameWithoutExtension(
                BindUriHelper.UriToString(uri)
                );

            return(new Guid(fileName));
        }
        internal static int MapUrlToZone(Uri uri)
        {
            EnsureSecurityManager();

            int targetZone;

            _securityManager.MapUrlToZone(BindUriHelper.UriToString(uri), out targetZone, 0);
            return(targetZone);
        }
        public override ObjectHandle CreateInstance(ActivationContext actCtx)
        {
            if (EventTrace.IsEnabled(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose))
            {
                EventTrace.EventProvider.TraceEvent(EventTrace.Event.WpfHost_ApplicationActivatorCreateInstanceStart,
                                                    EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose,
                                                    PresentationAppDomainManager.ActivationUri != null ? PresentationAppDomainManager.ActivationUri.ToString() : string.Empty);
            }

            ObjectHandle oh;

            if (PresentationAppDomainManager.ActivationUri != null)
            {
                oh = base.CreateInstance(
                    actCtx,
                    new string[] {
                    BindUriHelper.UriToString(PresentationAppDomainManager.ActivationUri),
                    PresentationAppDomainManager.IsDebug.ToString(),
                    (PresentationAppDomainManager.DebugSecurityZoneURL == null?
                     string.Empty
                        : PresentationAppDomainManager.DebugSecurityZoneURL.ToString())
                });
            }
            else
            {
                oh = base.CreateInstance(actCtx);
            }
            bool returnAppDomain = false;

            try
            {
                new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); // BlessedAssert:
                if (AppDomain.CurrentDomain.ActivationContext != null &&
                    AppDomain.CurrentDomain.ActivationContext.Identity.ToString().Equals(actCtx.Identity.ToString()))
                {
                    returnAppDomain = true;
                }
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
            }

            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_ApplicationActivatorCreateInstanceEnd);

            if (returnAppDomain)
            {
                // This is the new AppDomain. What we return here becomes the return value of
                // InPlaceHostingManager.Execute().
                return(new ObjectHandle(AppDomain.CurrentDomain));
            }
            else
            {
                return(oh);
            }
        }
Exemple #15
0
        // Token: 0x06002A28 RID: 10792 RVA: 0x000C214C File Offset: 0x000C034C
        private static void OnSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            NavigationWindow navigationWindow = (NavigationWindow)d;

            if (!navigationWindow._sourceUpdatedFromNavService)
            {
                Uri uriToNavigate = BindUriHelper.GetUriToNavigate(navigationWindow, d.GetValue(BaseUriHelper.BaseUriProperty) as Uri, (Uri)e.NewValue);
                navigationWindow._navigationService.Navigate(uriToNavigate, null, false, true);
            }
        }
        private Uri _ResolveUri()
        {
            Uri uriToNavigate = this.Source;

            if (uriToNavigate != null)
            {
                uriToNavigate = BindUriHelper.GetUriToNavigate(this, ((IUriContext)this).BaseUri, uriToNavigate);
            }
            return(uriToNavigate);
        }
        // Token: 0x060078B1 RID: 30897 RVA: 0x00226210 File Offset: 0x00224410
        private static string GetHeaders(Uri destinationUri)
        {
            string text = BindUriHelper.GetReferer(destinationUri);

            if (!string.IsNullOrEmpty(text))
            {
                text = "Referer: " + text + "\r\n";
            }
            return(text);
        }
 private static bool SetCookieUnsafe(Uri uri, string cookieData, string p3pHeader)
 {
     string uriString = BindUriHelper.UriToString(uri);
     // PresentationHost intercepts InternetSetCookieEx(). It will set the INTERNET_COOKIE_THIRD_PARTY
     // flag if necessary. (This doesn't look very elegant but is much simpler than having to make the 
     // 3rd party decision here as well or calling into the native code (from PresentationCore).)
     uint res = UnsafeNativeMethods.InternetSetCookieEx(
         uriString, null, cookieData, UnsafeNativeMethods.INTERNET_COOKIE_EVALUATE_P3P, p3pHeader);
     if(res == 0)
         throw new Win32Exception(/*uses last error code*/);
     return res != UnsafeNativeMethods.COOKIE_STATE_REJECT;
 }
 internal RequestSetStatusBarEventArgs(Uri targetUri)
 {
     if (targetUri == null)
     {
         this._text.Value = string.Empty;
     }
     else
     {
         this._text.Value = BindUriHelper.UriToString(targetUri);
     }
     base.RoutedEvent = Hyperlink.RequestSetStatusBarEvent;
 }
Exemple #20
0
        private void DoNavigate(Uri source, ref object targetFrameName, ref object postData, ref object headers, bool ignoreEscaping = false)
        {
            base.VerifyAccess();
            NativeMethods.IOleCommandTarget oleCommandTarget = (NativeMethods.IOleCommandTarget) this.AxIWebBrowser2;
            object obj = false;

            oleCommandTarget.Exec(null, 23, 0, new object[]
            {
                obj
            }, 0);
            this.LastNavigation = Guid.NewGuid();
            if (source == null)
            {
                this.NavigatingToAboutBlank = true;
                source = new Uri("about:blank");
            }
            else
            {
                this.CleanInternalState();
            }
            if (!source.IsAbsoluteUri)
            {
                throw new ArgumentException(SR.Get("AbsoluteUriOnly"), "source");
            }
            if (PackUriHelper.IsPackUri(source))
            {
                source = BaseUriHelper.ConvertPackUriToAbsoluteExternallyVisibleUri(source);
            }
            if (!string.IsNullOrEmpty((string)targetFrameName))
            {
                new WebPermission(PermissionState.Unrestricted).Demand();
            }
            else if (!this.NavigatingToAboutBlank)
            {
                SecurityHelper.DemandWebPermission(source);
            }
            object obj2 = null;
            object obj3 = ignoreEscaping ? source.AbsoluteUri : BindUriHelper.UriToString(source);

            try
            {
                this.AxIWebBrowser2.Navigate2(ref obj3, ref obj2, ref targetFrameName, ref postData, ref headers);
            }
            catch (COMException ex)
            {
                this.CleanInternalState();
                if (ex.ErrorCode != -2147023673)
                {
                    throw;
                }
            }
        }
 internal static void UnsafeLaunchBrowser(Uri uri, string targetFrame = null)
 {
     if (Application.Current != null && Application.Current.CheckAccess())
     {
         IBrowserCallbackServices browserCallbackServices = Application.Current.BrowserCallbackServices;
         if (browserCallbackServices != null)
         {
             browserCallbackServices.DelegateNavigation(BindUriHelper.UriToString(uri), targetFrame, AppSecurityManager.GetHeaders(uri));
             return;
         }
     }
     AppSecurityManager.ShellExecuteDefaultBrowser(uri);
 }
Exemple #22
0
        internal RequestSetStatusBarEventArgs(Uri targetUri)
            : base()
        {
            if (targetUri == null)
            {
                _text.Value = String.Empty;
            }
            else
            {
                _text.Value = BindUriHelper.UriToString(targetUri);
            }

            base.RoutedEvent = System.Windows.Documents.Hyperlink.RequestSetStatusBarEvent;
        }
        /// <summary>
        /// Returns the HTTP "Referer" header.
        /// </summary>
        /// <returns>returns a string containing one or more HTTP headers separated by \r\n; the string must also be terminated with a \r\n</returns>
        private static string GetHeaders(Uri destinationUri)
        {
            string referer = BindUriHelper.GetReferer(destinationUri);

            if (!String.IsNullOrEmpty(referer))
            {
                // The headers we pass in to IWebBrowser2.Navigate must
                // be terminated with a \r\n because the browser then
                // concatenates its own headers on to the end of that string.
                referer = RefererHeader + referer + "\r\n";
            }

            return(referer);
        }
Exemple #24
0
        internal static void DemandWebPermission(Uri uri)
        {
            string uriString = BindUriHelper.UriToString(uri);

            if (uri.IsFile)
            {
                string localPath = uri.LocalPath;
                new FileIOPermission(FileIOPermissionAccess.Read, localPath).Demand();
            }
            else
            {
                new WebPermission(NetworkAccess.Connect, uriString).Demand();
            }
        }
Exemple #25
0
        private void ParseGlyphRunProperties()
        {
            Glyphs.LayoutDependentGlyphRunProperties layoutDependentGlyphRunProperties = null;
            Uri uri = this.FontUri;

            if (uri != null)
            {
                if (string.IsNullOrEmpty(this.UnicodeString) && string.IsNullOrEmpty(this.Indices))
                {
                    throw new ArgumentException(SR.Get("GlyphsUnicodeStringAndIndicesCannotBothBeEmpty"));
                }
                layoutDependentGlyphRunProperties = new Glyphs.LayoutDependentGlyphRunProperties(base.GetDpi().PixelsPerDip);
                if (!uri.IsAbsoluteUri)
                {
                    uri = BindUriHelper.GetResolvedUri(BaseUriHelper.GetBaseUri(this), uri);
                }
                layoutDependentGlyphRunProperties.glyphTypeface  = new GlyphTypeface(uri, this.StyleSimulations);
                layoutDependentGlyphRunProperties.unicodeString  = this.UnicodeString;
                layoutDependentGlyphRunProperties.sideways       = this.IsSideways;
                layoutDependentGlyphRunProperties.deviceFontName = this.DeviceFontName;
                List <Glyphs.ParsedGlyphData> list;
                int num = this.ParseGlyphsProperty(layoutDependentGlyphRunProperties.glyphTypeface, layoutDependentGlyphRunProperties.unicodeString, layoutDependentGlyphRunProperties.sideways, out list, out layoutDependentGlyphRunProperties.clusterMap);
                layoutDependentGlyphRunProperties.glyphIndices  = new ushort[num];
                layoutDependentGlyphRunProperties.advanceWidths = new double[num];
                this.ParseCaretStops(layoutDependentGlyphRunProperties);
                layoutDependentGlyphRunProperties.glyphOffsets = null;
                int num2 = 0;
                layoutDependentGlyphRunProperties.fontRenderingSize = this.FontRenderingEmSize;
                layoutDependentGlyphRunProperties.bidiLevel         = this.BidiLevel;
                double num3 = layoutDependentGlyphRunProperties.fontRenderingSize / 100.0;
                foreach (Glyphs.ParsedGlyphData parsedGlyphData in list)
                {
                    layoutDependentGlyphRunProperties.glyphIndices[num2]  = parsedGlyphData.glyphIndex;
                    layoutDependentGlyphRunProperties.advanceWidths[num2] = parsedGlyphData.advanceWidth * num3;
                    if (parsedGlyphData.offsetX != 0.0 || parsedGlyphData.offsetY != 0.0)
                    {
                        if (layoutDependentGlyphRunProperties.glyphOffsets == null)
                        {
                            layoutDependentGlyphRunProperties.glyphOffsets = new Point[num];
                        }
                        layoutDependentGlyphRunProperties.glyphOffsets[num2].X = parsedGlyphData.offsetX * num3;
                        layoutDependentGlyphRunProperties.glyphOffsets[num2].Y = parsedGlyphData.offsetY * num3;
                    }
                    num2++;
                }
            }
            this._glyphRunProperties = layoutDependentGlyphRunProperties;
        }
 private static LaunchResult CheckBlockNavigation(Uri originatingUri, Uri destinationUri, bool fEnabled)
 {
     if (!fEnabled)
     {
         return(LaunchResult.Launched);
     }
     if (UnsafeNativeMethods.CoInternetIsFeatureZoneElevationEnabled(BindUriHelper.UriToString(originatingUri), BindUriHelper.UriToString(destinationUri), AppSecurityManager._secMgr, 2) == 1)
     {
         return(LaunchResult.Launched);
     }
     if (AppSecurityManager.IsZoneElevationSettingPrompt(destinationUri))
     {
         return(LaunchResult.NotLaunchedDueToPrompt);
     }
     return(LaunchResult.NotLaunched);
 }
Exemple #27
0
        internal static void BlockCrossDomainForHttpsApps(Uri uri)
        {
            Uri uri2 = ExtractUriForClickOnceDeployedApp();

            if (uri2 != null && uri2.Scheme == Uri.UriSchemeHttps)
            {
                if (uri.IsUnc || uri.IsFile)
                {
                    new FileIOPermission(FileIOPermissionAccess.Read, uri.LocalPath).Demand();
                }
                else
                {
                    new WebPermission(NetworkAccess.Connect, BindUriHelper.UriToString(uri)).Demand();
                }
            }
        }
        private unsafe static bool IsZoneElevationSettingPrompt(Uri target)
        {
            Invariant.Assert(AppSecurityManager._secMgr != null);
            int    num     = 3;
            string pwszUrl = BindUriHelper.UriToString(target);

            new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
            try
            {
                AppSecurityManager._secMgr.ProcessUrlAction(pwszUrl, 8449, (byte *)(&num), Marshal.SizeOf(typeof(int)), null, 0, 1, 0);
            }
            finally
            {
                CodeAccessPermission.RevertAssert();
            }
            return(num == 1);
        }
Exemple #29
0
        // returns the exact string on which we demanded permissions

        private string DemandPermissions(Uri absoluteUri)
        {
            Debug.Assert(absoluteUri.IsAbsoluteUri);
            string toOpen     = BindUriHelper.UriToString(absoluteUri);
            int    targetZone = SecurityHelper.MapUrlToZoneWrapper(absoluteUri);

            if (targetZone == NativeMethods.URLZONE_LOCAL_MACHINE)
            {
                // go here only for files and not for UNC
                if (absoluteUri.IsFile)
                {
                    toOpen = absoluteUri.LocalPath;
                }
            }

            return(toOpen);
        }
        internal static void UnsafeLaunchBrowser(Uri uri, string targetFrame = null)
        {
            // This'll likely go into SafeLaunchBrowser() function.
            if (Application.Current != null && Application.Current.CheckAccess())
            {
                IBrowserCallbackServices ibcs = Application.Current.BrowserCallbackServices;
                if (ibcs != null)
                {
                    // Browser app.
                    //

                    ibcs.DelegateNavigation(BindUriHelper.UriToString(uri), targetFrame, GetHeaders(uri));
                    return;
                }
            }

            ShellExecuteDefaultBrowser(uri);
        }