summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatersearch.cpp
diff options
context:
space:
mode:
authorCallum Linden <113564339+callumlinden@users.noreply.github.com>2025-08-22 16:21:31 -0700
committerGitHub <noreply@github.com>2025-08-22 16:21:31 -0700
commitcefee59b0e5fff683a50fe61633a9c14493d7145 (patch)
tree9b7ece084971f038db19291ba3c981b7b50bbf8d /indra/newview/llfloatersearch.cpp
parent1022be69862db187594f2971fa9602d46f13e372 (diff)
Improved open performance for some web based UI floaters by preloading the web content during login (#4574)
* First phase of some work to replace certain UI web based floaters with a much more simple floater (no more browserish web-content-floater) and then pre-load content as login is progressing. This means that after login, the floater can be opened much more rapidly than now. This first commit does this process for the Search floater * This commit brings in a new marketplace floater than hosts the marketplace web page (no more webcontent floater here either). It works as expected and opens quickly but the user is not logged in when the page is opened so that needs to be tackled before we can declare that this is a viable solution * This commit introduces a way to set the openID cookie that arrives via login.cgi into all the instances that are preloaded - the result is that when you open the preloaded floater after login, you are logged into your linden account * Fix a mac only warning as error - function overrides a member function but is not marked 'override' * Marchcat spotted left over cruft from earlier dev when we used a trimmed down URL for the pre-load search. Now we use the same search URL throughout and zero out the query parameters
Diffstat (limited to 'indra/newview/llfloatersearch.cpp')
-rw-r--r--indra/newview/llfloatersearch.cpp183
1 files changed, 72 insertions, 111 deletions
diff --git a/indra/newview/llfloatersearch.cpp b/indra/newview/llfloatersearch.cpp
index d3c8bf3451..9762154a26 100644
--- a/indra/newview/llfloatersearch.cpp
+++ b/indra/newview/llfloatersearch.cpp
@@ -1,11 +1,10 @@
/**
* @file llfloatersearch.cpp
- * @author Martin Reddy
- * @brief Search floater - uses an embedded web browser control
+ * @brief Floater for Search (update 2025, preload)
*
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * $LicenseInfo:firstyear=2011&license=viewerlgpl$
* Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
+ * Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -27,68 +26,34 @@
#include "llviewerprecompiledheaders.h"
+#include "llfloatersearch.h"
+
+#include "llagent.h"
#include "llcommandhandler.h"
#include "llfloaterreg.h"
-#include "llfloatersearch.h"
-#include "llhttpconstants.h"
#include "llmediactrl.h"
-#include "llnotificationsutil.h"
-#include "lllogininstance.h"
-#include "lluri.h"
-#include "llagent.h"
-#include "llui.h"
+#include "lluictrlfactory.h"
#include "llviewercontrol.h"
#include "llweb.h"
// support secondlife:///app/search/{CATEGORY}/{QUERY} SLapps
-class LLSearchHandler : public LLCommandHandler
-{
-public:
- // requires trusted browser to trigger
- LLSearchHandler() : LLCommandHandler("search", UNTRUSTED_CLICK_ONLY) { }
- bool handle(const LLSD& tokens, const LLSD& query_map, const std::string& grid, LLMediaCtrl* web)
- {
- const size_t parts = tokens.size();
-
- // get the (optional) category for the search
- std::string collection;
- if (parts > 0)
- {
- collection = tokens[0].asString();
+class LLSearchHandler : public LLCommandHandler {
+ public:
+ // requires trusted browser to trigger
+ LLSearchHandler() : LLCommandHandler("search", UNTRUSTED_CLICK_ONLY) { }
+ bool handle(const LLSD& tokens, const LLSD& query_map, const std::string& grid, LLMediaCtrl* web) {
+ const size_t parts = tokens.size();
+
+ // open the search floater and perform the requested search
+ LLFloaterReg::showInstance("search", tokens);
+ return true;
}
-
- // get the (optional) search string
- std::string search_text;
- if (parts > 1)
- {
- search_text = tokens[1].asString();
- }
-
- // create the LLSD arguments for the search floater
- LLFloaterSearch::Params p;
- p.search.collection = collection;
- p.search.query = LLURI::unescape(search_text);
-
- // open the search floater and perform the requested search
- LLFloaterReg::showInstance("search", p);
- return true;
- }
};
LLSearchHandler gSearchHandler;
-LLFloaterSearch::SearchQuery::SearchQuery()
-: category("category", ""),
- collection("collection", ""),
- query("query")
-{}
-
-LLFloaterSearch::LLFloaterSearch(const Params& key) :
- LLFloaterWebContent(key),
- mSearchGodLevel(0)
+LLFloaterSearch::LLFloaterSearch(const LLSD& key)
+ : LLFloater(key)
{
- // declare a map that transforms a category name into
- // the URL suffix that is used to search that category
-
mSearchType.insert("standard");
mSearchType.insert("land");
mSearchType.insert("classified");
@@ -100,76 +65,61 @@ LLFloaterSearch::LLFloaterSearch(const Params& key) :
mCollectionType.insert("people");
}
-bool LLFloaterSearch::postBuild()
+LLFloaterSearch::~LLFloaterSearch()
{
- LLFloaterWebContent::postBuild();
- mWebBrowser->addObserver(this);
-
- return true;
}
-void LLFloaterSearch::onOpen(const LLSD& key)
+void LLFloaterSearch::onOpen(const LLSD& tokens)
{
- Params p(key);
- p.trusted_content = true;
- p.allow_address_entry = false;
-
- LLFloaterWebContent::onOpen(p);
- mWebBrowser->setFocus(true);
- search(p.search);
+ initiateSearch(tokens);
}
-void LLFloaterSearch::onClose(bool app_quitting)
+void LLFloaterSearch::initiateSearch(const LLSD& tokens)
{
- LLFloaterWebContent::onClose(app_quitting);
- // tear down the web view so we don't show the previous search
- // result when the floater is opened next time
- destroy();
-}
+ std::string url = gSavedSettings.getString("SearchURL");
-void LLFloaterSearch::godLevelChanged(U8 godlevel)
-{
- // search results can change based upon god level - if the user
- // changes god level, then give them a warning (we don't refresh
- // the search as this might undo any page navigation or
- // AJAX-driven changes since the last search).
+ LLSD subs;
- //FIXME: set status bar text
+ // Setting this substitution here results in a full set of collections being
+ // substituted into the final URL using the logic from the original search.
+ subs["TYPE"] = "standard";
- //getChildView("refresh_search")->setVisible( (godlevel != mSearchGodLevel));
-}
+ const size_t parts = tokens.size();
-void LLFloaterSearch::search(const SearchQuery &p)
-{
- if (! mWebBrowser || !p.validateBlock())
+ // get the (optional) category for the search
+ std::string collection;
+ if (parts > 0)
{
- return;
+ collection = tokens[0].asString();
}
- // reset the god level warning as we're sending the latest state
- getChildView("refresh_search")->setVisible(false);
- mSearchGodLevel = gAgent.getGodLevel();
+ // get the (optional) search string
+ std::string search_text;
+ if (parts > 1)
+ {
+ search_text = tokens[1].asString();
+ }
- // work out the subdir to use based on the requested category
- LLSD subs;
- if (mSearchType.find(p.category) != mSearchType.end())
+ // TODO: where does category get set? I cannot find a reference to
+ // it in internal docs - might be conflated with values in mSearchType
+ std::string category;
+ if (mSearchType.find(category) != mSearchType.end())
{
- subs["TYPE"] = p.category;
+ subs["TYPE"] = category;
}
else
{
subs["TYPE"] = "standard";
}
- // add the search query string
- subs["QUERY"] = LLURI::escape(p.query);
+ subs["QUERY"] = LLURI::escape(search_text);
subs["COLLECTION"] = "";
if (subs["TYPE"] == "standard")
{
- if (mCollectionType.find(p.collection) != mCollectionType.end())
+ if (mCollectionType.find(collection) != mCollectionType.end())
{
- subs["COLLECTION"] = "&collection_chosen=" + std::string(p.collection);
+ subs["COLLECTION"] = "&collection_chosen=" + std::string(collection);
}
else
{
@@ -182,30 +132,41 @@ void LLFloaterSearch::search(const SearchQuery &p)
}
}
- // add the user's preferred maturity (can be changed via prefs)
- std::string maturity;
+ // Default to PG
+ std::string maturity = "g";
if (gAgent.prefersAdult())
{
- maturity = "gma"; // PG,Mature,Adult
+ // PG,Mature,Adult
+ maturity = "gma";
}
else if (gAgent.prefersMature())
{
- maturity = "gm"; // PG,Mature
- }
- else
- {
- maturity = "g"; // PG
+ // PG,Mature
+ maturity = "gm";
}
subs["MATURITY"] = maturity;
- // add the user's god status
+ // God status
subs["GODLIKE"] = gAgent.isGodlike() ? "1" : "0";
- // get the search URL and expand all of the substitutions
- // (also adds things like [LANGUAGE], [VERSION], [OS], etc.)
- std::string url = gSavedSettings.getString("SearchURL");
+ // This call expands a set of generic substitutions like language, viewer version
+ // etc. and then also does the same with the list of subs passed in.
url = LLWeb::expandURLSubstitutions(url, subs);
- // and load the URL in the web view
- mWebBrowser->navigateTo(url, HTTP_CONTENT_TEXT_HTML);
+ // Naviation to the calculated URL - we know it's HTML so we can
+ // tell the media system not to bother with the MIME type check.
+ LLMediaCtrl* search_browser = findChild<LLMediaCtrl>("search_contents");
+ search_browser->navigateTo(url, HTTP_CONTENT_TEXT_HTML);
+}
+
+bool LLFloaterSearch::postBuild()
+{
+ enableResizeCtrls(true, true, false);
+
+ // This call is actioned by the preload code in llViewerWindow
+ // that creates the search floater during the login process
+ // using a generic search with no query
+ initiateSearch(LLSD());
+
+ return true;
}