diff options
| author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2026-08-17 21:55:28 +0300 |
|---|---|---|
| committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2026-09-04 14:45:08 +0300 |
| commit | aecad04ca946115097390c2ef24c37da55ca3342 (patch) | |
| tree | acfb010e7f9060c0cb45005ea73d04832785c2cf | |
| parent | 069f87c6874f87714f10ec759e01db9817cbcc28 (diff) | |
Add fallback to legacy floater on page load error
| -rw-r--r-- | indra/newview/llbuycurrencyhtml.cpp | 5 | ||||
| -rw-r--r-- | indra/newview/llfloaterbuycurrencyhtml.cpp | 44 | ||||
| -rw-r--r-- | indra/newview/llfloaterbuycurrencyhtml.h | 6 |
3 files changed, 52 insertions, 3 deletions
diff --git a/indra/newview/llbuycurrencyhtml.cpp b/indra/newview/llbuycurrencyhtml.cpp index 81d9a261af..9ad068cf7f 100644 --- a/indra/newview/llbuycurrencyhtml.cpp +++ b/indra/newview/llbuycurrencyhtml.cpp @@ -145,6 +145,11 @@ void LLBuyCurrencyHTML::openCurrencyFloater( const std::string& message, S32 sum if (gSavedSettings.getBOOL("BuyCurrencyHTML") && sWebFloaterEnabled) { LLBuyCurrencyHTML::showDialog(sum - gStatusBar->getBalance()); + LLFloaterBuyCurrencyHTML* floater = dynamic_cast<LLFloaterBuyCurrencyHTML*>(LLFloaterReg::getInstance("buy_currency_html")); + if (floater) + { + floater->setFallbackContext(message, sum); + } } else { diff --git a/indra/newview/llfloaterbuycurrencyhtml.cpp b/indra/newview/llfloaterbuycurrencyhtml.cpp index cd8e33a04b..55b7c32169 100644 --- a/indra/newview/llfloaterbuycurrencyhtml.cpp +++ b/indra/newview/llfloaterbuycurrencyhtml.cpp @@ -27,6 +27,7 @@ #include "llviewerprecompiledheaders.h" #include "llfloaterbuycurrencyhtml.h" +#include "llfloaterbuycurrency.h" #include "llmediactrl.h" #include "llstatusbar.h" #include "llviewercontrol.h" @@ -83,11 +84,48 @@ void LLFloaterBuyCurrencyHTML::navigateToFinalURL() mBrowser->navigateTo(buildURL(mShortfall), HTTP_CONTENT_TEXT_HTML); } +void LLFloaterBuyCurrencyHTML::setFallbackContext(const std::string& message, S32 sum) +{ + mFallbackMessage = message; + mFallbackSum = sum; + mHasFallbackTarget = true; +} + +void LLFloaterBuyCurrencyHTML::fallbackToLegacy() +{ + LL_WARNS() << "Buy Currency HTML page failed to load, falling back to legacy floater" << LL_ENDL; + closeFloater(); + if (mHasFallbackTarget) + { + LLFloaterBuyCurrency::buyCurrency(mFallbackMessage, mFallbackSum); + } + else + { + LLFloaterBuyCurrency::buyCurrency(); + } +} + void LLFloaterBuyCurrencyHTML::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) { - if ((LLPluginClassMediaOwner::MEDIA_EVENT_NAVIGATE_COMPLETE == event) && - (self->getNavigateURI().find("done=success") != std::string::npos)) + if (LLPluginClassMediaOwner::MEDIA_EVENT_NAVIGATE_COMPLETE == event) { - LLStatusBar::sendMoneyBalanceRequest(); + if (self->getNavigateURI().find("done=success") != std::string::npos) + { + LLStatusBar::sendMoneyBalanceRequest(); + } + else + { + // HTTP 4xx/5xx: fall back to legacy floater + if (self->getNavigateResultCode() >= 400) + { + fallbackToLegacy(); + } + } + } + else if (event == LLPluginClassMediaOwner::MEDIA_EVENT_NAVIGATE_ERROR_PAGE || + event == LLPluginClassMediaOwner::MEDIA_EVENT_PLUGIN_FAILED_LAUNCH || + event == LLPluginClassMediaOwner::MEDIA_EVENT_PLUGIN_FAILED) + { + fallbackToLegacy(); } } diff --git a/indra/newview/llfloaterbuycurrencyhtml.h b/indra/newview/llfloaterbuycurrencyhtml.h index 76c54c5f3b..4b28cf6967 100644 --- a/indra/newview/llfloaterbuycurrencyhtml.h +++ b/indra/newview/llfloaterbuycurrencyhtml.h @@ -44,10 +44,16 @@ public: void navigateToFinalURL(); void setShortfall(S32 shortfall) { mShortfall = shortfall; } + void setFallbackContext(const std::string& message, S32 sum); static std::string buildURL(S32 shortfall = 0); private: + void fallbackToLegacy(); + LLMediaCtrl* mBrowser; S32 mShortfall{0}; + bool mHasFallbackTarget{false}; + std::string mFallbackMessage; + S32 mFallbackSum{0}; }; |
