00001 00033 #include "llviewerprecompiledheaders.h" 00034 00035 #include "llweb.h" 00036 00037 #include "llwindow.h" 00038 00039 #include "llviewercontrol.h" 00040 #include "llfloaterhtmlhelp.h" 00041 00042 // static 00043 void LLWeb::initClass() 00044 { 00045 LLAlertDialog::setURLLoader(&sAlertURLLoader); 00046 } 00047 00048 // static 00049 void LLWeb::loadURL(const std::string& url) 00050 { 00051 if (gSavedSettings.getBOOL("UseExternalBrowser")) 00052 { 00053 loadURLExternal(url); 00054 } 00055 else 00056 { 00057 LLFloaterMediaBrowser::showInstance(url); 00058 } 00059 } 00060 00061 00062 // static 00063 void LLWeb::loadURLExternal(const std::string& url) 00064 { 00065 std::string escaped_url = escapeURL(url); 00066 spawn_web_browser(escaped_url.c_str()); 00067 } 00068 00069 00070 // static 00071 std::string LLWeb::escapeURL(const std::string& url) 00072 { 00073 // The CURL curl_escape() function escapes colons, slashes, 00074 // and all characters but A-Z and 0-9. Do a cheesy mini-escape. 00075 std::string escaped_url; 00076 S32 len = url.length(); 00077 for (S32 i = 0; i < len; i++) 00078 { 00079 char c = url[i]; 00080 if (c == ' ') 00081 { 00082 escaped_url += "%20"; 00083 } 00084 else if (c == '\\') 00085 { 00086 escaped_url += "%5C"; 00087 } 00088 else 00089 { 00090 escaped_url += c; 00091 } 00092 } 00093 return escaped_url; 00094 } 00095 00096 // virtual 00097 void LLWeb::URLLoader::load(const std::string& url) 00098 { 00099 loadURL(url); 00100 } 00101 00102 // static 00103 LLWeb::URLLoader LLWeb::sAlertURLLoader;