Mercurial > dwindows
annotate win/edge.cpp @ 2290:3c3f0023ae02
GTK4: Fix menu action setup by adding code to install group actions into
the menu bar or popover menu when it exists. Delay setup until it is
available then use the cached parent saved on the menu during subsequent
creation.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 05 Feb 2021 03:24:51 +0000 |
parents | d3974aa8ad64 |
children | 2e804b4db81e |
rev | line source |
---|---|
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1 /* edge.cpp |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2 * |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3 * Allows dw_html_new() to embed a Microsoft Edge (Chromium) browser. |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4 * |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5 * Requires Windows 10, 8 or 7 with Microsoft Edge (Chromium) installed. |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6 * |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7 * Only included when BUILD_EDGE is defined, will fall back to embedded IE. |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8 */ |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
9 #include "dw.h" |
2167
da33732f182d
Win: Add support for building with Clang/LLVM on Windows. SET CLANG=Y
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2164
diff
changeset
|
10 #include "WebView2.h" |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
11 #include <wrl.h> |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
12 |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
13 using namespace Microsoft::WRL; |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
14 |
2034
89d62197124b
Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2033
diff
changeset
|
15 #define _DW_HTML_DATA_NAME "_dw_edge" |
89d62197124b
Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2033
diff
changeset
|
16 #define _DW_HTML_DATA_LOCATION "_dw_edge_location" |
89d62197124b
Visual C in C++ mode complains about missing const declarations in paramaters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2033
diff
changeset
|
17 #define _DW_HTML_DATA_RAW "_dw_edge_raw" |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
18 |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
19 extern "C" { |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
20 |
2018
663d79f28e46
Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2015
diff
changeset
|
21 /* Import the character conversion functions from dw.c */ |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
22 LPWSTR _myUTF8toWide(const char* utf8string, void* outbuf); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
23 char* _myWideToUTF8(LPCWSTR widestring, void* outbuf); |
2018
663d79f28e46
Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2015
diff
changeset
|
24 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) |
663d79f28e46
Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2015
diff
changeset
|
25 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL) |
663d79f28e46
Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2015
diff
changeset
|
26 LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2); |
2222
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
27 void _DWCreateJunction(LPWSTR source, LPWSTR target); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
28 LPWSTR _DWGetEdgeStablePath(void); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
29 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
30 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
31 class EdgeBrowser |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
32 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
33 public: |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
34 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); |
2124
f9a2fc59611c
Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2123
diff
changeset
|
35 BOOL Detect(LPWSTR AppID); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
36 protected: |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
37 Microsoft::WRL::ComPtr<ICoreWebView2Environment> Env; |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
38 }; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
39 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
40 class EdgeWebView |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
41 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
42 public: |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
43 VOID Action(int action); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
44 int Raw(const char* string); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
45 int URL(const char* url); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
46 int JavascriptRun(const char* script, void* scriptdata); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
47 VOID DoSize(VOID); |
2065
2dacac5e4023
Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2060
diff
changeset
|
48 VOID Setup(HWND hwnd, ICoreWebView2Controller* webview); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
49 VOID Close(VOID); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
50 protected: |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
51 HWND hWnd = nullptr; |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
52 Microsoft::WRL::ComPtr<ICoreWebView2> WebView; |
2065
2dacac5e4023
Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2060
diff
changeset
|
53 Microsoft::WRL::ComPtr<ICoreWebView2Controller> WebHost; |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
54 }; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
55 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
56 LRESULT CALLBACK EdgeBrowser::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
57 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
58 switch (uMsg) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
59 { |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
60 case WM_SIZE: |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
61 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
62 // Resize the browser object to fit the window |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
63 EdgeWebView *webview; |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
64 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
65 // Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
66 // we initially attached the browser object to this window. |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
67 webview = (EdgeWebView*)dw_window_get_data(hWnd, _DW_HTML_DATA_NAME); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
68 // Resize WebView to fit the bounds of the parent window |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
69 if (webview) |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
70 webview->DoSize(); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
71 return(0); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
72 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
73 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
74 case WM_PAINT: |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
75 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
76 PAINTSTRUCT ps; |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
77 HDC hdc = BeginPaint(hWnd, &ps); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
78 EndPaint(hWnd, &ps); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
79 return(0); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
80 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
81 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
82 case WM_CREATE: |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
83 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
84 // Step 3 - Create a single WebView within the parent window |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
85 // Create a WebView, whose parent is the main window hWnd |
2065
2dacac5e4023
Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2060
diff
changeset
|
86 Env->CreateCoreWebView2Controller(hWnd, Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>( |
2dacac5e4023
Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2060
diff
changeset
|
87 [hWnd](HRESULT result, ICoreWebView2Controller* webhost) -> HRESULT { |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
88 EdgeWebView* WebView = new EdgeWebView; |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
89 ICoreWebView2* webview; |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
90 |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
91 WebView->Setup(hWnd, webhost); |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
92 dw_window_set_data(hWnd, _DW_HTML_DATA_NAME, DW_POINTER(WebView)); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
93 |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
94 if (SUCCEEDED(webhost->get_CoreWebView2(&webview))) { |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
95 // Add a few settings for the webview |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
96 // this is a redundant demo step as they are the default settings values |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
97 ICoreWebView2Settings* Settings; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
98 webview->get_Settings(&Settings); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
99 Settings->put_IsScriptEnabled(TRUE); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
100 Settings->put_AreDefaultScriptDialogsEnabled(TRUE); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
101 Settings->put_IsWebMessageEnabled(TRUE); |
2045
cb195d76de8e
Win: Make HTML_RESULT event match other platforms and disable dev tools when not DEBUG.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2044
diff
changeset
|
102 #ifndef DEBUG |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
103 Settings->put_AreDevToolsEnabled(FALSE); |
2045
cb195d76de8e
Win: Make HTML_RESULT event match other platforms and disable dev tools when not DEBUG.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2044
diff
changeset
|
104 #endif |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
105 |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
106 // Save the token, we might need to dw_window_set_data() this value |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
107 // for later use to remove the handlers |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
108 EventRegistrationToken token; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
109 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
110 // Register a handler for the NavigationStarting event. |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
111 webview->add_NavigationStarting( |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
112 Callback<ICoreWebView2NavigationStartingEventHandler>( |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
113 [hWnd](ICoreWebView2* sender, |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
114 ICoreWebView2NavigationStartingEventArgs* args) -> HRESULT |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
115 { |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
116 LPWSTR uri; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
117 sender->get_Source(&uri); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
118 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
119 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED), |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
120 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri)); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
121 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
122 return S_OK; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
123 }).Get(), &token); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
124 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
125 // Register a handler for the SourceChanged event. |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
126 webview->add_SourceChanged( |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
127 Callback<ICoreWebView2SourceChangedEventHandler >( |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
128 [hWnd](ICoreWebView2* sender, |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
129 ICoreWebView2SourceChangedEventArgs* args) -> HRESULT |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
130 { |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
131 LPWSTR uri; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
132 sender->get_Source(&uri); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
133 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
134 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_REDIRECT), |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
135 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri)); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
136 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
137 return S_OK; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
138 }).Get(), &token); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
139 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
140 // Register a handler for the ContentLoading event. |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
141 webview->add_ContentLoading( |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
142 Callback<ICoreWebView2ContentLoadingEventHandler >( |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
143 [hWnd](ICoreWebView2* sender, |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
144 ICoreWebView2ContentLoadingEventArgs* args) -> HRESULT |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
145 { |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
146 LPWSTR uri; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
147 sender->get_Source(&uri); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
148 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
149 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING), |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
150 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri)); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
151 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
152 return S_OK; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
153 }).Get(), &token); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
154 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
155 // Register a handler for the NavigationCompleted event. |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
156 webview->add_NavigationCompleted( |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
157 Callback<ICoreWebView2NavigationCompletedEventHandler>( |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
158 [hWnd](ICoreWebView2* sender, |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
159 ICoreWebView2NavigationCompletedEventArgs* args) -> HRESULT |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
160 { |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
161 LPWSTR uri; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
162 sender->get_Source(&uri); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
163 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
164 _wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE), |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
165 !wcscmp(uri, L"about:blank") ? (LPARAM)"" : (LPARAM)WideToUTF8((LPWSTR)uri)); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
166 |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
167 return S_OK; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
168 }).Get(), &token); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
169 } |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
170 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
171 // Resize WebView to fit the bounds of the parent window |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
172 WebView->DoSize(); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
173 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
174 // Handle cached load requests due to delayed |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
175 // loading of the edge webview contexts |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
176 char *url = (char *)dw_window_get_data(hWnd, _DW_HTML_DATA_LOCATION); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
177 if (url) |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
178 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
179 WebView->URL(url); |
2085
43453c9a404c
Win: Implement DW_HTML_STOP for Edge (Chromium) now that it is suppported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2065
diff
changeset
|
180 dw_window_set_data(hWnd, _DW_HTML_DATA_LOCATION, NULL); |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
181 free((void*)url); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
182 } |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
183 char *raw = (char *)dw_window_get_data(hWnd, _DW_HTML_DATA_RAW); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
184 if (raw) |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
185 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
186 WebView->Raw(raw); |
2085
43453c9a404c
Win: Implement DW_HTML_STOP for Edge (Chromium) now that it is suppported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2065
diff
changeset
|
187 dw_window_set_data(hWnd, _DW_HTML_DATA_RAW, NULL); |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
188 free((void*)raw); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
189 } |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
190 return S_OK; |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
191 }).Get()); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
192 // Success |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
193 return(0); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
194 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
195 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
196 case WM_DESTROY: |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
197 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
198 // Detach the browser object from this window, and free resources. |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
199 EdgeWebView *webview; |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
200 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
201 // Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
202 // we initially attached the browser object to this window. |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
203 webview = (EdgeWebView*)dw_window_get_data(hWnd, _DW_HTML_DATA_NAME); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
204 if (webview) |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
205 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
206 dw_window_set_data(hWnd, _DW_HTML_DATA_NAME, NULL); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
207 webview->Close(); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
208 delete webview; |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
209 } |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
210 return(TRUE); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
211 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
212 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
213 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
214 return(DefWindowProc(hWnd, uMsg, wParam, lParam)); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
215 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
216 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
217 VOID EdgeWebView::DoSize(VOID) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
218 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
219 RECT bounds; |
2044
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
220 BOOL isVisible; |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
221 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
222 GetClientRect(hWnd, &bounds); |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
223 WebHost->put_Bounds(bounds); |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
224 WebHost->get_IsVisible(&isVisible); |
2044
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
225 if(!isVisible) |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
226 WebHost->put_IsVisible(TRUE); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
227 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
228 |
2124
f9a2fc59611c
Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2123
diff
changeset
|
229 BOOL EdgeBrowser::Detect(LPWSTR AppID) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
230 { |
2127
663467f6eee4
Code cleanup: Add constants to header for dark mode, buffer sizes and Unicode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2124
diff
changeset
|
231 // Combine two buffer lengths, ".WebView2\" (10) and a NULL |
663467f6eee4
Code cleanup: Add constants to header for dark mode, buffer sizes and Unicode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2124
diff
changeset
|
232 WCHAR tempdir[MAX_PATH+_DW_APP_ID_SIZE+11] = {0}; |
2123
589896c07c91
Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2102
diff
changeset
|
233 |
589896c07c91
Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2102
diff
changeset
|
234 GetTempPathW(MAX_PATH, tempdir); |
2124
f9a2fc59611c
Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2123
diff
changeset
|
235 wcscat(tempdir, AppID); |
2127
663467f6eee4
Code cleanup: Add constants to header for dark mode, buffer sizes and Unicode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2124
diff
changeset
|
236 wcscat(tempdir, L".WebView2\\"); |
2124
f9a2fc59611c
Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2123
diff
changeset
|
237 CreateDirectoryW(tempdir, NULL); |
2123
589896c07c91
Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2102
diff
changeset
|
238 |
2154
a8b55524b1b2
Win: Fix CreateCoreWebView2EnvironmentWithOption() failure with no CoInitializeEx().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2127
diff
changeset
|
239 CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); |
a8b55524b1b2
Win: Fix CreateCoreWebView2EnvironmentWithOption() failure with no CoInitializeEx().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2127
diff
changeset
|
240 |
2123
589896c07c91
Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2102
diff
changeset
|
241 CreateCoreWebView2EnvironmentWithOptions(nullptr, tempdir, nullptr, |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
242 Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>( |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
243 [this](HRESULT result, ICoreWebView2Environment* env) -> HRESULT { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
244 // Successfully created Edge environment, return TRUE |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
245 Env = env; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
246 return S_OK; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
247 }).Get()); |
2222
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
248 // If our first attempt was unsuccessful, attempt to load Edge Stable instead |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
249 if(!Env) |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
250 { |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
251 // Combine tempdir length, "EdgeStable" (10) and a NULL |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
252 WCHAR edgepath[sizeof(tempdir)+10] = {0}; |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
253 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
254 wcscpy(edgepath, tempdir); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
255 wcscat(edgepath, L"EdgeStable"); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
256 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
257 // Create the NTFS junction to get around Microsoft's path blacklist |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
258 _DWCreateJunction(_DWGetEdgeStablePath(), edgepath); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
259 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
260 CreateCoreWebView2EnvironmentWithOptions(edgepath, tempdir, nullptr, |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
261 Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>( |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
262 [this](HRESULT result, ICoreWebView2Environment* env) -> HRESULT { |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
263 // Successfully created Edge environment, return TRUE |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
264 Env = env; |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
265 return S_OK; |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
266 }).Get()); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
267 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
268 return Env ? TRUE : FALSE; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
269 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
270 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
271 void EdgeWebView::Action(int action) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
272 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
273 // We want to get the base address (ie, a pointer) to the IWebView2WebView object embedded within the browser |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
274 // object, so we can call some of the functions in the former's table. |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
275 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
276 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
277 // Call the desired function |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
278 switch (action) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
279 { |
2044
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
280 case DW_HTML_GOBACK: |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
281 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
282 // Call the IWebView2WebView object's GoBack function. |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
283 WebView->GoBack(); |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
284 break; |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
285 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
286 |
2044
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
287 case DW_HTML_GOFORWARD: |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
288 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
289 // Call the IWebView2WebView object's GoForward function. |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
290 WebView->GoForward(); |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
291 break; |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
292 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
293 |
2044
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
294 case DW_HTML_GOHOME: |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
295 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
296 // Call the IWebView2WebView object's GoHome function. |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
297 dw_html_url(hWnd, (char*)DW_HOME_URL); |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
298 break; |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
299 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
300 |
2044
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
301 case DW_HTML_SEARCH: |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
302 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
303 // Call the IWebView2WebView object's GoSearch function. |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
304 //WebView->GoSearch(); |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
305 break; |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
306 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
307 |
2044
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
308 case DW_HTML_RELOAD: |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
309 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
310 // Call the IWebView2WebView object's Refresh function. |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
311 WebView->Reload(); |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
312 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
313 |
2044
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
314 case DW_HTML_STOP: |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
315 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
316 // Call the IWebView2WebView object's Stop function. |
2085
43453c9a404c
Win: Implement DW_HTML_STOP for Edge (Chromium) now that it is suppported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2065
diff
changeset
|
317 WebView->Stop(); |
2044
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
318 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
319 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
320 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
321 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
322 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
323 int EdgeWebView::Raw(const char* string) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
324 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
325 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
326 WebView->NavigateToString(UTF8toWide(string)); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
327 return DW_ERROR_NONE; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
328 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
329 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
330 int EdgeWebView::URL(const char* url) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
331 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
332 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
333 WebView->Navigate(UTF8toWide(url)); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
334 return DW_ERROR_NONE; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
335 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
336 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
337 int EdgeWebView::JavascriptRun(const char* script, void* scriptdata) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
338 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
339 HWND thishwnd = hWnd; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
340 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
341 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
342 WebView->ExecuteScript(UTF8toWide(script), |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
343 Callback<ICoreWebView2ExecuteScriptCompletedHandler>( |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
344 [thishwnd, scriptdata](HRESULT error, PCWSTR result) -> HRESULT |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
345 { |
2052
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
346 char *scriptresult; |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
347 |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
348 /* Result is unquoted "null" when we should return NULL */ |
2045
cb195d76de8e
Win: Make HTML_RESULT event match other platforms and disable dev tools when not DEBUG.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2044
diff
changeset
|
349 if (result && _wcsicmp(result, L"null") == 0) |
2052
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
350 scriptresult = NULL; |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
351 else |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
352 scriptresult = result ? WideToUTF8((LPWSTR)result) : NULL; |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
353 |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
354 /* String results are enclosed in quotations, remove the quotes */ |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
355 if(scriptresult && *scriptresult == '\"') |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
356 { |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
357 char *end = strrchr(scriptresult, '\"'); |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
358 if(end) |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
359 *end = '\0'; |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
360 scriptresult++; |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
361 } |
cfa0a9554118
Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2045
diff
changeset
|
362 void *params[2] = { (void *)scriptresult, DW_INT_TO_POINTER((error == S_OK ? DW_ERROR_NONE : DW_ERROR_UNKNOWN)) }; |
2045
cb195d76de8e
Win: Make HTML_RESULT event match other platforms and disable dev tools when not DEBUG.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2044
diff
changeset
|
363 _wndproc(thishwnd, WM_USER + 100, (WPARAM)params, (LPARAM)scriptdata); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
364 return S_OK; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
365 }).Get()); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
366 return DW_ERROR_NONE; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
367 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
368 |
2065
2dacac5e4023
Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2060
diff
changeset
|
369 VOID EdgeWebView::Setup(HWND hwnd, ICoreWebView2Controller* host) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
370 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
371 hWnd = hwnd; |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
372 WebHost = host; |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
373 host->get_CoreWebView2(&WebView); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
374 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
375 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
376 VOID EdgeWebView::Close(VOID) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
377 { |
2060
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
378 if (WebHost) |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
379 WebHost->Close(); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
380 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
381 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
382 EdgeBrowser *DW_EDGE = NULL; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
383 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
384 extern "C" { |
2222
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
385 // Create a junction to Edge Stable current version so we can load it... |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
386 // For now we are using CreateProcess() to execute the mklink command... |
2223
a81b9031412e
Win: Change to using EdgeUpdate registry key instead of BLBeacon.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2222
diff
changeset
|
387 // May switch to using C code but that seems to be overly complicated |
2222
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
388 void _DWCreateJunction(LPWSTR source, LPWSTR target) |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
389 { |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
390 // Command line must be at least 2 MAX_PATHs and "cmd /c mklink /J "<path1>" "<path2>"" (22) and a NULL |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
391 WCHAR cmdLine[(MAX_PATH*2)+23] = L"cmd /c mklink /J \""; |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
392 STARTUPINFO si = {sizeof(si)}; |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
393 PROCESS_INFORMATION pi = {0}; |
2223
a81b9031412e
Win: Change to using EdgeUpdate registry key instead of BLBeacon.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2222
diff
changeset
|
394 |
a81b9031412e
Win: Change to using EdgeUpdate registry key instead of BLBeacon.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2222
diff
changeset
|
395 // Safety check |
a81b9031412e
Win: Change to using EdgeUpdate registry key instead of BLBeacon.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2222
diff
changeset
|
396 if(!source[0] || !target[0]) |
a81b9031412e
Win: Change to using EdgeUpdate registry key instead of BLBeacon.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2222
diff
changeset
|
397 return; |
2222
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
398 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
399 // Combine the command line components |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
400 wcscat(cmdLine, target); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
401 wcscat(cmdLine, L"\" \""); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
402 wcscat(cmdLine, source); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
403 wcscat(cmdLine, L"\""); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
404 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
405 // First remove any existing junction to an old version |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
406 RemoveDirectoryW(target); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
407 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
408 // Create the junction to the new version |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
409 if(!CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
410 return; |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
411 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
412 // Wait until child process exits. |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
413 WaitForSingleObject(pi.hProcess, INFINITE); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
414 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
415 // Close process and thread handles. |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
416 CloseHandle(pi.hProcess); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
417 CloseHandle(pi.hThread); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
418 } |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
419 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
420 // Return the path the the current Edge Stable version |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
421 LPWSTR _DWGetEdgeStablePath(void) |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
422 { |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
423 HKEY hKey; |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
424 WCHAR szBuffer[100] = {0}; |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
425 DWORD dwBufferSize = sizeof(szBuffer); |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
426 static WCHAR EdgeStablePath[MAX_PATH+1] = {0}; |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
427 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
428 /* If we haven't successfully gotten the path, try to find it in the registry */ |
2224
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
429 if(!EdgeStablePath[0]) |
2222
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
430 { |
2224
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
431 // Handle the case we are running on x64 |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
432 if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\WOW6432Node\\Microsoft\\EdgeUpdate\\Clients\\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}", 0, KEY_READ, &hKey) == ERROR_SUCCESS && |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
433 RegQueryValueExW(hKey, L"pv", 0, NULL, (LPBYTE)szBuffer, &dwBufferSize) == ERROR_SUCCESS) |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
434 { |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
435 wcscpy(EdgeStablePath, L"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\"); |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
436 wcscat(EdgeStablePath, szBuffer); |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
437 } |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
438 // and also the case we are running x86 |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
439 else if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\EdgeUpdate\\Clients\\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}", 0, KEY_READ, &hKey) == ERROR_SUCCESS && |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
440 RegQueryValueExW(hKey, L"pv", 0, NULL, (LPBYTE)szBuffer, &dwBufferSize) == ERROR_SUCCESS) |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
441 { |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
442 wcscpy(EdgeStablePath, L"C:\\Program Files\\Microsoft\\Edge\\Application\\"); |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
443 wcscat(EdgeStablePath, szBuffer); |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
444 } |
2222
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
445 } |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
446 return EdgeStablePath; |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
447 } |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
448 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
449 /******************************* dw_edge_detect() ************************** |
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
450 * Attempts to create a temporary Edge (Chromium) browser context... |
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
451 * If we succeed return TRUE and use Edge for HTML windows. |
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
452 * If it fails return FALSE and fall back to using embedded IE. |
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
453 */ |
2124
f9a2fc59611c
Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2123
diff
changeset
|
454 BOOL _dw_edge_detect(LPWSTR AppID) |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
455 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
456 DW_EDGE = new EdgeBrowser; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
457 if (DW_EDGE) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
458 { |
2124
f9a2fc59611c
Win: That last fix wasn't tested enough. Create a subfolder with the AppID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2123
diff
changeset
|
459 BOOL result = DW_EDGE->Detect(AppID); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
460 if (!result) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
461 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
462 delete DW_EDGE; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
463 DW_EDGE = NULL; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
464 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
465 return result; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
466 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
467 return FALSE; |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
468 } |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
469 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
470 /******************************* dw_edge_action() ************************** |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
471 * Implements the functionality of a "Back". "Forward", "Home", "Search", |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
472 * "Refresh", or "Stop" button. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
473 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
474 * hwnd = Handle to the window hosting the browser object. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
475 * action = One of the following: |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
476 * 0 = Move back to the previously viewed web page. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
477 * 1 = Move forward to the previously viewed web page. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
478 * 2 = Move to the home page. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
479 * 3 = Search. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
480 * 4 = Refresh the page. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
481 * 5 = Stop the currently loading page. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
482 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
483 |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
484 void _dw_edge_action(HWND hwnd, int action) |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
485 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
486 EdgeWebView* webview = (EdgeWebView *)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME); |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
487 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
488 webview->Action(action); |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
489 } |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
490 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
491 /******************************* dw_edge_raw() **************************** |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
492 * Takes a string containing some HTML BODY, and displays it in the specified |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
493 * window. For example, perhaps you want to display the HTML text of... |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
494 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
495 * <P>This is a picture.<P><IMG src="mypic.jpg"> |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
496 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
497 * hwnd = Handle to the window hosting the browser object. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
498 * string = Pointer to nul-terminated string containing the HTML BODY. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
499 * (NOTE: No <BODY></BODY> tags are required in the string). |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
500 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
501 * RETURNS: 0 if success, or non-zero if an error. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
502 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
503 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
504 int _dw_edge_raw(HWND hwnd, const char* string) |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
505 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
506 EdgeWebView* webview = (EdgeWebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME); |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
507 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
508 return webview->Raw(string); |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
509 else |
2164
05dd5189099f
Win: Fix some warnings reported with -W3 in Visual C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2154
diff
changeset
|
510 dw_window_set_data(hwnd, _DW_HTML_DATA_RAW, _strdup(string)); |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
511 return DW_ERROR_NONE; |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
512 } |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
513 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
514 /******************************* dw_edge_url() **************************** |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
515 * Displays a URL, or HTML file on disk. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
516 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
517 * hwnd = Handle to the window hosting the browser object. |
2015
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
518 * url = Pointer to nul-terminated name of the URL/file. |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
519 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
520 * RETURNS: 0 if success, or non-zero if an error. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
521 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
522 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
523 int _dw_edge_url(HWND hwnd, const char* url) |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
524 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
525 EdgeWebView* webview = (EdgeWebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME); |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
526 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
527 return webview->URL(url); |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
528 else |
2164
05dd5189099f
Win: Fix some warnings reported with -W3 in Visual C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2154
diff
changeset
|
529 dw_window_set_data(hwnd, _DW_HTML_DATA_LOCATION, _strdup(url)); |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
530 return DW_ERROR_NONE; |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
531 } |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
532 |
2015
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
533 /******************************* dw_edge_javascript_run() **************************** |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
534 * Runs a javascript in the specified browser context. |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
535 * |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
536 * hwnd = Handle to the window hosting the browser object. |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
537 * script = Pointer to nul-terminated javascript string. |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
538 * scriptdata = Pointer to user data to be passed to the callback. |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
539 * |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
540 * RETURNS: 0 if success, or non-zero if an error. |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
541 */ |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
542 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
543 int _dw_edge_javascript_run(HWND hwnd, const char* script, void* scriptdata) |
2015
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
544 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
545 EdgeWebView* webview = (EdgeWebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME); |
2015
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
546 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
547 return webview->JavascriptRun(script, scriptdata); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
548 return DW_ERROR_UNKNOWN; |
2015
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
549 } |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
550 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
551 /************************** edgeWindowProc() ************************* |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
552 * Our message handler for our window to host the browser. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
553 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
554 |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
555 LRESULT CALLBACK _edgeWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
556 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
557 if (DW_EDGE) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
558 return DW_EDGE->WndProc(hWnd, uMsg, wParam, lParam); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
559 return DefWindowProc(hWnd, uMsg, wParam, lParam); |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
560 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
561 } |