Exemplo n.º 1
0
        int IBrowserHostServices.ExecCommand(Guid guidCommandGroup, uint command, object arg)
        {
            XappLauncherApp xappLauncherApp = Application.Current as XappLauncherApp;

            if (xappLauncherApp != null && guidCommandGroup == Guid.Empty)
            {
                if (command == 22U)
                {
                    xappLauncherApp.HandleRefresh();
                    return(0);
                }
                if (command == 23U)
                {
                    xappLauncherApp.UserStop();
                    return(0);
                }
            }
            if (this._appProxyInternal != null)
            {
                OleCmdHelper oleCmdHelper = this._appProxyInternal.OleCmdHelper;
                if (oleCmdHelper != null)
                {
                    oleCmdHelper.ExecCommand(guidCommandGroup, command, arg);
                    return(0);
                }
            }
            return(-2147221244);
        }
Exemplo n.º 2
0
        int IBrowserHostServices.Run(string path, string fragment, MimeType mime, string debugSecurityZoneURL, string applicationId, object streamContainer, object ucomLoadIStream, HostingFlags hostingFlags, INativeProgressPage nativeProgressPage, string progressAssemblyName, string progressClassName, string errorAssemblyName, string errorClassName, IHostBrowser hostBrowser)
        {
            Invariant.Assert(!string.IsNullOrEmpty(path), "path string should not be null or empty when Run method is called.");
            Invariant.Assert(mime > MimeType.Unknown, "Unknown mime type");
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordHosting, EventTrace.Event.WpfHost_IBHSRunStart, "\"" + path + "\"", "\"" + applicationId + "\"");
            int num = 0;

            try
            {
                ApplicationProxyInternal.InitData value = this._initData.Value;
                value.HostBrowser       = hostBrowser;
                value.Fragment          = fragment;
                value.UcomLoadIStream   = ucomLoadIStream;
                value.HandleHistoryLoad = true;
                value.MimeType.Value    = mime;
                string  userAgentString = null;
                HRESULT hrLeft          = hostBrowser.GetUserAgentString(out userAgentString);
                if (hrLeft == HRESULT.E_OUTOFMEMORY && (hostingFlags & HostingFlags.hfHostedInIEorWebOC) != (HostingFlags)0)
                {
                    userAgentString = UnsafeNativeMethods.ObtainUserAgentString();
                    hrLeft          = HRESULT.S_OK;
                }
                hrLeft.ThrowIfFailed();
                value.UserAgentString = userAgentString;
                value.HostingFlags    = hostingFlags;
                Uri uri = new UriBuilder(path).Uri;
                value.ActivationUri.Value = uri;
                PresentationAppDomainManager.ActivationUri = uri;
                BrowserInteropHelper.SetBrowserHosted(true);
                if ((hostingFlags & HostingFlags.hfInDebugMode) != (HostingFlags)0)
                {
                    this._browserCallbackServices.ChangeDownloadState(false);
                    this._browserCallbackServices.UpdateProgress(-1L, 0L);
                    this.EnableErrorPage();
                    this._appProxyInternal = new ApplicationLauncherXappDebug(path, debugSecurityZoneURL).Initialize();
                }
                else
                {
                    switch (mime)
                    {
                    case MimeType.Document:
                        this._appProxyInternal = this.CreateAppDomainForXpsDocument();
                        if (this._appProxyInternal == null)
                        {
                            num = -1;
                        }
                        else if (streamContainer != null)
                        {
                            IntPtr iunknownForObject = Marshal.GetIUnknownForObject(streamContainer);
                            this._appProxyInternal.StreamContainer = iunknownForObject;
                            Marshal.Release(iunknownForObject);
                        }
                        this._initData.Value = null;
                        break;

                    case MimeType.Application:
                    {
                        XappLauncherApp xappLauncherApp = new XappLauncherApp(uri, applicationId, this._browserCallbackServices, new DocObjHost.ApplicationRunnerCallback(this.RunApplication), nativeProgressPage, progressAssemblyName, progressClassName, errorAssemblyName, errorClassName);
                        value.HandleHistoryLoad = false;
                        this._appProxyInternal  = new ApplicationProxyInternal();
                        break;
                    }

                    case MimeType.Markup:
                        this._appProxyInternal = this.CreateAppDomainForLooseXaml(uri);
                        this._initData.Value   = null;
                        break;

                    default:
                        num = -1;
                        break;
                    }
                }
                if (num != -1)
                {
                    if (mime == MimeType.Document || mime == MimeType.Markup)
                    {
                        this.EnableErrorPage();
                    }
                    if (this.IsAffectedByCtfIssue())
                    {
                        num = -1;
                        this._browserCallbackServices.ProcessUnhandledException(string.Format(CultureInfo.CurrentCulture, SR.Get("AffectedByMsCtfIssue"), new object[]
                        {
                            "http://support.microsoft.com/kb/954494"
                        }));
                    }
                    else
                    {
                        num = this._appProxyInternal.Run(value);
                    }
                }
            }
            catch (Exception ex)
            {
                num = -1;
                this._browserCallbackServices.ProcessUnhandledException(ex.ToString());
                throw;
            }
            catch
            {
                num = -1;
                this._browserCallbackServices.ProcessUnhandledException(SR.Get("NonClsActivationException"));
                throw;
            }
            finally
            {
                this.Cleanup(num);
            }
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordHosting, EventTrace.Event.WpfHost_IBHSRunEnd, num);
            return(num);
        }