diff --git a/common/webview_handler.cc b/common/webview_handler.cc index 71bc682..9cfe8ec 100644 --- a/common/webview_handler.cc +++ b/common/webview_handler.cc @@ -167,6 +167,7 @@ void WebviewHandler::OnBeforeClose(CefRefPtr browser) { bool WebviewHandler::OnBeforePopup(CefRefPtr browser, CefRefPtr frame, + int popup_id, const CefString& target_url, const CefString& target_frame_name, WindowOpenDisposition target_disposition, diff --git a/common/webview_handler.h b/common/webview_handler.h index 7c3c95e..501f251 100644 --- a/common/webview_handler.h +++ b/common/webview_handler.h @@ -98,6 +98,7 @@ public CefRenderHandler{ virtual void OnBeforeClose(CefRefPtr browser) override; virtual bool OnBeforePopup(CefRefPtr browser, CefRefPtr frame, + int popup_id, const CefString& target_url, const CefString& target_frame_name, WindowOpenDisposition target_disposition, diff --git a/lib/src/webview_manager.dart b/lib/src/webview_manager.dart index f9ee6fa..ebfe8c0 100644 --- a/lib/src/webview_manager.dart +++ b/lib/src/webview_manager.dart @@ -34,7 +34,7 @@ class WebviewManager extends ValueNotifier { final controller = WebViewController(pluginChannel, browserIndex, loading: loading); _tempWebViews[browserIndex] = controller; - _tempInjectUserScripts[browserIndex] = injectUserScripts; + _tempInjectUserScripts[browserIndex] = injectUserScripts ?? InjectUserScripts(); return controller; } diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index 1af6a67..c3de92b 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -26,6 +26,9 @@ set(CEF_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../third/cef") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake") find_package(CEF REQUIRED) +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED gtk+-3.0) + # This value is used when generating builds using this plugin, so it must # not be changed. set(PLUGIN_NAME "webview_cef_plugin") @@ -69,7 +72,7 @@ target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter) -target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK) +target_link_libraries(${PLUGIN_NAME} PRIVATE ${GTK_LIBRARIES}) target_include_directories(${PLUGIN_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../common") diff --git a/linux/target_modifier/modify_target.sh b/linux/target_modifier/modify_target.sh index f42bde7..670aee5 100755 --- a/linux/target_modifier/modify_target.sh +++ b/linux/target_modifier/modify_target.sh @@ -8,9 +8,9 @@ scriptdir=$(cd $(dirname $0); pwd -P) echo "Modifying target cc files..." -bash $scriptdir/tools/import_webview_cef_header_my_application.sh "$program_path/linux/my_application.cc" -bash $scriptdir/tools/add_key_release_event_to_my_application.sh "$program_path/linux/my_application.cc" -bash $scriptdir/tools/add_key_press_event_to_my_application.sh "$program_path/linux/my_application.cc" +bash $scriptdir/tools/import_webview_cef_header_my_application.sh "$program_path/linux/runner/my_application.cc" +bash $scriptdir/tools/add_key_release_event_to_my_application.sh "$program_path/linux/runner/my_application.cc" +bash $scriptdir/tools/add_key_press_event_to_my_application.sh "$program_path/linux/runner/my_application.cc" -bash $scriptdir/tools/import_webview_cef_header_main.sh "$program_path/linux/main.cc" -bash $scriptdir/tools/add_webview_init_to_main.sh "$program_path/linux/main.cc" +bash $scriptdir/tools/import_webview_cef_header_main.sh "$program_path/linux/runner/main.cc" +bash $scriptdir/tools/add_webview_init_to_main.sh "$program_path/linux/runner/main.cc" diff --git a/linux/target_modifier/tools/add_key_press_event_to_my_application.sh b/linux/target_modifier/tools/add_key_press_event_to_my_application.sh index fcf94b5..a38eb29 100755 --- a/linux/target_modifier/tools/add_key_press_event_to_my_application.sh +++ b/linux/target_modifier/tools/add_key_press_event_to_my_application.sh @@ -15,10 +15,19 @@ fi # Assign file path argument file="$1" -# Check if the file exists +# Check if the file exists at the provided path if [ ! -f "$file" ]; then - echo "File not found: $file" - exit 1 + # If not, construct a path in the parent directory with the same filename + parent_dir_file=$(dirname "$(dirname $file)")/$(basename "$file") + + # Check if the file exists at the new path + if [ -f "$parent_dir_file" ]; then + file="$parent_dir_file" # Use the new path if it exists + else + # If neither path is valid, exit + echo "File not found at '$file' or in its parent directory." + exit 1 + fi fi # Check if the line g_signal_connect exists in the file diff --git a/linux/target_modifier/tools/add_key_release_event_to_my_application.sh b/linux/target_modifier/tools/add_key_release_event_to_my_application.sh index dca9ffa..b0fcb76 100755 --- a/linux/target_modifier/tools/add_key_release_event_to_my_application.sh +++ b/linux/target_modifier/tools/add_key_release_event_to_my_application.sh @@ -15,10 +15,19 @@ fi # Assign file path argument file="$1" -# Check if the file exists +# Check if the file exists at the provided path if [ ! -f "$file" ]; then - echo "File not found: $file" - exit 1 + # If not, construct a path in the parent directory with the same filename + parent_dir_file=$(dirname "$(dirname $file)")/$(basename "$file") + + # Check if the file exists at the new path + if [ -f "$parent_dir_file" ]; then + file="$parent_dir_file" # Use the new path if it exists + else + # If neither path is valid, exit + echo "File not found at '$file' or in its parent directory." + exit 1 + fi fi # Check if the line g_signal_connect exists in the file diff --git a/linux/target_modifier/tools/add_webview_init_to_main.sh b/linux/target_modifier/tools/add_webview_init_to_main.sh index 13fe89b..12bbf21 100755 --- a/linux/target_modifier/tools/add_webview_init_to_main.sh +++ b/linux/target_modifier/tools/add_webview_init_to_main.sh @@ -13,10 +13,19 @@ fi # Assign file path argument file="$1" -# Check if the file exists +# Check if the file exists at the provided path if [ ! -f "$file" ]; then - echo "File not found: $file" - exit 1 + # If not, construct a path in the parent directory with the same filename + parent_dir_file=$(dirname "$(dirname $file)")/$(basename "$file") + + # Check if the file exists at the new path + if [ -f "$parent_dir_file" ]; then + file="$parent_dir_file" # Use the new path if it exists + else + # If neither path is valid, exit + echo "File not found at '$file' or in its parent directory." + exit 1 + fi fi # Check if the line initCEFProcesses(argc, argv); already exists in the file diff --git a/linux/target_modifier/tools/import_webview_cef_header_main.sh b/linux/target_modifier/tools/import_webview_cef_header_main.sh index 8e115fa..00f685d 100755 --- a/linux/target_modifier/tools/import_webview_cef_header_main.sh +++ b/linux/target_modifier/tools/import_webview_cef_header_main.sh @@ -11,10 +11,19 @@ fi # Assign file path argument file="$1" -# Check if the file exists +# Check if the file exists at the provided path if [ ! -f "$file" ]; then - echo "File not found: $file" - exit 1 + # If not, construct a path in the parent directory with the same filename + parent_dir_file=$(dirname "$(dirname $file)")/$(basename "$file") + + # Check if the file exists at the new path + if [ -f "$parent_dir_file" ]; then + file="$parent_dir_file" # Use the new path if it exists + else + # If neither path is valid, exit + echo "File not found at '$file' or in its parent directory." + exit 1 + fi fi # Check if the line already exists in the file diff --git a/linux/target_modifier/tools/import_webview_cef_header_my_application.sh b/linux/target_modifier/tools/import_webview_cef_header_my_application.sh index e47959d..d1c24fc 100755 --- a/linux/target_modifier/tools/import_webview_cef_header_my_application.sh +++ b/linux/target_modifier/tools/import_webview_cef_header_my_application.sh @@ -15,10 +15,19 @@ fi # Assign file path argument file="$1" -# Check if the file exists +# Check if the file exists at the provided path if [ ! -f "$file" ]; then - echo "File not found: $file" - exit 1 + # If not, construct a path in the parent directory with the same filename + parent_dir_file=$(dirname "$(dirname $file)")/$(basename "$file") + + # Check if the file exists at the new path + if [ -f "$parent_dir_file" ]; then + file="$parent_dir_file" # Use the new path if it exists + else + # If neither path is valid, exit + echo "File not found at '$file' or in its parent directory." + exit 1 + fi fi # Check if the line already exists in the file diff --git a/third/download.cmake b/third/download.cmake index 8f2c964..26d2e1d 100644 --- a/third/download.cmake +++ b/third/download.cmake @@ -1,22 +1,20 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") message(WARNING "current system is Linux") if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64") - set(cef_prebuilt_path "https://cef-builds.spotifycdn.com/cef_binary_130.1.2%2Bg48f3ef6%2Bchromium-130.0.6723.44_linuxarm64.tar.bz2") - set(cef_prebuilt_version "cef_binary_130.1.2%2Bg48f3ef6%2Bchromium-130.0.6723.44_linuxarm64.tar.bz2") + set(cef_prebuilt_path "https://cef-builds.spotifycdn.com/cef_binary_138.0.21%2Bg54811fe%2Bchromium-138.0.7204.101_linuxarm64.tar.bz2") + set(cef_prebuilt_version "cef_binary_138.0.21%2Bg54811fe%2Bchromium-138.0.7204.101_linuxarm64") else() - set(cef_prebuilt_path "https://cef-builds.spotifycdn.com/cef_binary_130.1.2%2Bg48f3ef6%2Bchromium-130.0.6723.44_linux64.tar.bz2") - set(cef_prebuilt_version "cef_binary_130.1.2%2Bg48f3ef6%2Bchromium-130.0.6723.44_linux64.tar.bz2") + set(cef_prebuilt_path "https://cef-builds.spotifycdn.com/cef_binary_138.0.21%2Bg54811fe%2Bchromium-138.0.7204.101_linux64.tar.bz2") + set(cef_prebuilt_version "cef_binary_138.0.21%2Bg54811fe%2Bchromium-138.0.7204.101_linux64") endif() elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") message(WARNING "current system is Windows") - set(cef_prebuilt_path "https://github.com/hlwhl/webview_cef/releases/download/prebuilt_cef_bin_linux/webview_cef_bin_0.0.2_101.0.18+chromium-101.0.4951.67_windows64.zip") - set(cef_prebuilt_version "webview_cef_bin_0.0.2_101.0.18+chromium-101.0.4951.67_windows64") + set(cef_prebuilt_path "https://cef-builds.spotifycdn.com/cef_binary_138.0.21%2Bg54811fe%2Bchromium-138.0.7204.101_windows64.tar.bz2") + set(cef_prebuilt_version "cef_binary_138.0.21%2Bg54811fe%2Bchromium-138.0.7204.101_windows64") # elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # message(STATUS "current system is MacOS") # set(cef_prebuilt_path "") endif() -set(cef_prebuilt_version_path "https://github.com/hlwhl/webview_cef/releases/download/prebuilt_cef_bin_linux/version.txt") - function(extract_file filename extract_dir) message(WARNING "${filename} will extract to ${extract_dir} ...")