/* * Copyright (c) 2021 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/. */ namespace SafeExamBrowser.Settings.Browser { /// /// Defines all policies for handling of URLs in the user interface and log. /// public enum UrlPolicy { /// /// Always show the URL of a resource instead of the title. Log URLs normally. /// Always, /// /// Show the URL until the title of a resource is available. Log URLs normally. /// BeforeTitle, /// /// Only show the URL on load errors, otherwise show the title of a resource. Only log URLs in error messages. /// LoadError, /// /// Never show the URL of a resource and do not log any URLs. /// Never } public static class UrlPolicyExtensions { /// /// Indicates whether URLs may be logged normally. /// public static bool CanLog(this UrlPolicy policy) { return policy == UrlPolicy.Always || policy == UrlPolicy.BeforeTitle; } /// /// Indicates whether URLs may be logged in case of an error. /// public static bool CanLogError(this UrlPolicy policy) { return policy.CanLog() || policy == UrlPolicy.LoadError; } } }