Skip to content

Commit

Permalink
Merge pull request #981 from r0x0r/chromium-arm64
Browse files Browse the repository at this point in the history
Better platform detection for Edge Chromium
  • Loading branch information
r0x0r authored Nov 12, 2022
2 parents 5125e64 + 99ca9d4 commit 8c3d5a5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
Binary file modified webview/lib/Microsoft.Web.WebView2.Core.dll
Binary file not shown.
Binary file modified webview/lib/Microsoft.Web.WebView2.WinForms.dll
Binary file not shown.
Binary file added webview/lib/arm64/WebView2Loader.dll
Binary file not shown.
Binary file modified webview/lib/x64/WebView2Loader.dll
Binary file not shown.
Binary file modified webview/lib/x86/WebView2Loader.dll
Binary file not shown.
29 changes: 17 additions & 12 deletions webview/platforms/edgechromium.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

"""
(C) 2014-2019 Roman Sirokov and contributors
(C) 2014-2022 Roman Sirokov and contributors
Licensed under BSD license
http://github.com/r0x0r/pywebview/
Expand All @@ -12,12 +12,9 @@
import json
import webbrowser
from threading import Semaphore
from ctypes import windll
from platform import architecture

from webview import _debug, _user_agent
from webview.serving import resolve_url
from webview.util import parse_api_js, interop_dll_path, parse_file_type, inject_base_uri, default_html, js_bridge_call
from webview.util import parse_api_js, interop_dll_path, default_html, js_bridge_call
from webview.js import alert
from webview.js.css import disable_text_select

Expand All @@ -29,16 +26,19 @@
clr.AddReference('System.Threading')

import System.Windows.Forms as WinForms
from System import IntPtr, Int32, String, Action, Func, Type, Environment, Uri
from System.Threading.Tasks import Task, TaskScheduler, TaskContinuationOptions
from System.Drawing import Size, Point, Icon, Color, ColorTranslator, SizeF
from System import String, Action, Uri
from System.Threading.Tasks import Task, TaskScheduler
from System.Drawing import Color

archpath = 'x64' if architecture()[0] == '64bit' else 'x86'
os.environ['Path'] = interop_dll_path(archpath) + ';' + os.environ['Path']
clr.AddReference(interop_dll_path('Microsoft.Web.WebView2.Core.dll'))
clr.AddReference(interop_dll_path('Microsoft.Web.WebView2.WinForms.dll'))

from Microsoft.Web.WebView2.WinForms import WebView2, CoreWebView2CreationProperties
from Microsoft.Web.WebView2.Core import CoreWebView2Environment


for platform in ('arm64', 'x64', 'x86'):
os.environ['Path'] += ';' + interop_dll_path(platform)


logger = logging.getLogger('pywebview')

Expand All @@ -47,7 +47,6 @@ def __init__(self, form, window):
self.pywebview_window = window
self.web_view = WebView2()
props = CoreWebView2CreationProperties()
#props.UserDataFolder = os.path.join(os.getcwd(), 'profile')
props.UserDataFolder = os.path.join(os.environ['LOCALAPPDATA'], 'pywebview')
self.web_view.CreationProperties = props
form.Controls.Add(self.web_view)
Expand Down Expand Up @@ -77,6 +76,7 @@ def __init__(self, form, window):
self.html = default_html
self.load_html(default_html, '')


def evaluate_js(self, script, id, callback=None):
def _callback(result):
if callback is None:
Expand Down Expand Up @@ -133,6 +133,10 @@ def on_new_window_request(self, _, args):
webbrowser.open(str(args.get_Uri()))

def on_webview_ready(self, sender, args):
if not args.IsSuccess:
logger.error('WebView2 initialization failed with exception:\n ' + str(args.InitializationException))
return

sender.CoreWebView2.NewWindowRequested += self.on_new_window_request
settings = sender.CoreWebView2.Settings
settings.AreDefaultContextMenusEnabled = _debug['mode']
Expand All @@ -150,6 +154,7 @@ def on_webview_ready(self, sender, args):
if self.html:
sender.CoreWebView2.NavigateToString(self.html)


def on_navigation_start(self, sender, args):
pass

Expand Down

0 comments on commit 8c3d5a5

Please sign in to comment.