Mercurial > dwindows
annotate win/edge.cpp @ 3005:522ef24b0aba default tip
GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
Migrate to GtkAlertDialog for 4.10 from GtkMessageDialog.
Still need to center the dialog or something.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 20 Dec 2023 05:17:54 +0000 |
parents | 0058ab32e1bd |
children |
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> |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
12 #include <string> |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
13 |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
14 using namespace Microsoft::WRL; |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
15 |
2034
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_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
|
17 #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
|
18 #define _DW_HTML_DATA_RAW "_dw_edge_raw" |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
19 #define _DW_HTML_DATA_ADD "_dw_edge_add" |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
20 |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
21 extern "C" { |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
22 |
2018
663d79f28e46
Win: Fix dw_html_javascript_run() when using embedded IE browser widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2015
diff
changeset
|
23 /* Import the character conversion functions from dw.c */ |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
24 LPWSTR _dw_UTF8toWide(const char* utf8string, void* outbuf); |
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
25 char* _dw_WideToUTF8(LPCWSTR widestring, void* outbuf); |
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
26 #define UTF8toWide(a) _dw_UTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) |
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
27 #define WideToUTF8(a) _dw_WideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL) |
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
28 LRESULT CALLBACK _dw_wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2); |
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
29 void _dw_create_junction(LPWSTR source, LPWSTR target); |
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
30 LPWSTR _dw_get_edge_stable_path(void); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
31 } |
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 class EdgeBrowser |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
34 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
35 public: |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 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
|
40 }; |
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 class EdgeWebView |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
43 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
44 public: |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
45 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
|
46 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
|
47 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
|
48 int JavascriptRun(const char* script, void* scriptdata); |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
49 int JavascriptAdd(const char* name); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
50 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
|
51 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
|
52 VOID Close(VOID); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
53 protected: |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
54 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
|
55 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
|
56 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
|
57 }; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
58 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
59 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
|
60 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
61 switch (uMsg) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
62 { |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
63 case WM_SIZE: |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
64 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
65 // 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
|
66 EdgeWebView *webview; |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
67 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
68 // 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
|
69 // 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
|
70 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
|
71 // 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
|
72 if (webview) |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
73 webview->DoSize(); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
74 return(0); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
75 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
76 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
77 case WM_PAINT: |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
78 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
79 PAINTSTRUCT ps; |
2955
f99414164f5b
Win: Enable vsnprintf() usage with Visual C for extra safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2625
diff
changeset
|
80 BeginPaint(hWnd, &ps); |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
81 EndPaint(hWnd, &ps); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
82 return(0); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
83 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
84 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
85 case WM_CREATE: |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
86 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
87 // 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
|
88 // 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
|
89 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
|
90 [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
|
91 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
|
92 ICoreWebView2* 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 WebView->Setup(hWnd, webhost); |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
95 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
|
96 |
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
|
97 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
|
98 // 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
|
99 // 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 #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
|
106 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
|
107 #endif |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
108 |
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
|
109 // 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
|
110 // 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
|
111 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
|
112 |
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 // 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
|
114 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
|
115 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
|
116 [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
|
117 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
|
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 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
|
120 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
|
121 |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
122 _dw_wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_STARTED), |
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
|
123 !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
|
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 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
|
126 }).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
|
127 |
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 // 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
|
129 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
|
130 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
|
131 [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
|
132 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
|
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 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
|
135 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
|
136 |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
137 _dw_wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_REDIRECT), |
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
|
138 !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
|
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 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
|
141 }).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
|
142 |
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 // 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
|
144 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
|
145 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
|
146 [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
|
147 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
|
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 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
|
150 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
|
151 |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
152 _dw_wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_LOADING), |
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
|
153 !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
|
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 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
|
156 }).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
|
157 |
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 // 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
|
159 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
|
160 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
|
161 [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
|
162 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
|
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 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
|
165 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
|
166 |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
167 _dw_wndproc(hWnd, WM_USER + 101, (WPARAM)DW_INT_TO_POINTER(DW_HTML_CHANGE_COMPLETE), |
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
|
168 !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
|
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 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
|
171 }).Get(), &token); |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
172 |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
173 // Register a handler for the WebMessageReceived event. |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
174 webview->add_WebMessageReceived( |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
175 Callback<ICoreWebView2WebMessageReceivedEventHandler>( |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
176 [hWnd](ICoreWebView2* sender, |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
177 ICoreWebView2WebMessageReceivedEventArgs* args) -> HRESULT |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
178 { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
179 LPWSTR message, name = NULL, body = NULL; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
180 args->TryGetWebMessageAsString(&message); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
181 |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
182 // Locate the DWindows|<function name>| signature and body |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
183 if(message && !wcsncmp(message, L"DWindows|", 9)) { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
184 name = message + 9; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
185 if(*name) { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
186 body = wcschr(name, L'|'); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
187 if(body) { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
188 *body = 0; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
189 body++; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
190 } |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
191 } |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
192 } |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
193 if(name && body) |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
194 _dw_wndproc(hWnd, WM_USER + 103, (WPARAM)WideToUTF8(name), (LPARAM)WideToUTF8(body)); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
195 |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
196 return S_OK; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
197 }).Get(), &token); |
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
|
198 } |
21bc72ff40cb
Win: Update Edge (Chromium) support for the 0.9.430 WebView2 SDK release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2052
diff
changeset
|
199 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
200 // 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
|
201 WebView->DoSize(); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
202 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
203 // 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
|
204 // 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
|
205 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
|
206 if (url) |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
207 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
208 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
|
209 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
|
210 free((void*)url); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
211 } |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
212 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
|
213 if (raw) |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
214 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
215 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
|
216 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
|
217 free((void*)raw); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
218 } |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
219 char *adds = (char *)dw_window_get_data(hWnd, _DW_HTML_DATA_ADD); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
220 if(adds) |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
221 { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
222 char *start = adds, *separator; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
223 |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
224 while((separator = strchr(start, '|'))) |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
225 { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
226 *separator = 0; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
227 WebView->JavascriptAdd(start); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
228 start = separator + 1; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
229 } |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
230 WebView->JavascriptAdd(start); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
231 dw_window_set_data(hWnd, _DW_HTML_DATA_ADD, NULL); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
232 free((void *)adds); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
233 } |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
234 return S_OK; |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
235 }).Get()); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
236 // Success |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
237 return(0); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
238 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
239 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
240 case WM_DESTROY: |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
241 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
242 // 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
|
243 EdgeWebView *webview; |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
244 |
2043
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
245 // 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
|
246 // 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
|
247 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
|
248 if (webview) |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
249 { |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
250 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
|
251 webview->Close(); |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
252 delete webview; |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
253 } |
82e5c998df2e
Win: Fix crash on Edge HTML widget destruction.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2042
diff
changeset
|
254 return(TRUE); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
255 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
256 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
257 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
258 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
|
259 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
260 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
261 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
|
262 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
263 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
|
264 BOOL isVisible; |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
265 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
272 |
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
|
273 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
|
274 { |
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
|
275 // 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
|
276 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
|
277 |
589896c07c91
Win: Use GetTempPathW() to get a location for the embedded Edge (Chromium) data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2102
diff
changeset
|
278 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
|
279 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
|
280 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
|
281 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
|
282 |
2154
a8b55524b1b2
Win: Fix CreateCoreWebView2EnvironmentWithOption() failure with no CoInitializeEx().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2127
diff
changeset
|
283 CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); |
a8b55524b1b2
Win: Fix CreateCoreWebView2EnvironmentWithOption() failure with no CoInitializeEx().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2127
diff
changeset
|
284 |
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
|
285 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
|
286 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
|
287 [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
|
288 // 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
|
289 Env = env; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
290 return S_OK; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
291 }).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
|
292 // 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
|
293 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
|
294 { |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
295 // 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
|
296 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
|
297 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
298 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
|
299 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
|
300 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
301 // Create the NTFS junction to get around Microsoft's path blacklist |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
302 _dw_create_junction(_dw_get_edge_stable_path(), edgepath); |
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
|
303 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
304 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
|
305 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
|
306 [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
|
307 // 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
|
308 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
|
309 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
|
310 }).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
|
311 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
312 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
|
313 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
314 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
315 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
|
316 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
317 // 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
|
318 // 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
|
319 if (WebView) |
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 // 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
|
322 switch (action) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
323 { |
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
|
324 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
|
325 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
326 // 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
|
327 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
|
328 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
|
329 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
330 |
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
|
331 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
|
332 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
333 // 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
|
334 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
|
335 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
|
336 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
337 |
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
|
338 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
|
339 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
340 // 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
|
341 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
|
342 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
|
343 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
344 |
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
|
345 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
|
346 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
347 // 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
|
348 //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
|
349 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
|
350 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
351 |
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
|
352 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
|
353 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
354 // 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
|
355 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
|
356 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
357 |
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
|
358 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
|
359 { |
b74b9afa31aa
Win: Fix Edge/Chromium HTML widgets in notebook/tabbed widgets not being visible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2043
diff
changeset
|
360 // 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
|
361 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
|
362 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
363 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
364 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
365 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
366 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
367 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
|
368 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
369 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
370 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
|
371 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
|
372 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
373 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
374 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
|
375 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
376 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
377 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
|
378 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
|
379 } |
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 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
|
382 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
383 HWND thishwnd = hWnd; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
384 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
385 if (WebView) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
386 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
|
387 Callback<ICoreWebView2ExecuteScriptCompletedHandler>( |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
388 [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
|
389 { |
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
|
390 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
|
391 |
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
|
392 /* 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
|
393 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
|
394 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
|
395 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
|
396 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
|
397 |
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
|
398 /* 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
|
399 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
|
400 { |
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
|
401 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
|
402 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
|
403 *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
|
404 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
|
405 } |
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
|
406 void *params[2] = { (void *)scriptresult, DW_INT_TO_POINTER((error == S_OK ? DW_ERROR_NONE : DW_ERROR_UNKNOWN)) }; |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
407 _dw_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
|
408 return S_OK; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
409 }).Get()); |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
410 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
|
411 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
412 |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
413 int EdgeWebView::JavascriptAdd(const char* name) |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
414 { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
415 if (WebView) { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
416 std::wstring wname = std::wstring(UTF8toWide(name)); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
417 std::wstring script = L"function " + wname + L"(body) {window.chrome.webview.postMessage('DWindows|" + wname + L"|' + body);}"; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
418 WebView->AddScriptToExecuteOnDocumentCreated(script.c_str(), |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
419 Callback<ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler>( |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
420 [this](HRESULT error, PCWSTR id) -> HRESULT { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
421 return S_OK; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
422 }).Get()); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
423 return DW_ERROR_NONE; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
424 } |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
425 return DW_ERROR_UNKNOWN; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
426 } |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
427 |
2065
2dacac5e4023
Win: Updated Edge (Chromium) support for WebView2 SDK 0.9.488.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2060
diff
changeset
|
428 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
|
429 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
430 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
|
431 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
|
432 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
|
433 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
434 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
435 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
|
436 { |
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
|
437 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
|
438 WebHost->Close(); |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
439 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
440 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
441 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
|
442 |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
443 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
|
444 // 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
|
445 // 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
|
446 // May switch to using C code but that seems to be overly complicated |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
447 void _dw_create_junction(LPWSTR source, LPWSTR target) |
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
|
448 { |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
449 // 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
|
450 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
|
451 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
|
452 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
|
453 |
a81b9031412e
Win: Change to using EdgeUpdate registry key instead of BLBeacon.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2222
diff
changeset
|
454 // Safety check |
a81b9031412e
Win: Change to using EdgeUpdate registry key instead of BLBeacon.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2222
diff
changeset
|
455 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
|
456 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
|
457 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
458 // 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
|
459 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
|
460 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
|
461 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
|
462 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
|
463 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
464 // 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
|
465 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
|
466 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
467 // 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
|
468 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
|
469 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
|
470 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
471 // 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
|
472 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
|
473 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
474 // 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
|
475 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
|
476 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
|
477 } |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
478 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
479 // Return the path the the current Edge Stable version |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
480 LPWSTR _dw_get_edge_stable_path(void) |
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
|
481 { |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
482 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
|
483 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
|
484 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
|
485 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
|
486 |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
487 /* 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
|
488 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
|
489 { |
2224
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
490 // 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
|
491 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
|
492 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
|
493 { |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
494 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
|
495 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
|
496 } |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
497 // 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
|
498 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
|
499 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
|
500 { |
d3974aa8ad64
Win: Add a second registry check for when running on x86.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2223
diff
changeset
|
501 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
|
502 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
|
503 } |
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
|
504 } |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
505 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
|
506 } |
f1241b668611
Win: Create an NTFS junction to Edge Stable to avoid WebView2 path blacklist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2167
diff
changeset
|
507 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
508 /******************************* 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
|
509 * 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
|
510 * 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
|
511 * 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
|
512 */ |
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
|
513 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
|
514 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
515 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
|
516 if (DW_EDGE) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
517 { |
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
|
518 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
|
519 if (!result) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
520 { |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
521 delete DW_EDGE; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
522 DW_EDGE = NULL; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
523 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
524 return result; |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
525 } |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
526 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
|
527 } |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
528 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
529 /******************************* 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
|
530 * 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
|
531 * "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
|
532 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
533 * 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
|
534 * 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
|
535 * 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
|
536 * 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
|
537 * 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
|
538 * 3 = Search. |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
539 * 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
|
540 * 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
|
541 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
542 |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
543 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
|
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); |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
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 webview->Action(action); |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
548 } |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
549 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
550 /******************************* 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
|
551 * 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
|
552 * 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
|
553 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
554 * <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
|
555 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
556 * 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
|
557 * 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
|
558 * (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
|
559 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
560 * 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
|
561 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
562 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
563 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
|
564 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
565 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
|
566 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
567 return webview->Raw(string); |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
568 else { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
569 char *oldstring = (char *)dw_window_get_data(hwnd, _DW_HTML_DATA_RAW); |
2164
05dd5189099f
Win: Fix some warnings reported with -W3 in Visual C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2154
diff
changeset
|
570 dw_window_set_data(hwnd, _DW_HTML_DATA_RAW, _strdup(string)); |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
571 if(oldstring) |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
572 free((void *)oldstring); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
573 } |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
574 return DW_ERROR_NONE; |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
575 } |
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
576 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
577 /******************************* 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
|
578 * 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
|
579 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
580 * 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
|
581 * 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
|
582 * |
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
583 * 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
|
584 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
585 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
586 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
|
587 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
588 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
|
589 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
590 return webview->URL(url); |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
591 else { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
592 char *oldurl = (char *)dw_window_get_data(hwnd, _DW_HTML_DATA_LOCATION); |
2164
05dd5189099f
Win: Fix some warnings reported with -W3 in Visual C.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2154
diff
changeset
|
593 dw_window_set_data(hwnd, _DW_HTML_DATA_LOCATION, _strdup(url)); |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
594 if(oldurl) |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
595 free((void *)oldurl); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
596 } |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
597 return DW_ERROR_NONE; |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
598 } |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
599 |
2015
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
600 /******************************* 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
|
601 * 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
|
602 * |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
603 * 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
|
604 * 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
|
605 * 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
|
606 * |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
607 * 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
|
608 */ |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
609 |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
610 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
|
611 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
612 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
|
613 if (webview) |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
614 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
|
615 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
|
616 } |
c30f4354966e
Win: Added support for dw_html_javascript_run() using Edge (Chromium).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2001
diff
changeset
|
617 |
2981
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
618 /******************************* dw_edge_javascript_add() **************************** |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
619 * Adds a javascript function in the specified browser context. |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
620 * |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
621 * hwnd = Handle to the window hosting the browser object. |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
622 * name = Pointer to nul-terminated javascript function name string. |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
623 * |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
624 * RETURNS: 0 if success, or non-zero if an error. |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
625 */ |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
626 |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
627 int _dw_edge_javascript_add(HWND hwnd, const char* name) |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
628 { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
629 if(name) { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
630 EdgeWebView* webview = (EdgeWebView*)dw_window_get_data(hwnd, _DW_HTML_DATA_NAME); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
631 if (webview) |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
632 return webview->JavascriptAdd(name); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
633 else { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
634 char *oldadd = (char *)dw_window_get_data(hwnd, _DW_HTML_DATA_ADD); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
635 char *newadd = (char *)calloc(strlen(name) + (oldadd ? strlen(oldadd) : 0) + 2, 1); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
636 if(oldadd) { |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
637 strcpy(newadd, oldadd); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
638 strcat(newadd, "|"); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
639 } |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
640 strcat(newadd, name); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
641 dw_window_set_data(hwnd, _DW_HTML_DATA_ADD, newadd); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
642 if(oldadd) |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
643 free((void *)oldadd); |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
644 return DW_ERROR_NONE; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
645 } |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
646 } |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
647 return DW_ERROR_UNKNOWN; |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
648 } |
0058ab32e1bd
Win: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2955
diff
changeset
|
649 |
2001
f7acca46f795
Win: Fixes for Edge (Chromium) embedding, the loading can be delayed so...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2000
diff
changeset
|
650 /************************** edgeWindowProc() ************************* |
2000
77e43d71eaa7
Changes to allow mixing C and C++ when including dw.h.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
1999
diff
changeset
|
651 * 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
|
652 */ |
1999
4e808c4cadfb
Win: Add initial support for Microsoft Edge (Chromium) embedding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
653 |
2625
2e804b4db81e
Win: Standardize internal function name style...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2224
diff
changeset
|
654 LRESULT CALLBACK _dw_edgewndproc(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
|
655 { |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
656 if (DW_EDGE) |
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
657 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
|
658 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
|
659 } |
2042
0d8b898b03e2
Win: Rewrite edge.cpp using C++ classes, EdgeBrowser and EdgeWebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2041
diff
changeset
|
660 } |