diff --git a/common/webview_handler.cc b/common/webview_handler.cc index 468c82a..af7b0eb 100644 --- a/common/webview_handler.cc +++ b/common/webview_handler.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include "include/base/cef_callback.h" #include "include/cef_app.h" @@ -18,6 +19,18 @@ #include "include/wrapper/cef_closure_task.h" #include "include/wrapper/cef_helpers.h" +#include + +namespace stringpatch +{ + template < typename T > std::string to_string( const T& n ) + { + std::ostringstream stm ; + stm << n ; + return stm.str() ; + } +} + #include "webview_js_handler.h" namespace { @@ -67,7 +80,7 @@ bool WebviewHandler::OnProcessMessageReceived( } onJavaScriptChannelMessage( - fun_name,param,std::to_string(js_callback_id), browser->GetIdentifier(), std::to_string(frame->GetIdentifier())); + fun_name,param,stringpatch::to_string(js_callback_id), browser->GetIdentifier(), stringpatch::to_string(frame->GetIdentifier())); } else if(message_name == kEvaluateCallbackMessage){ CefString callbackId = message->GetArgumentList()->GetString(0); @@ -543,8 +556,12 @@ void WebviewHandler::sendJavaScriptChannelCallBack(const bool error, const std:: args->SetString(2, result); auto bit = browser_map_.find(browserId); if(bit != browser_map_.end()){ + int64_t frameIdInt = atoll(frameId.c_str()); + CefRefPtr frame = bit->second.browser->GetMainFrame(); - if (frame->GetIdentifier() == atoll(frameId.c_str())) + + // GetIdentifier().ToString() does not work on MacOS + if (std::stoll(stringpatch::to_string(frame->GetIdentifier())) == frameIdInt) { frame->SendProcessMessage(PID_RENDERER, message); } diff --git a/common/webview_js_handler.h b/common/webview_js_handler.h index 3c94293..513ef85 100644 --- a/common/webview_js_handler.h +++ b/common/webview_js_handler.h @@ -6,6 +6,8 @@ #include #include +#include + static const char kJSCallCppFunctionMessage[] = "JSCallCppFunction"; //js call c++ message static const char kExecuteJsCallbackMessage[] = "ExecuteJsCallback"; //c++ call js message @@ -29,7 +31,7 @@ class CefJSBridge void RemoveCallbackFuncWithFrame(CefRefPtr frame); bool ExecuteJSCallbackFunc(int js_callback_id, bool has_error, const CefString& json_result); private: - uint32 js_callback_id_ = 0; + uint32_t js_callback_id_ = 0; RenderCallbackMap render_callback_; StartRequestCallbackMap startRequest_callback_; }; diff --git a/common/webview_value.cc b/common/webview_value.cc index e5fedb5..5c7394c 100644 --- a/common/webview_value.cc +++ b/common/webview_value.cc @@ -2,6 +2,7 @@ #include #include #include +#include #if defined(_MSC_VER) #pragma warning(disable: 4996) @@ -12,6 +13,9 @@ typedef SSIZE_T ssize_t; #define return_val_if_fail(p, ret) if(!(p)) return (ret) #define return_if_fail(p) if(!(p)) return +using std::malloc; +using std::free; + struct webview_value{ WValueType type; int ref_count; @@ -914,4 +918,4 @@ char* webview_value_to_string(WValue* value) { default: return strdup(""); } -} \ No newline at end of file +} diff --git a/linux/webview_cef_plugin.cc b/linux/webview_cef_plugin.cc index 3d7a549..2089746 100644 --- a/linux/webview_cef_plugin.cc +++ b/linux/webview_cef_plugin.cc @@ -328,6 +328,8 @@ FLUTTER_PLUGIN_EXPORT gboolean processKeyEventForCEF(GtkWidget *widget, GdkEvent if(system("xclip -o -sel clipboard | xclip -i -sel clipboard &>/dev/null") == 0){ res = system("xclip -o -sel clipboard | xclip -i &>/dev/null"); } + // Suppress unused variable warning + (void)res; } else { // FIXME: fix for non BMP chars diff --git a/third/download.cmake b/third/download.cmake index c3881f1..ab0ce94 100644 --- a/third/download.cmake +++ b/third/download.cmake @@ -2,12 +2,15 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") message(WARNING "current system is Linux") if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64") set(cef_prebuilt_path "https://github.com/hlwhl/webview_cef/releases/download/prebuilt_cef_bin_linux/cef_binary_114.2.9+g1a97a28+chromium-114.0.5735.91_linuxarm64.zip") + set(cef_prebuilt_version "cef_binary_114.2.9+g1a97a28+chromium-114.0.5735.91_linuxarm64") else() - set(cef_prebuilt_path "https://github.com/hlwhl/webview_cef/releases/download/prebuilt_cef_bin_linux/cef_binary_114.2.9+g1a97a28+chromium-114.0.5735.91_linux64.zip") + set(cef_prebuilt_path "https://cef-builds.spotifycdn.com/cef_binary_128.4.12%2Bg1d7a1f9%2Bchromium-128.0.6613.138_linux64.tar.bz2") + set(cef_prebuilt_version "cef_binary_128.4.12%2Bg1d7a1f9%2Bchromium-128.0.6613.138_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") # elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # message(STATUS "current system is MacOS") # set(cef_prebuilt_path "") @@ -35,7 +38,7 @@ function(extract_file filename extract_dir) get_filename_component(contents ${contents} ABSOLUTE) file(INSTALL "${contents}/" DESTINATION ${extract_dir}) - + file(REMOVE_RECURSE ${temp_dir}) endfunction() @@ -55,10 +58,8 @@ function(prepare_prebuilt_files filepath) message(WARNING "No ${filepath}/version.txt found") set(need_download TRUE) else() - download_file(${cef_prebuilt_version_path} ${filepath}/new_version.txt) file(READ ${filepath}/version.txt local_version) - file(READ ${filepath}/new_version.txt new_version) - if(local_version STREQUAL new_version) + if(local_version STREQUAL cef_prebuilt_version) message(WARNING "No need to update ${filepath}") else() set(need_download TRUE) @@ -73,6 +74,7 @@ function(prepare_prebuilt_files filepath) download_file(${cef_prebuilt_path} ${CMAKE_CURRENT_SOURCE_DIR}/prebuilt.zip) file(MAKE_DIRECTORY ${filepath}) extract_file(${CMAKE_CURRENT_SOURCE_DIR}/prebuilt.zip ${filepath}) + file(WRITE "${filepath}/version.txt" "${cef_prebuilt_version}") file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/prebuilt.zip) endif() endfunction(prepare_prebuilt_files)