diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml
index 83b747a..2f4ba1e 100644
--- a/.idea/libraries/Dart_SDK.xml
+++ b/.idea/libraries/Dart_SDK.xml
@@ -1,17 +1,25 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml
new file mode 100644
index 0000000..53449da
--- /dev/null
+++ b/.idea/libraries/Flutter_Plugins.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index a6a1075..d322796 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,45 +1,73 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+ 1704357562807
+
+
+ 1704357562807
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/example/lib/main.dart b/example/lib/main.dart
index d0d491b..e2e87cb 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -50,6 +50,11 @@ class _ExampleBrowser extends State {
try {
await _controller.initialize();
_subscriptions.add(_controller.url.listen((url) {
+ print('url change -- $url');
+ _textController.text = url;
+ }));
+ _subscriptions.add(_controller.newRequestUrl.listen((url) {
+ print('newRequestUrl -- $url');
_textController.text = url;
}));
diff --git a/example/windows/flutter/generated_plugins.cmake b/example/windows/flutter/generated_plugins.cmake
new file mode 100644
index 0000000..c0c4e87
--- /dev/null
+++ b/example/windows/flutter/generated_plugins.cmake
@@ -0,0 +1,26 @@
+#
+# Generated file, do not edit.
+#
+
+list(APPEND FLUTTER_PLUGIN_LIST
+ screen_retriever
+ webview_windows
+ window_manager
+)
+
+list(APPEND FLUTTER_FFI_PLUGIN_LIST
+)
+
+set(PLUGIN_BUNDLED_LIBRARIES)
+
+foreach(plugin ${FLUTTER_PLUGIN_LIST})
+ add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
+ target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
+ list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
+ list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
+endforeach(plugin)
+
+foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
+ add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
+ list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
+endforeach(ffi_plugin)
diff --git a/lib/src/webview.dart b/lib/src/webview.dart
index 32d0770..fd7b60f 100644
--- a/lib/src/webview.dart
+++ b/lib/src/webview.dart
@@ -106,8 +106,13 @@ class WebviewController extends ValueNotifier {
final StreamController _urlStreamController =
StreamController();
+ final StreamController _newWindowRequestedStreamController =
+ StreamController();
+
+
/// A stream reflecting the current URL.
Stream get url => _urlStreamController.stream;
+ Stream get newRequestUrl => _newWindowRequestedStreamController.stream;
final StreamController _loadingStateStreamController =
StreamController.broadcast();
@@ -172,15 +177,23 @@ class WebviewController extends ValueNotifier {
await _pluginChannel.invokeMapMethod('initialize');
_textureId = reply!['textureId'];
+
+ print('_textureId -- $_textureId');
_methodChannel = MethodChannel('$_pluginChannelPrefix/$_textureId');
_eventChannel = EventChannel('$_pluginChannelPrefix/$_textureId/events');
_eventStreamSubscription =
_eventChannel.receiveBroadcastStream().listen((event) {
final map = event as Map;
+
+ print('event type -- $map');
switch (map['type']) {
case 'urlChanged':
_urlStreamController.add(map['value']);
break;
+
+ case 'newTabUrl':
+ _newWindowRequestedStreamController.add(map['value']);
+ break;
case 'onLoadError':
final value = WebErrorStatus.values[map['value']];
_onLoadErrorStreamController.add(value);
@@ -203,6 +216,9 @@ class WebviewController extends ValueNotifier {
case 'cursorChanged':
_cursorStreamController.add(getCursorByName(map['value']));
break;
+ case 'click':
+ _urlStreamController.add(map['value']);
+ break;
case 'webMessageReceived':
try {
final message = json.decode(map['value']);
diff --git a/pubspec.yaml b/pubspec.yaml
index 9abbb0f..1502a95 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -12,6 +12,7 @@ dependencies:
flutter:
sdk: flutter
+
dev_dependencies:
flutter_test:
sdk: flutter
diff --git a/webview_windows.iml b/webview_windows.iml
index 0fbe6fd..49b44c6 100644
--- a/webview_windows.iml
+++ b/webview_windows.iml
@@ -8,11 +8,11 @@
-
+
+
-
diff --git a/windows/.idea/.gitignore b/windows/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/windows/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/windows/.idea/misc.xml b/windows/.idea/misc.xml
new file mode 100644
index 0000000..639900d
--- /dev/null
+++ b/windows/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/windows/.idea/modules.xml b/windows/.idea/modules.xml
new file mode 100644
index 0000000..efa1d66
--- /dev/null
+++ b/windows/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/windows/.idea/vcs.xml b/windows/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/windows/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/windows/.idea/windows.iml b/windows/.idea/windows.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/windows/.idea/windows.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/windows/webview.cc b/windows/webview.cc
index 0de207a..33c77ef 100644
--- a/windows/webview.cc
+++ b/windows/webview.cc
@@ -1,9 +1,11 @@
#include "webview.h"
-
+#include
#include
+#include
+#include
+
#include
-#include
#include "util/composition.desktop.interop.h"
#include "util/string_converter.h"
@@ -354,11 +356,23 @@ void Webview::RegisterEventHandlers() {
break;
}
+ // Extract relevant information
+ // Open the URI in the default browser.
+ // Extract relevant information
+ LPWSTR wurl;
+ args->get_Uri(&wurl);
+ std::cout << "The value of myVariable is result: " << std::endl;
+
+ std::string url = util::Utf8FromUtf16(wurl);
+ url_new_tab_callback_(url);
+
return S_OK;
})
.Get(),
&event_registrations_.new_windows_requested_token_);
+
+// url_new_tab_callback_(args);
webview_->add_ContainsFullScreenElementChanged(
Callback(
[this](ICoreWebView2* sender, IUnknown* args) -> HRESULT {
diff --git a/windows/webview.h b/windows/webview.h
index 567e742..beca3df 100644
--- a/windows/webview.h
+++ b/windows/webview.h
@@ -94,6 +94,7 @@ class Webview {
friend class WebviewHost;
typedef std::function UrlChangedCallback;
+ typedef std::function UrlNewTabCallback;
typedef std::function LoadingStateChangedCallback;
typedef std::function
OnLoadErrorCallback;
@@ -164,6 +165,10 @@ class Webview {
url_changed_callback_ = std::move(callback);
}
+ void OnUrlNewTab(UrlNewTabCallback callback) {
+ url_new_tab_callback_ = std::move(callback);
+ }
+
void OnLoadError(OnLoadErrorCallback callback) {
on_load_error_callback_ = std::move(callback);
}
@@ -233,6 +238,7 @@ class Webview {
EventRegistrations event_registrations_{};
UrlChangedCallback url_changed_callback_;
+ UrlNewTabCallback url_new_tab_callback_;
LoadingStateChangedCallback loading_state_changed_callback_;
OnLoadErrorCallback on_load_error_callback_;
HistoryChangedCallback history_changed_callback_;
diff --git a/windows/webview_bridge.cc b/windows/webview_bridge.cc
index f417f9a..dfd3afe 100644
--- a/windows/webview_bridge.cc
+++ b/windows/webview_bridge.cc
@@ -224,6 +224,15 @@ void WebviewBridge::RegisterEventHandlers() {
EmitEvent(event);
});
+ webview_->OnUrlNewTab([this](const std::string& url) {
+ const auto event = flutter::EncodableValue(flutter::EncodableMap{
+ {flutter::EncodableValue(kEventType),
+ flutter::EncodableValue("newTabUrl")},
+ {flutter::EncodableValue(kEventValue), flutter::EncodableValue(url)},
+ });
+ EmitEvent(event);
+ });
+
webview_->OnLoadError([this](COREWEBVIEW2_WEB_ERROR_STATUS web_status) {
const auto event = flutter::EncodableValue(flutter::EncodableMap{
{flutter::EncodableValue(kEventType),