Restore SEBPatch
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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 System;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Contracts.Browser.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the state of a download item.
|
||||
/// </summary>
|
||||
public class DownloadItemState
|
||||
{
|
||||
/// <summary>
|
||||
/// The current completion of the item, as percentage value from <c>0.0</c> to <c>1.0</c>.
|
||||
/// </summary>
|
||||
public double Completion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The full path of the download location for the item.
|
||||
/// </summary>
|
||||
public string FullPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The unique identifier of the item.
|
||||
/// </summary>
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the download was cancelled.
|
||||
/// </summary>
|
||||
public bool IsCancelled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the download was completed.
|
||||
/// </summary>
|
||||
public bool IsComplete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The download URL of the item.
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
|
||||
public DownloadItemState(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Contracts.Browser.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// The data resulting from a JavaScript expression evaluation.
|
||||
/// </summary>
|
||||
public class JavaScriptResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates if the JavaScript was evaluated successfully or not.
|
||||
/// </summary>
|
||||
public bool Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The error message, in case of an unsuccessful evaluation of the JavaScript expression.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The data item returned by the JavaScript expression.
|
||||
/// </summary>
|
||||
public object Result { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Contracts.Browser.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the address has changed to the specified value.
|
||||
/// </summary>
|
||||
public delegate void AddressChangedEventHandler(string address);
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Contracts.Browser.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that a page search is being requested.
|
||||
/// </summary>
|
||||
public delegate void FindRequestedEventHandler(string term, bool isInitial, bool caseSensitive, bool forward = true);
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Contracts.Browser.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates a load error for a browser request.
|
||||
/// </summary>
|
||||
public delegate void LoadFailedEventHandler(int errorCode, string errorText, bool isMainRequest, string url);
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Contracts.Browser.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the loading state of a <see cref="IBrowserControl"/> has changed, i.e. whether it's loading or not.
|
||||
/// </summary>
|
||||
public delegate void LoadingStateChangedEventHandler(bool isLoading);
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Contracts.Browser.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the title of a <see cref="IBrowserControl"/> has changed.
|
||||
/// </summary>
|
||||
public delegate void TitleChangedEventHandler(string title);
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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 System;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Browser.Data;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Browser.Events;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Contracts.Browser
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the functionality of a browser control (i.e. an instance of the browser resp. its user interface) and is normally embedded
|
||||
/// within an <see cref="IBrowserWindow"/>.
|
||||
/// </summary>
|
||||
public interface IBrowserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The address which is currently loaded.
|
||||
/// </summary>
|
||||
string Address { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether a backward navigation can be performed.
|
||||
/// </summary>
|
||||
bool CanNavigateBackwards { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether a forward navigation can be performed.
|
||||
/// </summary>
|
||||
bool CanNavigateForwards { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The user interface control to be embedded in an <see cref="IBrowserWindow"/>.
|
||||
/// </summary>
|
||||
object EmbeddableControl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the address of the browser control changes.
|
||||
/// </summary>
|
||||
event AddressChangedEventHandler AddressChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when a load error occurs.
|
||||
/// </summary>
|
||||
event LoadFailedEventHandler LoadFailed;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the loading state of the browser control changes.
|
||||
/// </summary>
|
||||
event LoadingStateChangedEventHandler LoadingStateChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the current page (and thus the title) of the browser control changes.
|
||||
/// </summary>
|
||||
event TitleChangedEventHandler TitleChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes the browser control (e.g. stops audio / video playback) and releases all used resources.
|
||||
/// </summary>
|
||||
void Destroy();
|
||||
|
||||
/// <summary>
|
||||
/// Executes the given JavaScript code in the browser. An optional callback may be used to process a potential <see cref="JavaScriptResult"/>.
|
||||
/// </summary>
|
||||
void ExecuteJavaScript(string code, Action<JavaScriptResult> callback = default);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to find the given term on the current page according to the specified parameters.
|
||||
/// </summary>
|
||||
void Find(string term, bool isInitial, bool caseSensitive, bool forward = true);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the browser control.
|
||||
/// </summary>
|
||||
void Initialize();
|
||||
|
||||
/// <summary>
|
||||
/// Navigates to the previous page in the browser control history.
|
||||
/// </summary>
|
||||
void NavigateBackwards();
|
||||
|
||||
/// <summary>
|
||||
/// Navigates to the next page in the browser control history.
|
||||
/// </summary>
|
||||
void NavigateForwards();
|
||||
|
||||
/// <summary>
|
||||
/// Navigates to the specified web address.
|
||||
/// </summary>
|
||||
void NavigateTo(string address);
|
||||
|
||||
/// <summary>
|
||||
/// Opens the developer console or actives it, if it is already open.
|
||||
/// </summary>
|
||||
void ShowDeveloperConsole();
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the current web page.
|
||||
/// </summary>
|
||||
void Reload();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the page zoom to the given level. A value of <c>0</c> resets the page zoom.
|
||||
/// </summary>
|
||||
void Zoom(double level);
|
||||
}
|
||||
}
|
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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 System;
|
||||
using SafeExamBrowser.Browser.Contracts.Events;
|
||||
using SafeExamBrowser.Core.Contracts.Resources.Icons;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Browser.Data;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Browser.Events;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.UserInterface.Contracts.Browser
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the functionality of a browser window, i.e. a window with an embedded browser instance (see <see cref="IBrowserControl"/>).
|
||||
/// </summary>
|
||||
public interface IBrowserWindow : IWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Enables the backward navigation button.
|
||||
/// </summary>
|
||||
bool CanNavigateBackwards { set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enables the forward navigation button.
|
||||
/// </summary>
|
||||
bool CanNavigateForwards { set; }
|
||||
|
||||
/// <summary>
|
||||
/// The native handle of the window.
|
||||
/// </summary>
|
||||
IntPtr Handle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the user changed the URL.
|
||||
/// </summary>
|
||||
event AddressChangedEventHandler AddressChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the user would like to navigate backwards.
|
||||
/// </summary>
|
||||
event ActionRequestedEventHandler BackwardNavigationRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the user would like to open the developer console.
|
||||
/// </summary>
|
||||
event ActionRequestedEventHandler DeveloperConsoleRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the user would like to search the current page.
|
||||
/// </summary>
|
||||
event FindRequestedEventHandler FindRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the user would like to navigate forwards.
|
||||
/// </summary>
|
||||
event ActionRequestedEventHandler ForwardNavigationRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the user would like to navigate home.
|
||||
/// </summary>
|
||||
event ActionRequestedEventHandler HomeNavigationRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the browser window wants to lose focus to the taskbar.
|
||||
/// </summary>
|
||||
event LoseFocusRequestedEventHandler LoseFocusRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the user would like to reload the current page.
|
||||
/// </summary>
|
||||
event ActionRequestedEventHandler ReloadRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the user would like to zoom in.
|
||||
/// </summary>
|
||||
event ActionRequestedEventHandler ZoomInRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the user would like to zoom out.
|
||||
/// </summary>
|
||||
event ActionRequestedEventHandler ZoomOutRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the user would like to reset the zoom factor.
|
||||
/// </summary>
|
||||
event ActionRequestedEventHandler ZoomResetRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the focus on the address bar of the window.
|
||||
/// </summary>
|
||||
void FocusAddressBar();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the focus on the browser content of the window.
|
||||
/// </summary>
|
||||
void FocusBrowser();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the focus on the toolbar of the window. If the parameter is set to true, the first focusable control on the toolbar gets focused.
|
||||
/// If it is set to false, the last one.
|
||||
/// </summary>
|
||||
void FocusToolbar(bool forward);
|
||||
|
||||
/// <summary>
|
||||
/// Displays the find toolbar to search the content of a page.
|
||||
/// </summary>
|
||||
void ShowFindbar();
|
||||
|
||||
/// <summary>
|
||||
/// Updates the address bar of the browser window to the given value.
|
||||
/// </summary>
|
||||
void UpdateAddress(string adress);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the icon of the browser window.
|
||||
/// </summary>
|
||||
void UpdateIcon(IconResource icon);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the download state for the given item.
|
||||
/// </summary>
|
||||
void UpdateDownloadState(DownloadItemState state);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the loading state according to the given value.
|
||||
/// </summary>
|
||||
void UpdateLoadingState(bool isLoading);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the page load progress according to the given value.
|
||||
/// </summary>
|
||||
void UpdateProgress(double value);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the title of the browser window to the given value.
|
||||
/// </summary>
|
||||
void UpdateTitle(string title);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the display value of the current page zoom. Value is expected to be in percentage.
|
||||
/// </summary>
|
||||
void UpdateZoomLevel(double value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user