2017-07-21 10:04:27 +02:00
|
|
|
|
/*
|
2018-01-16 08:24:00 +01:00
|
|
|
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
2017-07-21 10:04:27 +02:00
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using SafeExamBrowser.Contracts.Behaviour;
|
2018-02-01 08:37:12 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.Behaviour.Operations;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.Configuration;
|
|
|
|
|
using SafeExamBrowser.Contracts.I18n;
|
|
|
|
|
using SafeExamBrowser.Contracts.Logging;
|
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface;
|
2017-08-15 15:30:31 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2018-01-18 08:16:20 +01:00
|
|
|
|
namespace SafeExamBrowser.Client.Behaviour.Operations
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
2018-01-18 08:16:20 +01:00
|
|
|
|
internal class BrowserOperation : IOperation
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
|
|
|
|
private IApplicationController browserController;
|
|
|
|
|
private IApplicationInfo browserInfo;
|
|
|
|
|
private ILogger logger;
|
|
|
|
|
private ITaskbar taskbar;
|
2017-07-27 14:45:54 +02:00
|
|
|
|
private IUserInterfaceFactory uiFactory;
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2018-02-01 08:37:12 +01:00
|
|
|
|
public bool Abort { get; private set; }
|
2018-02-02 09:18:35 +01:00
|
|
|
|
public IProgressIndicator ProgressIndicator { private get; set; }
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
2017-07-26 14:36:20 +02:00
|
|
|
|
public BrowserOperation(
|
2017-07-21 10:04:27 +02:00
|
|
|
|
IApplicationController browserController,
|
|
|
|
|
IApplicationInfo browserInfo,
|
|
|
|
|
ILogger logger,
|
|
|
|
|
ITaskbar taskbar,
|
2017-07-27 14:45:54 +02:00
|
|
|
|
IUserInterfaceFactory uiFactory)
|
2017-07-21 10:04:27 +02:00
|
|
|
|
{
|
|
|
|
|
this.browserController = browserController;
|
|
|
|
|
this.browserInfo = browserInfo;
|
|
|
|
|
this.logger = logger;
|
|
|
|
|
this.taskbar = taskbar;
|
|
|
|
|
this.uiFactory = uiFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Perform()
|
|
|
|
|
{
|
2017-07-24 15:29:17 +02:00
|
|
|
|
logger.Info("Initializing browser...");
|
2018-02-02 09:30:41 +01:00
|
|
|
|
ProgressIndicator?.UpdateText(TextKey.ProgressIndicator_InitializeBrowser, true);
|
2017-07-21 10:04:27 +02:00
|
|
|
|
|
|
|
|
|
var browserButton = uiFactory.CreateApplicationButton(browserInfo);
|
|
|
|
|
|
2017-07-24 17:31:28 +02:00
|
|
|
|
browserController.Initialize();
|
2017-07-21 10:04:27 +02:00
|
|
|
|
browserController.RegisterApplicationButton(browserButton);
|
2017-07-24 17:31:28 +02:00
|
|
|
|
|
2017-08-15 15:30:31 +02:00
|
|
|
|
taskbar.AddApplication(browserButton);
|
2017-07-21 10:04:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-01 08:37:12 +01:00
|
|
|
|
public void Repeat()
|
|
|
|
|
{
|
|
|
|
|
// Nothing to do here...
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-21 10:04:27 +02:00
|
|
|
|
public void Revert()
|
|
|
|
|
{
|
2017-07-24 17:31:28 +02:00
|
|
|
|
logger.Info("Terminating browser...");
|
2018-02-02 09:30:41 +01:00
|
|
|
|
ProgressIndicator?.UpdateText(TextKey.ProgressIndicator_TerminateBrowser, true);
|
2017-07-26 14:36:20 +02:00
|
|
|
|
|
2017-07-24 17:31:28 +02:00
|
|
|
|
browserController.Terminate();
|
2017-07-21 10:04:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|