Beispiel #1
0
        private Page(Session client, Target target, FrameTree frameTree, bool ignoreHTTPSErrors, TaskQueue screenshotTaskQueue)
        {
            _client           = client;
            _target           = target;
            Keyboard          = new Keyboard(client);
            _mouse            = new Mouse(client, Keyboard);
            Touchscreen       = new Touchscreen(client, Keyboard);
            _frameManager     = new FrameManager(client, frameTree, this);
            _networkManager   = new NetworkManager(client, _frameManager);
            _emulationManager = new EmulationManager(client);
            Tracing           = new Tracing(client);
            _pageBindings     = new Dictionary <string, Func <object> >();

            _ignoreHTTPSErrors = ignoreHTTPSErrors;

            _screenshotTaskQueue = screenshotTaskQueue;

            //TODO: Do we need this bubble?
            _frameManager.FrameAttached  += (sender, e) => FrameAttached?.Invoke(this, e);
            _frameManager.FrameDetached  += (sender, e) => FrameDetached?.Invoke(this, e);
            _frameManager.FrameNavigated += (sender, e) => FrameNavigated?.Invoke(this, e);

            _networkManager.RequestCreated  += (sender, e) => RequestCreated?.Invoke(this, e);
            _networkManager.RequestFailed   += (sender, e) => RequestFailed?.Invoke(this, e);
            _networkManager.ResponseCreated += (sender, e) => ResponseCreated?.Invoke(this, e);
            _networkManager.RequestFinished += (sender, e) => RequestFinished?.Invoke(this, e);

            _client.MessageReceived += client_MessageReceived;
        }
Beispiel #2
0
        private void OnFrameNavigatedWithinDocument(NavigatedWithinDocumentResponse e)
        {
            if (Frames.TryGetValue(e.FrameId, out var frame))
            {
                frame.NavigatedWithinDocument(e.Url);

                var eventArgs = new FrameEventArgs(frame);
                FrameNavigatedWithinDocument?.Invoke(this, eventArgs);
                FrameNavigated?.Invoke(this, eventArgs);
            }
        }
Beispiel #3
0
        private void OnFrameNavigated(object sender, NavigationEventArgs navigationEventArgs)
        {
            FrameNavigated?.Invoke(this, navigationEventArgs);

            var activeKey = _menu?.SelectedLinkGroup?.GroupKey;

            foreach (var link in TitleLinks.OfType <TitleLink>())
            {
                link.IsActive = link.GroupKey == activeKey;
            }
        }
Beispiel #4
0
        private void Frame_Navigated(object sender, NavigationEventArgs navigationEventArgs)
        {
            if (Layout == TabLayout.TabWithTitle)
            {
                Title = (Frame.Content as ITitleable)?.Title;
            }

            FrameNavigated?.Invoke(this, navigationEventArgs);

            if (SaveKey != null && (_linkList.SelectedItem != null || SavePolicy == SavePolicy.Flexible))
            {
                ValuesStorage.Set(SaveKey, Frame.Source.OriginalString);
            }
        }
Beispiel #5
0
        private void OnFrameNavigated(FramePayload framePayload)
        {
            var isMainFrame = string.IsNullOrEmpty(framePayload.ParentId);
            var frame       = isMainFrame ? MainFrame : Frames[framePayload.Id];

            Contract.Assert(isMainFrame || frame != null, "We either navigate top level or have old version of the navigated frame");

            // Detach all child frames first.
            if (frame != null)
            {
                while (frame.ChildFrames.Count > 0)
                {
                    RemoveFramesRecursively(frame.ChildFrames[0]);
                }
            }

            // Update or create main frame.
            if (isMainFrame)
            {
                if (frame != null)
                {
                    // Update frame id to retain frame identity on cross-process navigation.
                    if (frame.Id != null)
                    {
                        Frames.Remove(frame.Id);
                    }
                    frame.Id = framePayload.Id;
                }
                else
                {
                    // Initial main frame navigation.
                    frame = new Frame(this, _client, null, framePayload.Id);
                }

                Frames[framePayload.Id] = frame;
                MainFrame = frame;
            }

            // Update frame payload.
            frame.Navigated(framePayload);

            FrameNavigated?.Invoke(this, new FrameEventArgs(frame));
        }
        private async Task OnFrameNavigatedAsync(FramePayload framePayload)
        {
            var isMainFrame = string.IsNullOrEmpty(framePayload.ParentId);
            var frame       = isMainFrame ? MainFrame : await GetFrameAsync(framePayload.Id).ConfigureAwait(false);

            Contract.Assert(isMainFrame || frame != null, "We either navigate top level or have old version of the navigated frame");

            // Detach all child frames first.
            if (frame != null)
            {
                while (frame.ChildFrames.Count > 0)
                {
                    RemoveFramesRecursively(frame.ChildFrames[0]);
                }
            }

            // Update or create main frame.
            if (isMainFrame)
            {
                if (frame != null)
                {
                    // Update frame id to retain frame identity on cross-process navigation.
                    if (frame.Id != null)
                    {
                        _frames.TryRemove(frame.Id, out _);
                    }
                    frame.Id = framePayload.Id;
                }
                else
                {
                    // Initial main frame navigation.
                    frame = new Frame(this, null, framePayload.Id);
                }
                _asyncFrames.AddItem(framePayload.Id, frame);
                MainFrame = frame;
            }

            // Update frame payload.
            frame.Navigated(framePayload);

            FrameNavigated?.Invoke(this, new FrameEventArgs(frame));
        }
Beispiel #7
0
 private void Frame_Navigated(object sender, NavigationEventArgs navigationEventArgs)
 {
     FrameNavigated?.Invoke(this, navigationEventArgs);
 }
Beispiel #8
0
 internal void OnFrameNavigated(Frame frame) => FrameNavigated?.Invoke(this, new FrameEventArgs(frame));