public void BeforeApplicationWindowPopup(BeforePopupEventArgs eventArgs)
        {
            if (eventArgs == null)
            {
                Logger.Error("Unable to apply settings to popup window. EventArgs is null");
                return;
            }

            // Create pending request based on details supplied to window.open
            var options = new CreateWindowOptions {
                Id = eventArgs.TargetFrameName
            };

            if (eventArgs.PopupFeatures != null)
            {
                options.OuterBounds = new BoundsSpecification
                {
                    Left   = eventArgs.PopupFeatures.X.HasValue ? eventArgs.PopupFeatures.X.Value : double.NaN,
                    Top    = eventArgs.PopupFeatures.Y.HasValue ? eventArgs.PopupFeatures.Y.Value : double.NaN,
                    Height = eventArgs.PopupFeatures.Height.HasValue ? eventArgs.PopupFeatures.Height.Value : double.NaN,
                    Width  = eventArgs.PopupFeatures.Width.HasValue ? eventArgs.PopupFeatures.Width.Value : double.NaN
                };

                options.InitialState = "normal";
                if (eventArgs.PopupFeatures.Fullscreen)
                {
                    options.InitialState = "fullscreen";
                }

                options.Resizable = eventArgs.PopupFeatures.Resizable;
                options.Frame     = new FrameOptions {
                    Type = Application.Package.Manifest.DefaultFrameType
                };
                options.AlwaysOnTop = false;
                options.Focused     = true;
                options.Hidden      = false;
            }
            var request = new CreateWindowRequest(eventArgs.TargetUrl, options, null, eventArgs.TargetFrameName);

            lock (_pendingWindowCreations)
            {
                _pendingWindowCreations.Add(request);
            }
            eventArgs.NeedCustomPopupWindow = true;
            eventArgs.Cancel = false;
        }
        public virtual void CreateWindow(CreateWindowRequest request)
        {
            if (request == null)
            {
                Logger.Error("Unable to create window because create window request is null");
                throw new ArgumentNullException("request");
            }

            var browser = GetRootBrowser();

            if (browser != null)
            {
                lock (_pendingWindowCreations)
                {
                    _pendingWindowCreations.Add(request);
                }
                browser.ExecuteJavaScript(string.Format("window.open('{0}', '{1}');", request.StartUrl, request.RequestId));
                Logger.Debug("Created window with URL {0} and ID {1}", request.StartUrl, request.RequestId);
            }
            else
            {
                Logger.Error("Unable to create window because root browser is null");
            }
        }