Skip to content

Commit

Permalink
npapi: log NPN failures
Browse files Browse the repository at this point in the history
  • Loading branch information
i-rinat committed Dec 10, 2017
1 parent f2251ca commit 246d712
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/n2p_proxy_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ n2p_call_ptac(void *param)

p->result = var;
} else {
trace_error("%s, NPN_Invoke failed (or there were no npp)\n", __func__);
p->result = PP_MakeUndefined();
}

Expand Down
37 changes: 29 additions & 8 deletions src/np_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ NPP_SetWindow(NPP npp, NPWindow *window)
pp_i->clip_rect.top = window->clipRect.top;
pp_i->clip_rect.bottom = window->clipRect.bottom;

if (npn.getvalue(pp_i->npp, NPNVnetscapeWindow, &pp_i->browser_wnd) != NPERR_NO_ERROR)
if (npn.getvalue(pp_i->npp, NPNVnetscapeWindow, &pp_i->browser_wnd) != NPERR_NO_ERROR) {
pp_i->browser_wnd = None;
trace_error("%s, failed to get NPNVnetscapeWindow\n", __func__);
}

if (pp_i->windowed_mode) {
pp_i->wnd = x11et_register_window(pp_i->id, (Window)window->window, NPP_HandleEvent,
Expand Down Expand Up @@ -428,7 +430,11 @@ NPP_New(NPMIMEType pluginType, NPP npp, uint16_t mode, int16_t argc, char *argn[

if (config.quirks.plugin_missing) {
trace_info_z("plugin missing, using placeholder\n");
npn.setvalue(npp, NPPVpluginWindowBool, (void*)0); // ask windowsless mode

// ask windowsless mode
if (npn.setvalue(npp, NPPVpluginWindowBool, (void*)0) != NPERR_NO_ERROR)
trace_error("%s, failed to set NPPVpluginWindowBool\n", __func__);

return NPERR_NO_ERROR;
}

Expand Down Expand Up @@ -478,21 +484,30 @@ NPP_New(NPMIMEType pluginType, NPP npp, uint16_t mode, int16_t argc, char *argn[

if (pp_i->windowed_mode) {
// ask windowed mode
npn.setvalue(npp, NPPVpluginWindowBool, (void*)1);
if (npn.setvalue(npp, NPPVpluginWindowBool, (void*)1) != NPERR_NO_ERROR)
trace_error("%s, failed to set NPPVpluginWindowBool\n", __func__);

} else {
// ask windowsless mode
npn.setvalue(npp, NPPVpluginWindowBool, (void*)0);
if (npn.setvalue(npp, NPPVpluginWindowBool, (void*)0) != NPERR_NO_ERROR)
trace_error("%s, failed to set NPPVpluginWindowBool\n", __func__);
}

// determine whenever XEmbed is used
NPBool browser_supports_xembed = false;
npn.getvalue(npp, NPNVSupportsXEmbedBool, &browser_supports_xembed);
if (npn.getvalue(npp, NPNVSupportsXEmbedBool, &browser_supports_xembed) != NPERR_NO_ERROR)
trace_error("%s, failed to get NPNVSupportsXEmbedBool\n", __func__);

pp_i->use_xembed = browser_supports_xembed && config.enable_xembed;
trace_info_f(" XEmbed is %s\n", browser_supports_xembed ? "supported" : "not supported");
trace_info_f(" XEmbed is %s\n", pp_i->use_xembed ? "used" : "not used");

// set transparency mode
npn.setvalue(npp, NPPVpluginTransparentBool, (void*)(size_t)pp_i->is_transparent);
if (npn.setvalue(npp, NPPVpluginTransparentBool,
(void *)(size_t)pp_i->is_transparent) != NPERR_NO_ERROR)
{
trace_error("%s, failed to set NPPVpluginTransparentBool\n", __func__);
}

pp_i->is_fullframe = (mode == NP_FULL);
pp_i->id = tables_generate_new_pp_instance_id();
Expand All @@ -501,8 +516,12 @@ NPP_New(NPMIMEType pluginType, NPP npp, uint16_t mode, int16_t argc, char *argn[
pp_i->incognito_mode = 0;
if (npn.version >= NPVERS_HAS_PRIVATE_MODE) {
NPBool private = false;
if (npn.getvalue(pp_i->npp, NPNVprivateModeBool, &private) == NPERR_NO_ERROR)
if (npn.getvalue(pp_i->npp, NPNVprivateModeBool, &private) == NPERR_NO_ERROR) {
pp_i->incognito_mode = private ? 1 : 0;
} else {
// Not an error, actually. Browser can have no support for that variable.
trace_info_f("%s, failed to get NPNVprivateModeBool\n", __func__);
}
}

do {
Expand Down Expand Up @@ -1537,8 +1556,10 @@ handle_key_press_release_event(NPP npp, void *event)

if (pp_i->im_context && ev->type == KeyPress) {
Window browser_window;
if (npn.getvalue(npp, NPNVnetscapeWindow, &browser_window) != NPERR_NO_ERROR)
if (npn.getvalue(npp, NPNVnetscapeWindow, &browser_window) != NPERR_NO_ERROR) {
trace_error("%s, failed to get NPNVnetscapeWindow\n", __func__);
browser_window = None;
}
ev->window = browser_window;

pthread_mutex_lock(&display.lock);
Expand Down
5 changes: 4 additions & 1 deletion src/ppb_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ update_instance_playing_audio_status_ptac(void *p)
return;

int is_playing_audio = g_atomic_int_get(&pp_i->audio_source_count) > 0;
npn.setvalue(pp_i->npp, NPPVpluginIsPlayingAudio, GINT_TO_POINTER(is_playing_audio));
NPError err = npn.setvalue(pp_i->npp, NPPVpluginIsPlayingAudio,
GINT_TO_POINTER(is_playing_audio));
if (err != NPERR_NO_ERROR)
trace_info_f("%s, failed to set NPPVpluginIsPlayingAudio\n", __func__);
}

PP_Bool
Expand Down
4 changes: 3 additions & 1 deletion src/ppb_cursor_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ set_cursor_ptac(void *user_data)
} else if (pp_i->windowed_mode) {
wnd = pp_i->wnd;
} else {
if (npn.getvalue(pp_i->npp, NPNVnetscapeWindow, &wnd) != NPERR_NO_ERROR)
if (npn.getvalue(pp_i->npp, NPNVnetscapeWindow, &wnd) != NPERR_NO_ERROR) {
trace_error("%s, failed to get NPNnetscapeWindow\n", __func__);
wnd = None;
}
}

pthread_mutex_lock(&display.lock);
Expand Down
2 changes: 1 addition & 1 deletion src/ppb_file_chooser.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ show_without_user_guesture_ptac(void *param)
GDK_WINDOW_XID(fcd_wnd),
parent_wnd);
} else {
trace_warning("%s, can't get NPNVnetscapeWindow", __func__);
trace_error("%s, failed to get NPNVnetscapeWindow\n", __func__);
}

g_signal_connect(G_OBJECT(fcd), "response", G_CALLBACK(fcd_response_handler), p);
Expand Down
10 changes: 8 additions & 2 deletions src/ppb_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ get_proxy_for_url_ptac(void *user_data)
err = npn.getvalueforurl(pp_i->npp, NPNURLVProxy, p->url, &value, &len);
if (err == NPERR_NO_ERROR) {
p->result = ppb_var_var_from_utf8(value, len);
} else {
trace_info_f("%s, failed to get NPNURLVProxy, code %d\n", __func__, err);
}
}

Expand Down Expand Up @@ -269,8 +271,10 @@ topmost_rect_ptac(void *param)
"})");
NPVariant topmost_func;

if (!npn.evaluate(pp_i->npp, pp_i->np_window_obj, &topmost_func_src, &topmost_func))
if (!npn.evaluate(pp_i->npp, pp_i->np_window_obj, &topmost_func_src, &topmost_func)) {
trace_error("%s, NPN_Evaluate failed\n", __func__);
goto err_1;
}

if (!NPVARIANT_IS_OBJECT(topmost_func))
goto err_1;
Expand All @@ -284,8 +288,10 @@ topmost_rect_ptac(void *param)
INT32_TO_NPVARIANT(p->rect.point.x + p->rect.size.width / 2, args[1]);
INT32_TO_NPVARIANT(p->rect.point.y + p->rect.size.height / 2, args[2]);

if (!npn.invokeDefault(pp_i->npp, topmost_func_obj, args, 3, &is_topmost))
if (!npn.invokeDefault(pp_i->npp, topmost_func_obj, args, 3, &is_topmost)) {
trace_error("%s, NPN_InvokeDefault failed\n", __func__);
goto err_2;
}

if (!NPVARIANT_IS_BOOLEAN(is_topmost))
goto err_3;
Expand Down
4 changes: 3 additions & 1 deletion src/ppb_flash_fullscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ get_browser_window(void *p)
{
struct thread_param_s *tp = p;

if (npn.getvalue(tp->pp_i->npp, NPNVnetscapeWindow, &tp->browser_window) != NPERR_NO_ERROR)
if (npn.getvalue(tp->pp_i->npp, NPNVnetscapeWindow, &tp->browser_window) != NPERR_NO_ERROR) {
tp->browser_window = None;
trace_error("%s, failed to get NPNVnetscapeWindow\n", __func__);
}

pthread_barrier_wait(&cross_thread_call_barrier);
}
Expand Down
9 changes: 9 additions & 0 deletions src/ppb_url_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,14 @@ url_loader_open_ptac(void *user_data)

if (p->target) {
p->retval = npn.posturl(pp_i->npp, p->url, p->target, strlen(tmpfname), tmpfname, true);
if (p->retval != NPERR_NO_ERROR)
trace_error("%s, NPN_PostURL returned %d\n", __func__, p->retval);

} else {
p->retval = npn.posturlnotify(pp_i->npp, p->url, NULL, strlen(tmpfname), tmpfname, true,
(void*)(size_t)p->loader);
if (p->retval != NPERR_NO_ERROR)
trace_error("%s, NPN_PostURLNotify returned %d\n", __func__, p->retval);
}
err:
if (fp)
Expand All @@ -216,8 +221,12 @@ url_loader_open_ptac(void *user_data)
// GET request
if (p->target) {
p->retval = npn.geturl(pp_i->npp, p->url, p->target);
if (p->retval != NPERR_NO_ERROR)
trace_warning("%s, NPN_GetUrl returned %d\n", __func__, p->retval);
} else {
p->retval = npn.geturlnotify(pp_i->npp, p->url, NULL, (void*)(size_t)p->loader);
if (p->retval != NPERR_NO_ERROR)
trace_warning("%s, NPN_GetUrlNotify returned %d\n", __func__, p->retval);
}
}

Expand Down

0 comments on commit 246d712

Please sign in to comment.