SEBWIN-820, #764: Fixed missing content of isolated clipboard after navigation or reload.

This commit is contained in:
Damian Büchel 2024-03-13 17:38:10 +01:00
parent 4b222df6c5
commit 514414e322
2 changed files with 12 additions and 5 deletions

View file

@ -158,7 +158,7 @@ namespace SafeExamBrowser.Browser
var downloadLogger = logger.CloneFor($"{nameof(DownloadHandler)} #{Id}");
var downloadHandler = new DownloadHandler(appConfig, downloadLogger, settings, WindowSettings);
var keyboardHandler = new KeyboardHandler();
var renderHandler = new RenderProcessMessageHandler(appConfig, keyGenerator, settings, text);
var renderHandler = new RenderProcessMessageHandler(appConfig, clipboard, keyGenerator, settings, text);
var requestFilter = new RequestFilter();
var requestLogger = logger.CloneFor($"{nameof(RequestHandler)} #{Id}");
var resourceHandler = new ResourceHandler(appConfig, requestFilter, keyGenerator, logger, sessionMode, settings, WindowSettings, text);

View file

@ -18,14 +18,16 @@ namespace SafeExamBrowser.Browser.Handlers
internal class RenderProcessMessageHandler : IRenderProcessMessageHandler
{
private readonly AppConfig appConfig;
private readonly Clipboard clipboard;
private readonly ContentLoader contentLoader;
private readonly IKeyGenerator keyGenerator;
private readonly BrowserSettings settings;
private readonly IText text;
internal RenderProcessMessageHandler(AppConfig appConfig, IKeyGenerator keyGenerator, BrowserSettings settings, IText text)
internal RenderProcessMessageHandler(AppConfig appConfig, Clipboard clipboard, IKeyGenerator keyGenerator, BrowserSettings settings, IText text)
{
this.appConfig = appConfig;
this.clipboard = clipboard;
this.contentLoader = new ContentLoader(text);
this.keyGenerator = keyGenerator;
this.settings = settings;
@ -37,7 +39,7 @@ namespace SafeExamBrowser.Browser.Handlers
var browserExamKey = keyGenerator.CalculateBrowserExamKeyHash(settings.ConfigurationKey, settings.BrowserExamKeySalt, frame.Url);
var configurationKey = keyGenerator.CalculateConfigurationKeyHash(settings.ConfigurationKey, frame.Url);
var api = contentLoader.LoadApi(browserExamKey, configurationKey, appConfig.ProgramBuildVersion);
var clipboard = contentLoader.LoadClipboard();
var clipboardScript = contentLoader.LoadClipboard();
frame.ExecuteJavaScriptAsync(api);
@ -48,7 +50,12 @@ namespace SafeExamBrowser.Browser.Handlers
if (settings.UseIsolatedClipboard)
{
frame.ExecuteJavaScriptAsync(clipboard);
frame.ExecuteJavaScriptAsync(clipboardScript);
if (clipboard.Content != default)
{
frame.ExecuteJavaScriptAsync($"SafeExamBrowser.clipboard.update('', '{clipboard.Content}');");
}
}
}