diff --git a/ohos_nweb/src/cef_delegate/nweb_application.cc b/ohos_nweb/src/cef_delegate/nweb_application.cc index 716dd0b406eb896e48bc88214f3295f68a0576e6..00287493aa01b6826213431e942b418200bbc97d 100644 --- a/ohos_nweb/src/cef_delegate/nweb_application.cc +++ b/ohos_nweb/src/cef_delegate/nweb_application.cc @@ -35,6 +35,10 @@ #include "cef/libcef/common/net/scheme_registration.h" #endif +#ifdef defined(OHOS_NWEB_EX) && defined(OHOS_CRASHPAD) +#include "ohos_nweb_ex/overrides/ohos_nweb/src/cef_delegate/custom_crashpad_handler.h" +#endif + namespace { #if defined(OHOS_API_INIT_WEB_ENGINE) CefRefPtr g_application = nullptr; @@ -95,6 +99,10 @@ void NWebApplication::InitializeCef(const CefMainArgs& mainargs, } #endif // defined(OHOS_API_INIT_WEB_ENGINE) +#ifdef defined(OHOS_NWEB_EX) && defined(OHOS_CRASHPAD) +OHOS::NWeb::ReportCrashpadFiles(NWebImpl::GetDefaultCrashpadLogPath()); +#endif + /* CefApp methods begin */ CefRefPtr NWebApplication::GetBrowserProcessHandler() { diff --git a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc index 296d3be358bf23c0be41156c86860416252329c6..b3c49ccdd2477dd6d59abbd5e12986177f393111 100644 --- a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc @@ -113,6 +113,9 @@ #ifdef OHOS_ARKWEB_ADBLOCK #include "base/strings/string_number_conversions.h" #endif +#if defined(OHOS_NWEB_EX) && defined(OHOS_CRASHPAD) +#include "ohos_nweb_ex/overrides/ohos_nweb/src/cef_delegate/custom_crashpad_handler.h" +#endif #include "third_party/bounds_checking_function/include/securec.h" @@ -1618,6 +1621,11 @@ void NWebHandlerDelegate::OnRenderProcessTerminated( ReportPageLoadErrorInfo(nweb_id_, error_type, static_cast(reason), error_desc); #endif + +#if defined(OHOS_NWEB_EX) && defined(OHOS_CRASHPAD) + OHOS::NWeb::ReportFeedbacklogsCrashDmpFiles( + NWebImpl::GetDefaultFeedbacklogsCrashPath()); +#endif } bool NWebHandlerDelegate::GetAuthCredentials( diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index 5a24004c4ec7c68f516a46c6ab167ac2dcdcd949..a1afe5fe59239d62dc2b7ba82826258c082cf69c 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -212,6 +212,11 @@ static bool set_whole_page_drawing = false; std::shared_ptr g_logger_callback; #endif bool g_logger_callback_initialized = false; +#if defined(OHOS_CRASHPAD) +static std::string g_crashpad_target_location = "/data/storage/el2/crashpad"; +static std::string g_feedbacklogs_crash_path = + "/data/storage/el2/base/haps/entry/files/logs/logs/logFile"; +#endif bool GetWebOptimizationValue() { auto& system_properties_adapter = OHOS::NWeb::OhosAdapterHelper::GetInstance() @@ -2849,8 +2854,28 @@ void NWebImpl::PutLoggerCallback( std::shared_ptr logger_callback) { WVLOG_D("put logger callback"); g_logger_callback = logger_callback; +#ifdef OHOS_CRASHPAD +void NWebImpl::SetDefaultCrashpadLogPath(const std::string& crashpad_log_path) { + LOG(INFO) << "g_crashpad_target_location is" << g_crashpad_target_location + << "crashpad_log_path is" << crashpad_log_path; + g_crashpad_target_location = crashpad_log_path; +} +const std::string NWebImpl::GetDefaultCrashpadLogPath() { + return g_crashpad_target_location; +} + +void NWebImpl::SetDefaultFeedbacklogsCrashPath( + const std::string& feedbacklogs_crash_path) { + LOG(INFO) << "[feedbacklogs] g_feedbacklogs_crash_path: " << g_feedbacklogs_crash_path + << ", feedbacklogs_crash_path: " << feedbacklogs_crash_path; + g_feedbacklogs_crash_path = feedbacklogs_crash_path; } +const std::string& NWebImpl::GetDefaultFeedbacklogsCrashPath() { + return g_feedbacklogs_crash_path; +} +#endif + void NWebImpl::RemoveLoggerCallback() { WVLOG_D("remove logger callback"); NWebHandlerDelegate::UnRegisterLoggerCallback(); diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index 752920b8db5af207b881675eecf1d5ed6c0f8ab9..8cd5a10fdbe6df3c31539c8fd329967b7d100ab0 100644 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -472,6 +472,14 @@ class NWebImpl : public NWeb { double GetBrowserZoomLevel() const; #endif +#ifdef OHOS_CRASHPAD + static void SetDefaultCrashpadLogPath(const std::string& crashpad_log_path); + static const std::string GetDefaultCrashpadLogPath(); + static void SetDefaultFeedbacklogsCrashPath( + const std::string& feedbacklogs_crash_path); + static const std::string& GetDefaultFeedbacklogsCrashPath(); +#endif + #if defined(OHOS_INCOGNITO_MODE) bool IsIncognitoMode() override { return incognito_mode_;