コード例 #1
0
ファイル: NavigationService.cs プロジェクト: JianwenSun/cc
        private void CleanupAfterNavigationCancelled(NavigateQueueItem localNavigateQueueItem)
        {
            if (JournalScope != null)
            {
                JournalScope.AbortJournalNavigation();
            }

            // If event was canceled then we need to remove it.
            // If the event was canceled AND superceded by StopLoading or Navigate, it won't be
            // in the list but Remove won't throw an exception so not doing an if check here
            // Don't clear the whole list here since this could be an intermediate Navigate in a recursive callstack
            // and the caller could now proceed with the navigation
            _recursiveNavigateList.Remove(localNavigateQueueItem);

            if (_navigatorHostImpl != null)
            {
                _navigatorHostImpl.OnSourceUpdatedFromNavService(true /* journalOrCancel */);
            }

            // TFS Dev10 451993 - Browser downloading state not reset; case 4.
            InformBrowserAboutStoppedNavigation();
        }
コード例 #2
0
ファイル: NavigationService.cs プロジェクト: JianwenSun/cc
        // returns whether or not to navigate
        private bool HandleNavigating(Uri source, Object content, Object navState, WebRequest newRequest, bool navigateOnSourceChanged)
        {
            NavigateInfo navigateInfo = navState as NavigateInfo;

            if (navigateInfo != null)
            {
                Debug.Assert(navigateInfo.IsConsistent);
                Debug.Assert(source == null ||
                             navigateInfo.Source == null ||
                             IsSameUri(null, navigateInfo.Source, source, false /* withFragment */),
                             "Source argument does not match NavigateInfo.Source");
                // Don't want to overwrite one passed in
                if (source == null)
                {
                    source = navigateInfo.Source;
                }
            }

            NavigateQueueItem localNavigateQueueItem = new NavigateQueueItem(source,
                                                                             content,
                                                                             navigateInfo != null ? navigateInfo.NavigationMode : NavigationMode.New,
                                                                             navState,
                                                                             this);

            // Set the pending state. _navigateQueue item may get overwritten in a recursive StopLoading
            // or Navigate call (called from FireNavigating). If so then we need to cancel this navigation
            // since the last StopLoading and Navigate call will supercede this call. We need to cancel
            // this navigation is such a case even if this event was not explicitly cancelled
            _recursiveNavigateList.Add(localNavigateQueueItem);

            // For each new navigation we need to re-determine if we are the initial navigator
            _isNavInitiatorValid = false;

            // If this is not a navigation started by Source DP change, we notify the INavigatorHost
            // that source changed.
            if ((_navigatorHostImpl != null) && (!navigateOnSourceChanged))
            {
                _navigatorHostImpl.OnSourceUpdatedFromNavService(IsJournalNavigation(navigateInfo) /* journalOrCancel */);
            }

            // Event handler exception continuality: if exception occurs in Navigating event handler, the cleanup action is
            // the same as the event being cancelled.
            bool allowNavigation = false;
            try
            {
                allowNavigation = FireNavigating(source, content, navState, newRequest);
            }
            catch
            {
                CleanupAfterNavigationCancelled(localNavigateQueueItem);

                throw;
            }

            if (allowNavigation == true)
            {
                DoStopLoading(false /*clearRecursiveLoads*/, true /*fireEvents*/);
                Debug.Assert(PendingNavigationList.Count == 0,
                             "Pending child navigations were not stopped before starting a new navigation");

                // NavigationStopped event handler could have caused a new navigation.
                if (_recursiveNavigateList.Contains(localNavigateQueueItem) == false)
                    return false;

                _recursiveNavigateList.Clear();

                // Continue with the navigation
                Debug.Assert(_navigateQueueItem == null, "Previous nav queue item should be cleared by now.");
                _navigateQueueItem = localNavigateQueueItem;

                _request = newRequest;

                _navStatus = NavigationStatus.Navigating;
            }
            else
            {
                CleanupAfterNavigationCancelled(localNavigateQueueItem);
            }

            return allowNavigation;
        }