diff --git a/include/capi/cef_browser_capi.h b/include/capi/cef_browser_capi.h index ad3d3e768f6131ef158381df8564008e3c978a2f..a34f177e5e360189e5a2d24713ddccf29d1f3ecf 100644 --- a/include/capi/cef_browser_capi.h +++ b/include/capi/cef_browser_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=7ef2a76186a15d25bd6e66b8f311366a7955d2e3$ +// $hash=bd8050242da82fa39fa2b3a37815cbd884f3efa8$ // #ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_ @@ -1335,6 +1335,11 @@ typedef struct _cef_browser_host_t { /// void(CEF_CALLBACK *set_window_id)(struct _cef_browser_host_t *self, int window_id, int nweb_id); + + /// + // Set the token of the UI framework + /// + void(CEF_CALLBACK *set_token)(struct _cef_browser_host_t *self, void *token); } cef_browser_host_t; /// diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index 35a92d520c115556ccd3c5836aaf2b758ab9c506..1dfe43c1179f6ab9c8e86546875e5f1be749eff3 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -42,15 +42,15 @@ // way that may cause binary incompatibility with other builds. The universal // hash value will change if any platform is affected whereas the platform hash // values will change only if that particular platform is affected. -#define CEF_API_HASH_UNIVERSAL "59162f853721a1af11bedc887a854836cfe7d678" +#define CEF_API_HASH_UNIVERSAL "9136694da06c3e39438804f09ab4f6169a8e751c" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "db4f64a322df7dc67c474809c04a32b7b74d2bfa" +#define CEF_API_HASH_PLATFORM "2834804fc2e11abb6ac5c3550a6641981c2e748b" #elif defined(OS_MAC) -#define CEF_API_HASH_PLATFORM "40c167b27881003dbd1ab45879ca40cadf1c8340" +#define CEF_API_HASH_PLATFORM "539213150036dbda126130249e711d4bb4f92cd7" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "a67604ca783d6e4b91af5daf5ead5c8d9242000b" +#define CEF_API_HASH_PLATFORM "8b7ac65714f030a8e55e13d6ada103799cbd158a" #elif defined(OS_OHOS) -#define CEF_API_HASH_PLATFORM "a67604ca783d6e4b91af5daf5ead5c8d9242000b" +#define CEF_API_HASH_PLATFORM "8b7ac65714f030a8e55e13d6ada103799cbd158a" #endif #ifdef __cplusplus diff --git a/include/cef_browser.h b/include/cef_browser.h index d886c08506ae63cfcd0cdf8120ba25ee760027f7..5a78f7d7dc85c084d44759266c0bbfe350da50a8 100644 --- a/include/cef_browser.h +++ b/include/cef_browser.h @@ -1432,6 +1432,12 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void SetWindowId(int window_id, int nweb_id) = 0; + + /// + // Set the token of the UI framework + /// + /*--cef()--*/ + virtual void SetToken(void* token) = 0; }; /// diff --git a/libcef/browser/alloy/alloy_browser_host_impl.cc b/libcef/browser/alloy/alloy_browser_host_impl.cc index 3cacdabb88a357b9e8891c5d74b37a3a26e94668..91a195372cbe40f9818b900ff52abf5a22ec5a37 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.cc +++ b/libcef/browser/alloy/alloy_browser_host_impl.cc @@ -1977,6 +1977,12 @@ void AlloyBrowserHostImpl::WasKeyboardResized() { platform_delegate_->WasKeyboardResized(); } +void AlloyBrowserHostImpl::SetToken(void* token) { + if (platform_delegate_) { + platform_delegate_->SetToken(token); + } +}; + void AlloyBrowserHostImpl::OpenDateTimeChooser() { content::DateTimeChooserOHOS* date_time_chooser = content::DateTimeChooserOHOS::FromWebContents(web_contents()); diff --git a/libcef/browser/alloy/alloy_browser_host_impl.h b/libcef/browser/alloy/alloy_browser_host_impl.h index 3002df8d64b8638284323bec278a25fe52ae1168..7beae3d52d56e5188658c1683c1e4464f6557087 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.h +++ b/libcef/browser/alloy/alloy_browser_host_impl.h @@ -201,6 +201,7 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase, void SetShouldFrameSubmissionBeforeDraw(bool should) override; void SetWindowId(int window_id, int nweb_id) override; void WasKeyboardResized() override; + void SetToken(void* token) override; #else bool HandleContextMenu(content::WebContents* web_contents, const content::ContextMenuParams& params); diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.cc b/libcef/browser/alloy/browser_platform_delegate_alloy.cc index 4f4ec9702f66f7048df1fd86b65bd843138a59e3..e44f6af4b0cb45c9463e1142ed905b9336652b78 100644 --- a/libcef/browser/alloy/browser_platform_delegate_alloy.cc +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.cc @@ -53,6 +53,13 @@ namespace { +#if BUILDFLAG(IS_OHOS) +printing::OhosPrintManager* GetPrintViewManager( + content::WebContents* web_contents) { + return printing::OhosPrintManager::FromWebContents(web_contents); +} +#endif + #if BUILDFLAG(IS_OHOS) && BUILDFLAG(ENABLE_PRINT_PREVIEW) printing::CefPrintViewManager* GetPrintViewManager( content::WebContents* web_contents) { @@ -553,4 +560,23 @@ void CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted() { DCHECK(is_background_host_); DCHECK(extension_host_); extension_host_ = nullptr; -} \ No newline at end of file +} + +#if BUILDFLAG(IS_OHOS) + void CefBrowserPlatformDelegateAlloy::SetToken(void* token) { + REQUIRE_ALLOY_RUNTIME(); + auto contents_to_use = printing::GetWebContentsToUse(web_contents_); + if (!contents_to_use) { + LOG(ERROR) << "contents_to_use is nullptr"; + return; + } + + auto ohosPrintManager = GetPrintViewManager(contents_to_use); + if (!ohosPrintManager) { + LOG(ERROR) << "ohosPrintManager is nullptr"; + return; + } + + ohosPrintManager->SetToken(token); + } +#endif \ No newline at end of file diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.h b/libcef/browser/alloy/browser_platform_delegate_alloy.h index 9f8d24aac22b8f6c92bf1e526b83be0692e9b9ca..257fd82e6bb25e734a1f809d74ed6114de4959c9 100644 --- a/libcef/browser/alloy/browser_platform_delegate_alloy.h +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.h @@ -78,6 +78,10 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate { return last_search_result_; } +#if BUILDFLAG(IS_OHOS) + void SetToken(void* token) override; +#endif + protected: CefBrowserPlatformDelegateAlloy(); diff --git a/libcef/browser/browser_platform_delegate.cc b/libcef/browser/browser_platform_delegate.cc index d1bbb6d04dd6ca4efe1b80b920663e5db67c7447..af21fc53f28fe7837c35b99923d39ac032a4ca78 100644 --- a/libcef/browser/browser_platform_delegate.cc +++ b/libcef/browser/browser_platform_delegate.cc @@ -427,6 +427,12 @@ void CefBrowserPlatformDelegate::ShowPasswordDialog(bool is_update, } #endif +#if BUILDFLAG(IS_OHOS) + void CefBrowserPlatformDelegate::SetToken(void* token) { + NOTIMPLEMENTED(); + } +#endif + // static int CefBrowserPlatformDelegate::TranslateWebEventModifiers( uint32 cef_modifiers) { diff --git a/libcef/browser/browser_platform_delegate.h b/libcef/browser/browser_platform_delegate.h index 32cda0e50816d65e20e01caa2973bdaba6646501..52dcc24f6349853d0d4e71ad3b07a07d06aaca26 100644 --- a/libcef/browser/browser_platform_delegate.h +++ b/libcef/browser/browser_platform_delegate.h @@ -393,6 +393,7 @@ class CefBrowserPlatformDelegate { #if BUILDFLAG(IS_OHOS) virtual void SetShouldFrameSubmissionBeforeDraw(bool should) {}; virtual void WasKeyboardResized() {}; + virtual void SetToken(void* token); #endif protected: // Allow deletion via std::unique_ptr only. diff --git a/libcef/browser/printing/ohos_print_manager.cc b/libcef/browser/printing/ohos_print_manager.cc index e24e8616231e18eafffc7ecd01f95e638577f9a1..baf03b811bcd3c5109fa2a4a7325f17a1a92539b 100755 --- a/libcef/browser/printing/ohos_print_manager.cc +++ b/libcef/browser/printing/ohos_print_manager.cc @@ -153,7 +153,8 @@ bool OhosPrintManager::PrintNow() { int32_t ret = OHOS::NWeb::OhosAdapterHelper::GetInstance() .GetPrintManagerInstance() .Print(printJobName, printDocumentAdapterImpl, - printAttributesAdapter); + printAttributesAdapter, token_); + LOG(INFO) << "OhosPrintManager::PrintNow ret = " << ret; if (ret == -1) { LOG(ERROR) << "print failed"; return false; @@ -374,18 +375,24 @@ std::string OhosPrintManager::GetHtmlTitle() { printJobName = RemoveProtocol(printJobName); std::replace(printJobName.begin(), printJobName.end(), '/', '_'); std::replace(printJobName.begin(), printJobName.end(), '?', '_'); - LOG(INFO) << "OhosPrintManager::GetHtmlTitle printJobName is = " << printJobName; + LOG(INFO) << "OhosPrintManager::GetHtmlTitle printJobName is = " + << printJobName; return printJobName; } std::string OhosPrintManager::RemoveProtocol(const std::string& url) { LOG(INFO) << "OhosPrintManager::RemoveProtocol"; - std::string result = url; - std::size_t pos = result.find(PROTOCOL_PATH); - if (pos != std::string::npos) { - result = result.substr(pos + PROTOCOL_PATH.size()); - } - return result; + std::string result = url; + std::size_t pos = result.find(PROTOCOL_PATH); + if (pos != std::string::npos) { + result = result.substr(pos + PROTOCOL_PATH.size()); + } + return result; +} + +void OhosPrintManager::SetToken(void* token) { + LOG(INFO) << "OhosPrintManager::SetToken"; + token_ = token; } WEB_CONTENTS_USER_DATA_KEY_IMPL(OhosPrintManager); diff --git a/libcef/browser/printing/ohos_print_manager.h b/libcef/browser/printing/ohos_print_manager.h index b843f5ce2e160a381ebc295b1050da84862815d1..01a4f1bc2fb4e347b2c351af966edb5dd2a079f6 100755 --- a/libcef/browser/printing/ohos_print_manager.h +++ b/libcef/browser/printing/ohos_print_manager.h @@ -61,6 +61,7 @@ class OhosPrintManager : public printing::PrintManager, void PrintPageImpl(); void SetPrintAttrs(const PrintAttrs printAttrs); void RunPrintRequestedCallback(const std::string& jobId); + void SetToken(void* token); private: friend class content::WebContentsUserData; @@ -94,7 +95,7 @@ class OhosPrintManager : public printing::PrintManager, uint32_t width_ = 8270; uint32_t height_ = 11690; int dpi_ = 300; // DPI (Dots Per Inch) - + void* token_ = nullptr; static std::unordered_map printAttrsMap_; static std::string printJobId_; PrintRequestedCallback printRequestedCallback_; diff --git a/libcef_dll/cpptoc/browser_host_cpptoc.cc b/libcef_dll/cpptoc/browser_host_cpptoc.cc index bfdfdeec130ad6ee1c0c39e143a6de383a22ac5f..1e916f1fc959a5446efba276f412ec98b0802cec 100644 --- a/libcef_dll/cpptoc/browser_host_cpptoc.cc +++ b/libcef_dll/cpptoc/browser_host_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=9c96357f5492ca971fb691efde09334789599e47$ +// $hash=f189b57327c9226121c0ff30543c1107e119bbb3$ // #include "libcef_dll/cpptoc/browser_host_cpptoc.h" @@ -2199,6 +2199,24 @@ void CEF_CALLBACK browser_host_set_window_id(struct _cef_browser_host_t *self, CefBrowserHostCppToC::Get(self)->SetWindowId(window_id, nweb_id); } +void CEF_CALLBACK browser_host_set_token(struct _cef_browser_host_t *self, + void *token) { + shutdown_checker::AssertNotShutdown(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: token; type: simple_byaddr + DCHECK(token); + if (!token) + return; + + // Execute + CefBrowserHostCppToC::Get(self)->SetToken(token); +} + } // namespace // CONSTRUCTOR - Do not edit by hand. @@ -2331,6 +2349,7 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() { browser_host_set_should_frame_submission_before_draw; GetStruct()->zoom_by = browser_host_zoom_by; GetStruct()->set_window_id = browser_host_set_window_id; + GetStruct()->set_token = browser_host_set_token; } // DESTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.cc b/libcef_dll/ctocpp/browser_host_ctocpp.cc index 05d325cf015fa6e06adf0a913f5a1ee8f5a63dd5..3a8efcd0495d9b571b0c68e8697c5d3beca46b01 100644 --- a/libcef_dll/ctocpp/browser_host_ctocpp.cc +++ b/libcef_dll/ctocpp/browser_host_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=e54557b8104e13c6fe2c59456ab362cc219a8606$ +// $hash=3691a500f9953dab9b1ee4caf9a82386baaaeef1$ // #include "libcef_dll/ctocpp/browser_host_ctocpp.h" @@ -2011,6 +2011,24 @@ void CefBrowserHostCToCpp::SetWindowId(int window_id, int nweb_id) { _struct->set_window_id(_struct, window_id, nweb_id); } +NO_SANITIZE("cfi-icall") void CefBrowserHostCToCpp::SetToken(void *token) { + shutdown_checker::AssertNotShutdown(); + + cef_browser_host_t *_struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, set_token)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: token; type: simple_byaddr + DCHECK(token); + if (!token) + return; + + // Execute + _struct->set_token(_struct, token); +} + // CONSTRUCTOR - Do not edit by hand. CefBrowserHostCToCpp::CefBrowserHostCToCpp() {} diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.h b/libcef_dll/ctocpp/browser_host_ctocpp.h index e08cf74f354b5170fb276655c8d409e8e5c41681..54ffc90aef59fa2c54c5613d1a590fe1d90e01b0 100644 --- a/libcef_dll/ctocpp/browser_host_ctocpp.h +++ b/libcef_dll/ctocpp/browser_host_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=27a92060c53540973408590dd50a4e0b553c3a02$ +// $hash=01e70f22f4d554ed94d4208b086797596ba0291b$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_ @@ -191,6 +191,7 @@ public: void SetShouldFrameSubmissionBeforeDraw(bool should) override; void ZoomBy(float delta, float width, float height) override; void SetWindowId(int window_id, int nweb_id) override; + void SetToken(void *token) override; }; #endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_