diff options
| author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2022-01-14 15:36:00 +0200 | 
|---|---|---|
| committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-02-01 23:57:48 +0200 | 
| commit | 257f75d7a31d68ade0ee981546f5afa8bd762f1d (patch) | |
| tree | 4e827abefdc06f2f0d49047619acdc2cbbccd4f3 | |
| parent | bb71cbed04bdda9092abfc0418986be6e504ef5c (diff) | |
SL-16638 don't allow downloading files from the built-in browser
| -rw-r--r-- | indra/newview/llfloater360capture.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/llmediactrl.cpp | 23 | ||||
| -rw-r--r-- | indra/newview/llmediactrl.h | 5 | ||||
| -rw-r--r-- | indra/newview/llviewermedia.cpp | 45 | ||||
| -rw-r--r-- | indra/newview/llviewermenufile.cpp | 20 | ||||
| -rw-r--r-- | indra/newview/llviewermenufile.h | 14 | 
6 files changed, 63 insertions, 45 deletions
| diff --git a/indra/newview/llfloater360capture.cpp b/indra/newview/llfloater360capture.cpp index c469356cb0..c075f7e8bd 100644 --- a/indra/newview/llfloater360capture.cpp +++ b/indra/newview/llfloater360capture.cpp @@ -102,6 +102,7 @@ BOOL LLFloater360Capture::postBuild()      mWebBrowser = getChild<LLMediaCtrl>("360capture_contents");      mWebBrowser->addObserver(this); +    mWebBrowser->setAllowFileDownload(true);      // There is a group of radio buttons that define the quality      // by each having a 'value' that is returns equal to the pixel diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index 0affe8efb4..5393d0b0b7 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -46,6 +46,7 @@  #include "lluictrlfactory.h"	// LLDefaultChildRegistry  #include "llkeyboard.h"  #include "llviewermenu.h" +#include "llviewermenufile.h" // LLFilePickerThread  // linden library includes  #include "llfocusmgr.h" @@ -105,7 +106,8 @@ LLMediaCtrl::LLMediaCtrl( const Params& p) :  	mTrusted(p.trusted_content),  	mWindowShade(NULL),  	mHoverTextChanged(false), -	mContextMenu(NULL) +	mContextMenu(NULL), +    mAllowFileDownload(false)  {  	{  		LLColor4 color = p.caret_color().get(); @@ -1129,8 +1131,23 @@ void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event)  		case MEDIA_EVENT_FILE_DOWNLOAD:  		{ -			//llinfos << "Media event - file download requested - filename is " << self->getFileDownloadFilename() << llendl; -			//LLNotificationsUtil::add("MediaFileDownloadUnsupported"); +            if (mAllowFileDownload) +            { +                // pick a file from SAVE FILE dialog +                // for now the only thing that should be allowed to save is 360s +                std::string suggested_filename = self->getFileDownloadFilename(); +                LLFilePicker::ESaveFilter filter = LLFilePicker::FFSAVE_ALL; +                if (suggested_filename.find(".jpg") != std::string::npos || suggested_filename.find(".jpeg") != std::string::npos) +                    filter = LLFilePicker::FFSAVE_JPEG; +                if (suggested_filename.find(".png") != std::string::npos) +                    filter = LLFilePicker::FFSAVE_PNG; + +                (new LLMediaFilePicker(self, filter, suggested_filename))->getFile(); +            } +            else +            { +                LLNotificationsUtil::add("MediaFileDownloadUnsupported"); +            }  		};  		break; diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h index bd24c47a4f..bc4cbaae68 100644 --- a/indra/newview/llmediactrl.h +++ b/indra/newview/llmediactrl.h @@ -151,6 +151,8 @@ public:  		void setTrustedContent(bool trusted); +        void setAllowFileDownload(bool allow) { mAllowFileDownload = allow; } +  		// over-rides  		virtual BOOL handleKeyHere( KEY key, MASK mask);  		virtual BOOL handleKeyUpHere(KEY key, MASK mask); @@ -205,7 +207,8 @@ public:  				mClearCache,  				mHoverTextChanged,  				mDecoupleTextureSize, -				mUpdateScrolls; +				mUpdateScrolls, +                mAllowFileDownload;  		std::string mHomePageUrl,  					mHomePageMimeType, diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 54c2099ac9..b314c78839 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -78,41 +78,12 @@  #include <boost/bind.hpp>	// for SkinFolder listener  #include <boost/signals2.hpp> -class LLMediaFilePicker : public LLFilePickerThread // deletes itself when done -{ -public: -    LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple) -        : LLFilePickerThread(filter, get_multiple), -        mPlugin(plugin->getSharedPrt()) -    { -    } - -    LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, const std::string &proposed_name) -        : LLFilePickerThread(filter, proposed_name), -        mPlugin(plugin->getSharedPrt()) -    { -    } - -    virtual void notify(const std::vector<std::string>& filenames) -    { -        mPlugin->sendPickFileResponse(mResponses); -        mPlugin = NULL; -    } - -private: -    boost::shared_ptr<LLPluginClassMedia> mPlugin; -};  void init_threaded_picker_load_dialog(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple)  {      (new LLMediaFilePicker(plugin, filter, get_multiple))->getFile(); // will delete itself  } -void init_threaded_picker_save_dialog(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, std::string &proposed_name) -{ -    (new LLMediaFilePicker(plugin, filter, proposed_name))->getFile(); // will delete itself -} -  ///////////////////////////////////////////////////////////////////////////////  // Move this to its own file. @@ -3237,18 +3208,10 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla  		case LLViewerMediaObserver::MEDIA_EVENT_FILE_DOWNLOAD:  		{  			LL_DEBUGS("Media") << "Media event - file download requested - filename is " << plugin->getFileDownloadFilename() << LL_ENDL; -			// pick a file from SAVE FILE dialog - -			// need a better algorithm that this or else, pass in type of save type -			// from event that initiated it - this is okay for now - only thing -			// that saves is 360s -			std::string suggested_filename = plugin->getFileDownloadFilename(); -			LLFilePicker::ESaveFilter filter = LLFilePicker::FFSAVE_ALL; -			if (suggested_filename.find(".jpg") != std::string::npos || suggested_filename.find(".jpeg") != std::string::npos) -				filter = LLFilePicker::FFSAVE_JPEG; -			if (suggested_filename.find(".png") != std::string::npos) -				filter = LLFilePicker::FFSAVE_PNG; -			init_threaded_picker_save_dialog(plugin, filter, suggested_filename); + +            //unblock media plugin +            const std::vector<std::string> empty_response; +            plugin->sendPickFileResponse(empty_response);  		}  		break; diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 4efc3d1cb3..bb3e80c3ad 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -46,6 +46,7 @@  #include "llimagejpeg.h"  #include "llimagetga.h"  #include "llinventorymodel.h"	// gInventory +#include "llpluginclassmedia.h"  #include "llresourcedata.h"  #include "lltoast.h"  #include "llfloaterperms.h" @@ -251,6 +252,25 @@ void LLFilePickerReplyThread::notify(const std::vector<std::string>& filenames)  	}  } + +LLMediaFilePicker::LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple) +    : LLFilePickerThread(filter, get_multiple), +    mPlugin(plugin->getSharedPrt()) +{ +} + +LLMediaFilePicker::LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, const std::string &proposed_name) +    : LLFilePickerThread(filter, proposed_name), +    mPlugin(plugin->getSharedPrt()) +{ +} + +void LLMediaFilePicker::notify(const std::vector<std::string>& filenames) +{ +    mPlugin->sendPickFileResponse(mResponses); +    mPlugin = NULL; +} +  //============================================================================  #if LL_WINDOWS diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 4e6250d9b4..beeac418d9 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -37,6 +37,7 @@  #include "llviewerassetupload.h"  class LLTransactionID; +class LLPluginClassMedia;  void init_menu_file(); @@ -71,6 +72,7 @@ void assign_defaults_and_show_upload_message(  	const std::string& display_name,  	std::string& description); +//consider moving all file pickers below to more suitable place  class LLFilePickerThread : public LLThread  { //multi-threaded file picker (runs system specific file picker in background and calls "notify" from main thread)  public: @@ -127,5 +129,17 @@ private:  	file_picked_signal_t*		mFailureSignal;  }; +class LLMediaFilePicker : public LLFilePickerThread +{ +public: +    LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple); +    LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, const std::string &proposed_name); + +    virtual void notify(const std::vector<std::string>& filenames); + +private: +    boost::shared_ptr<LLPluginClassMedia> mPlugin; +}; +  #endif | 
