internal void LoadHistoryStream(MemoryStream loadStream, bool firstLoadFromHistory) { if (Application.Current == null) { return; } LoadHistoryStreamInfo info = new LoadHistoryStreamInfo(); info.loadStream = loadStream; info.firstLoadFromHistory = firstLoadFromHistory; Application.Current.Dispatcher.Invoke( DispatcherPriority.Send, new DispatcherOperationCallback(_LoadHistoryStreamDelegate), info); }
private object _LoadHistoryStreamDelegate(object arg) { Journal journal = null; JournalEntry entry = null; LoadHistoryStreamInfo info = (LoadHistoryStreamInfo)arg; if (IsShutdown() == true) { return(null); } // Reset the memory stream pointer back to the begining and get the persisted object info.loadStream.Seek(0, System.IO.SeekOrigin.Begin); object journaledObject = DeserializeJournaledObject(info.loadStream); //This is the very first load from history, so need to set the BaseUri and StartupUri. if (info.firstLoadFromHistory) { // The journal does not get saved on Ctrl+N. Because of this, // here we can get just an index, like in the 'else' case below. if (!(journaledObject is BrowserJournal)) { return(null); } BrowserJournal browserJournal = (BrowserJournal)journaledObject; journal = browserJournal.Journal; entry = journal.CurrentEntry; if (entry == null) // See special case in _GetSaveHistoryBytesDelegate(). { entry = journal.GetGoBackEntry(); // could still be null } //This will create the frame to use for hosting { NavigationService navigationService = null; navigationService = _rbw.Value.NavigationService; } _rbw.Value.SetJournalForBrowserInterop(journal); //This should already be set for the container and exe cases. The former //sets it to the transformed ssres scheme and we don't want to overwrite it. if (BindUriHelper.BaseUri == null) { BindUriHelper.BaseUri = browserJournal.BaseUri; } //CHECK: For xaml case, what should we set as the Startup Uri ? We set it the initial //uri we started with, should this be changed to creating the window explicitly //and navigating the window instead of setting the StartupUri? //(Application.Current as Application).StartupUri = entry.Uri; Debug.Assert(Application.Current != null, "BrowserJournalingError: Application object should already be created"); if (entry != null) { //Prevent navigations to StartupUri for history loads by canceling the StartingUp event Application.Current.Startup += new System.Windows.StartupEventHandler(this.OnStartup); _rbw.Value.JournalNavigationScope.NavigateToEntry(entry); } //else: fall back on navigating to StartupUri } else { if (!(journaledObject is int)) { return(null); } journal = _rbw.Value.Journal; int index = journal.FindIndexForEntryWithId((int)journaledObject); Debug.Assert(journal[index].Id == (int)journaledObject, "BrowserJournalingError: Index retrieved from journal stream does not match index of journal entry"); // Check whether the navigation is canceled. if (!_rbw.Value.JournalNavigationScope.NavigateToEntry(index)) { // When the navigation is canceled, we want to notify browser to prevent the internal journal from // getting out of sync with the browser's. // The exception will be caught by the interop layer and browser will cancel the navigation as a result. // If the navigation is initiated pragmatically by calling GoBack/Forward (comparing to user initiated // by clicking the back/forward button), this will result in a managed exception at the call to ibcs.GoBack() // in rbw.GoBackOverride(). rbw catches the exception when this happens. throw new OperationCanceledException(); } } return(null); }
internal void LoadHistoryStream(MemoryStream loadStream, bool firstLoadFromHistory) { if (Application.Current == null) { return; } LoadHistoryStreamInfo info = new LoadHistoryStreamInfo(); info.loadStream = loadStream ; info.firstLoadFromHistory = firstLoadFromHistory ; Application.Current.Dispatcher.Invoke( DispatcherPriority.Send, new DispatcherOperationCallback(_LoadHistoryStreamDelegate), info); }