protected override void OnElementChanged(ElementChangedEventArgs <WebView> e) { if (_control == null) { TChromium.Initialize(); Forms.Context.Terminated += (sender, arg) => TChromium.Shutdown(); _control = new TWebView(Forms.Context.MainWindow); _control.LoadStarted += OnLoadStarted; _control.LoadFinished += OnLoadFinished; _control.LoadError += OnLoadError; SetNativeView(_control); } if (e.OldElement != null) { e.OldElement.EvalRequested -= OnEvalRequested; e.OldElement.GoBackRequested -= OnGoBackRequested; e.OldElement.GoForwardRequested -= OnGoForwardRequested; } if (e.NewElement != null) { e.NewElement.EvalRequested += OnEvalRequested; e.NewElement.GoForwardRequested += OnGoForwardRequested; e.NewElement.GoBackRequested += OnGoBackRequested; Load(); } base.OnElementChanged(e); }
/// <summary> /// Initializes a new instance of <see cref="TizenWebViewManager"/> /// </summary> /// <param name="blazorMauiWebViewHandler">The <see cref="BlazorWebViewHandler"/>.</param> /// <param name="webview">A wrapper to access platform-specific WebView APIs.</param> /// <param name="provider">The <see cref="IServiceProvider"/> for the application.</param> /// <param name="dispatcher">A <see cref="Dispatcher"/> instance instance that can marshal calls to the required thread or sync context.</param> /// <param name="fileProvider">Provides static content to the webview.</param> /// <param name="jsComponents">Describes configuration for adding, removing, and updating root components from JavaScript code.</param> /// <param name="contentRootRelativeToAppRoot">Path to the directory containing application content files.</param> /// <param name="hostPageRelativePath">Path to the host page within the fileProvider.</param> public TizenWebViewManager(BlazorWebViewHandler blazorMauiWebViewHandler, TWebView webview, IServiceProvider provider, Dispatcher dispatcher, IFileProvider fileProvider, JSComponentConfigurationStore jsComponents, string contentRootRelativeToAppRoot, string hostPageRelativePath) : base(provider, dispatcher, new Uri(AppOrigin), fileProvider, jsComponents, hostPageRelativePath) { _blazorMauiWebViewHandler = blazorMauiWebViewHandler ?? throw new ArgumentNullException(nameof(blazorMauiWebViewHandler)); _webview = webview ?? throw new ArgumentNullException(nameof(webview)); _contentRootRelativeToAppRoot = contentRootRelativeToAppRoot; }
public WebViewContainer(EvasObject parent) : base(parent) { WebView = new TWebView(parent); SetContent(WebView); AllowFocus(true); Focused += OnFocused; Unfocused += OnUnfocused; }
public WebViewContainer(EvasObject parent) : base(parent) { SetTheme("layout", "elm_widget", "default"); WebView = new TWebView(parent); SetContent(WebView); AllowFocus(true); Focused += OnFocused; Unfocused += OnUnfocused; }
public static void SetInterceptRequestCallback(this TWebView webView, InterceptRequestCallback callback) { #pragma warning disable CA1062 // Validate arguments of public methods var context = webView.GetContext(); #pragma warning restore CA1062 // Validate arguments of public methods var handleField = context.GetType().GetField("_handle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var contextHandle = (IntPtr)handleField.GetValue(context); ewk_context_intercept_request_callback_set(contextHandle, callback, IntPtr.Zero); }
public static void SetInspectorStart(this TWebView webView, uint port) { var context = webView.GetContext(); var handleField = context.GetType().GetField("_handle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var contextHandle = (IntPtr?)handleField?.GetValue(context); if (contextHandle != null) { ewk_context_inspector_server_start(contextHandle.Value, port); } }
public static void SetInterceptRequestCallback(this TWebView webView, InterceptRequestCallback callback) { var context = webView.GetContext(); var handleField = context.GetType().GetField("_handle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var contextHandle = (IntPtr?)handleField?.GetValue(context); if (contextHandle != null) { ewk_context_intercept_request_callback_set(contextHandle.Value, callback, IntPtr.Zero); } }
#pragma warning disable CA1055 // URI-like return values should not be strings #pragma warning disable IDE0060 // Remove unused parameter public static string GetInterceptRequestUrl(this TWebView webView, IntPtr request) #pragma warning restore IDE0060 // Remove unused parameter #pragma warning restore CA1055 // URI-like return values should not be strings { return(Marshal.PtrToStringAnsi(_ewk_intercept_request_url_get(request))); }
#pragma warning disable IDE0060 // Remove unused parameter public static bool IgnoreInterceptRequest(this TWebView webView, IntPtr request) #pragma warning restore IDE0060 // Remove unused parameter { return(ewk_intercept_request_ignore(request)); }
#pragma warning disable IDE0060 // Remove unused parameter public static bool SetInterceptRequestResponse(this TWebView webView, IntPtr request, string header, string body, uint length) #pragma warning restore IDE0060 // Remove unused parameter { return(ewk_intercept_request_response_set(request, header, body, length)); }
public static string GetInterceptRequestUrl(this TWebView webView, IntPtr request) { return(Marshal.PtrToStringAnsi(_ewk_intercept_request_url_get(request)) ?? string.Empty); }
public static bool IgnoreInterceptRequest(this TWebView webView, IntPtr request) { return(ewk_intercept_request_ignore(request)); }
public static bool SetInterceptRequestResponse(this TWebView webView, IntPtr request, string header, byte[] body, uint length) { return(ewk_intercept_request_response_set(request, header, body, length)); }