예제 #1
0
        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);
        }
예제 #2
0
 /// <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;
 }
예제 #3
0
 public WebViewContainer(EvasObject parent) : base(parent)
 {
     WebView = new TWebView(parent);
     SetContent(WebView);
     AllowFocus(true);
     Focused   += OnFocused;
     Unfocused += OnUnfocused;
 }
예제 #4
0
 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);
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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));
        }
예제 #11
0
 public static string GetInterceptRequestUrl(this TWebView webView, IntPtr request)
 {
     return(Marshal.PtrToStringAnsi(_ewk_intercept_request_url_get(request)) ?? string.Empty);
 }
예제 #12
0
 public static bool IgnoreInterceptRequest(this TWebView webView, IntPtr request)
 {
     return(ewk_intercept_request_ignore(request));
 }
예제 #13
0
 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));
 }