[embedlite-components] support filepicker filter

parent e4243a5d
......@@ -41,12 +41,14 @@ NS_IMETHODIMP nsEmbedFilePicker::Init(nsIDOMWindow* parent, const nsAString& tit
mDefaultName.Truncate();
mMode = mode;
mCallback = nullptr;
mFilterIndex = 0;
mFilters.clear();
return NS_OK;
}
NS_IMETHODIMP nsEmbedFilePicker::AppendFilters(int32_t filterMask)
{
printf("nsEmbedFilePicker::AppendFilters NOT USED: filterMask:%i\n", filterMask);
mFilters.push_back(filterMask);
return NS_OK;
}
......@@ -88,7 +90,7 @@ NS_IMETHODIMP nsEmbedFilePicker::GetFilterIndex(int32_t* aFilterIndex)
NS_IMETHODIMP nsEmbedFilePicker::SetFilterIndex(int32_t aFilterIndex)
{
printf("nsEmbedFilePicker::SetFilterIndex NOT USED: aFilterIndex:%i\n", aFilterIndex);
mFilterIndex = aFilterIndex;
return NS_OK;
}
......@@ -251,6 +253,9 @@ nsEmbedFilePicker::DoSendPrompt()
root->SetPropertyAsUint32(NS_LITERAL_STRING("winid"), winid);
root->SetPropertyAsUint32(NS_LITERAL_STRING("mode"), mMode);
root->SetPropertyAsAString(NS_LITERAL_STRING("title"), mTitle);
if (mFilters.size() > 0 && mFilterIndex > -1 && (unsigned)mFilterIndex < mFilters.size()) {
root->SetPropertyAsUint32(NS_LITERAL_STRING("filter"), mFilters.at(mFilterIndex));
}
root->SetPropertyAsAString(NS_LITERAL_STRING("name"), mDefaultName);
json->CreateJSON(root, sendString);
......
......@@ -14,6 +14,7 @@
#include "nsCOMPtr.h"
#include <map>
#include <string>
#include <vector>
class EmbedFilePickerResponse
{
......@@ -42,12 +43,14 @@ private:
EmbedFilePickerResponse GetResponse();
int mModalDepth;
int mMode;
int mFilterIndex;
nsCOMPtr<nsIEmbedAppService> mService;
nsCOMPtr<nsIDOMWindow> mWin;
nsString mTitle;
nsString mDefaultName;
nsCOMPtr<nsIFilePickerShownCallback> mCallback;
std::map<uint32_t, EmbedFilePickerResponse> mResponseMap;
std::vector<uint32_t> mFilters;
};
#define NS_EMBED_FILEPICKER_SERVICE_CID \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment