64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
/*
|
|
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
|
*
|
|
* 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.Core.Contracts.OperationModel;
|
|
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
|
using SafeExamBrowser.I18n.Contracts;
|
|
using SafeExamBrowser.Logging.Contracts;
|
|
using SafeExamBrowser.UserInterface.Contracts;
|
|
using SafeExamBrowser.UserInterface.Contracts.Shell;
|
|
|
|
namespace SafeExamBrowser.Client.Operations
|
|
{
|
|
internal class BrowserOperation : ClientOperation
|
|
{
|
|
private IActionCenter actionCenter;
|
|
private ILogger logger;
|
|
private ITaskbar taskbar;
|
|
private IUserInterfaceFactory uiFactory;
|
|
|
|
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
|
public override event StatusChangedEventHandler StatusChanged;
|
|
|
|
public BrowserOperation(
|
|
IActionCenter actionCenter,
|
|
ClientContext context,
|
|
ILogger logger,
|
|
ITaskbar taskbar,
|
|
IUserInterfaceFactory uiFactory) : base(context)
|
|
{
|
|
this.actionCenter = actionCenter;
|
|
this.logger = logger;
|
|
this.taskbar = taskbar;
|
|
this.uiFactory = uiFactory;
|
|
}
|
|
|
|
public override OperationResult Perform()
|
|
{
|
|
logger.Info("Initializing browser...");
|
|
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeBrowser);
|
|
|
|
Context.Browser.Initialize();
|
|
|
|
actionCenter.AddApplicationControl(uiFactory.CreateApplicationControl(Context.Browser, Location.ActionCenter));
|
|
taskbar.AddApplicationControl(uiFactory.CreateApplicationControl(Context.Browser, Location.Taskbar));
|
|
|
|
return OperationResult.Success;
|
|
}
|
|
|
|
public override OperationResult Revert()
|
|
{
|
|
logger.Info("Terminating browser...");
|
|
StatusChanged?.Invoke(TextKey.OperationStatus_TerminateBrowser);
|
|
|
|
Context.Browser.Terminate();
|
|
|
|
return OperationResult.Success;
|
|
}
|
|
}
|
|
}
|