From a23ec5ffa84c1122af3cbb416363a0eb564ad65c Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Mon, 23 Jun 2014 23:16:36 +0300 Subject: MAINT-4127: New default mode when clicking links: Linden links open in viewer, third-party links open in user's browser --- indra/newview/app_settings/settings.xml | 13 ++++++- indra/newview/llviewermenu.cpp | 4 +- indra/newview/llweb.cpp | 21 ++++++++++- indra/newview/llweb.h | 8 ++++ .../default/xui/en/panel_preferences_setup.xml | 44 +++++++++++++++++++++- 5 files changed, 85 insertions(+), 5 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2e49357d6f..b92751c448 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -13256,7 +13256,7 @@ Value Default - UseExternalBrowser + UseExternalBrowser Comment Use default browser when opening web pages instead of in-world browser. @@ -13267,6 +13267,17 @@ Value 1 + PreferredBrowserBehavior + + Comment + Use system browser for any links (0), use builtin browser for SL links and system one for others (1) or use builtin browser only (2). + Persist + 1 + Type + U32 + Value + 1 + UseFreezeFrame Comment diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 8b9b9ed172..01e6c8a5d0 100755 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -6196,7 +6196,7 @@ class LLPromptShowURL : public view_listener_t std::string alert = param.substr(0, offset); std::string url = param.substr(offset+1); - if(gSavedSettings.getBOOL("UseExternalBrowser")) + if (LLWeb::useExternalBrowser(url)) { LLSD payload; payload["url"] = url; @@ -7816,7 +7816,7 @@ void handle_web_content_test(const LLSD& param) void handle_show_url(const LLSD& param) { std::string url = param.asString(); - if(gSavedSettings.getBOOL("UseExternalBrowser")) + if (LLWeb::useExternalBrowser(url)) { LLWeb::loadURLExternal(url); } diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp index 665671a38f..0312972a22 100755 --- a/indra/newview/llweb.cpp +++ b/indra/newview/llweb.cpp @@ -50,6 +50,8 @@ #include "llviewerwindow.h" #include "llnotificationsutil.h" +#include + bool on_load_url_external_response(const LLSD& notification, const LLSD& response, bool async ); @@ -87,7 +89,8 @@ void LLWeb::loadURL(const std::string& url, const std::string& target, const std // Force load in the internal browser, as if with a blank target. loadURLInternal(url, "", uuid); } - else if (gSavedSettings.getBOOL("UseExternalBrowser") || (target == "_external")) + + else if (useExternalBrowser(url) || (target == "_external")) { loadURLExternal(url); } @@ -225,3 +228,19 @@ std::string LLWeb::expandURLSubstitutions(const std::string &url, return LLWeb::escapeURL(expanded_url); } + +//static +bool LLWeb::useExternalBrowser(const std::string &url) +{ + if (gSavedSettings.getU32("PreferredBrowserBehavior") == BROWSER_EXTERNAL_ONLY) + { + return true; + } + else if (gSavedSettings.getU32("PreferredBrowserBehavior") == BROWSER_INT_LL_EXT_OTHERS) + { + boost::regex pattern = boost::regex("\\b(lindenlab.com|secondlife.com)\\b", boost::regex::perl|boost::regex::icase); + boost::match_results matches; + return !(boost::regex_search(url, matches, pattern)); + } + return false; +} diff --git a/indra/newview/llweb.h b/indra/newview/llweb.h index 0b95f664d6..7c90badbfe 100755 --- a/indra/newview/llweb.h +++ b/indra/newview/llweb.h @@ -40,6 +40,13 @@ class LLWeb { public: + enum PreferredBrowser + { + BROWSER_EXTERNAL_ONLY = 0, + BROWSER_INT_LL_EXT_OTHERS = 1, + BROWSER_INTERNAL_ONLY = 2 + }; + static void initClass(); /// Load the given url in the operating system's web browser, async if we want to return immediately @@ -57,6 +64,7 @@ public: /// Expands various strings like [LANG], [VERSION], etc. in a URL static std::string expandURLSubstitutions(const std::string &url, const LLSD &default_subs); + static bool useExternalBrowser(const std::string &url); }; #endif diff --git a/indra/newview/skins/default/xui/en/panel_preferences_setup.xml b/indra/newview/skins/default/xui/en/panel_preferences_setup.xml index dd4533ae74..1e9a1aa27c 100755 --- a/indra/newview/skins/default/xui/en/panel_preferences_setup.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_setup.xml @@ -106,7 +106,7 @@ width="300"> Web: - + --> + + + + +