I need to write a file uploader PPAPI plugin instead of using NPAPI in Chrome.
I extend the hello_nacl_cpp
project in vs_addin
example to test PPAPI and NaCl. The code is similar to this:
...
int32_t showSelectFileDialog() {
pp::CompletionCallbackWithOutput< std::vector<pp::FileRef> > cb =
factory_.NewCallbackWithOutput(&NaClProjectInstance::onFilesSelected);
int32_t ret = file_chooser_.Show(cb);
return ret;
}
void onFilesSelected(int32_t result,
const std::vector<pp::FileRef>& files) {
std::stringstream ss;
if (result == PP_OK) {
// ok
} else {
ss << "undo select file? error code: " << result;
PostMessage(pp::Var(ss.str()));
}
}
...
It's ok if I select PPAPI platform and debug above code. But on NaCl64 platform, the result is PP_ERROR_NO_USER_GESTURE(-41)
. How can I fix this?
/** * This value indicates failure due to lack of a user gesture such as a * mouse click or key input event. Examples of actions requiring a user * gesture are showing the file chooser dialog and going into fullscreen * mode. */ PP_ERROR_NO_USER_GESTURE = -41,
call showSelectFileDialog() in HandleInputEvent