| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 using o3d::Event; | 49 using o3d::Event; |
| 50 | 50 |
| 51 namespace { | 51 namespace { |
| 52 // We would normally make this a stack variable in main(), but in a | 52 // We would normally make this a stack variable in main(), but in a |
| 53 // plugin, that's not possible, so we allocate it dynamically and | 53 // plugin, that's not possible, so we allocate it dynamically and |
| 54 // destroy it explicitly. | 54 // destroy it explicitly. |
| 55 scoped_ptr<base::AtExitManager> g_at_exit_manager; | 55 scoped_ptr<base::AtExitManager> g_at_exit_manager; |
| 56 | 56 |
| 57 bool g_xembed_support = false; | 57 bool g_xembed_support = false; |
| 58 | 58 |
| 59 } // end anonymous namespace | |
| 60 | |
| 61 static void DrawPlugin(PluginObject *obj) { | 59 static void DrawPlugin(PluginObject *obj) { |
| 62 // Limit drawing to no more than once every timer tick. | 60 // Limit drawing to no more than once every timer tick. |
| 63 if (!obj->draw_) return; | 61 if (!obj->draw_) return; |
| 64 obj->client()->RenderClient(); | 62 obj->client()->RenderClient(); |
| 65 obj->draw_ = false; | 63 obj->draw_ = false; |
| 66 } | 64 } |
| 67 | 65 |
| 68 void RenderOnDemandCallbackHandler::Run() { | |
| 69 DrawPlugin(obj_); | |
| 70 } | |
| 71 | |
| 72 // Xt support functions | 66 // Xt support functions |
| 73 | 67 |
| 74 void LinuxTimer(XtPointer data, XtIntervalId* id) { | 68 void LinuxTimer(XtPointer data, XtIntervalId* id) { |
| 75 PluginObject *obj = static_cast<PluginObject *>(data); | 69 PluginObject *obj = static_cast<PluginObject *>(data); |
| 76 DCHECK(obj->xt_interval_ == *id); | 70 DCHECK(obj->xt_interval_ == *id); |
| 77 obj->client()->Tick(); | 71 obj->client()->Tick(); |
| 78 obj->draw_ = true; | 72 obj->draw_ = true; |
| 79 if (obj->client()->render_mode() == o3d::Client::RENDERMODE_CONTINUOUS) { | 73 if (obj->client()->render_mode() == o3d::Client::RENDERMODE_CONTINUOUS) { |
| 80 // NOTE: this draws no matter what instead of just invalidating the region, | 74 // NOTE: this draws no matter what instead of just invalidating the region, |
| 81 // which means it will execute even if the plug-in window is invisible. | 75 // which means it will execute even if the plug-in window is invisible. |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 PluginObject *obj = static_cast<PluginObject *>(user_data); | 563 PluginObject *obj = static_cast<PluginObject *>(user_data); |
| 570 obj->draw_ = true; | 564 obj->draw_ = true; |
| 571 obj->client()->Tick(); | 565 obj->client()->Tick(); |
| 572 if (obj->client()->render_mode() == | 566 if (obj->client()->render_mode() == |
| 573 o3d::Client::RENDERMODE_CONTINUOUS) { | 567 o3d::Client::RENDERMODE_CONTINUOUS) { |
| 574 gtk_widget_queue_draw(obj->gtk_container_); | 568 gtk_widget_queue_draw(obj->gtk_container_); |
| 575 } | 569 } |
| 576 return TRUE; | 570 return TRUE; |
| 577 } | 571 } |
| 578 | 572 |
| 579 bool PluginObject::GetDisplayMode(int id, o3d::DisplayMode *mode) { | |
| 580 return false; | |
| 581 } | |
| 582 | |
| 583 // TODO: Where should this really live? It's platform-specific, but in | |
| 584 // PluginObject, which mainly lives in cross/o3d_glue.h+cc. | |
| 585 bool PluginObject::RequestFullscreenDisplay() { | |
| 586 // TODO: Unimplemented. | |
| 587 return false; | |
| 588 } | |
| 589 | |
| 590 void PluginObject::CancelFullscreenDisplay() { | |
| 591 // TODO: Unimplemented. | |
| 592 } | |
| 593 | |
| 594 NPError PlatformNPPGetValue(NPP instance, NPPVariable variable, void *value) { | 573 NPError PlatformNPPGetValue(NPP instance, NPPVariable variable, void *value) { |
| 595 switch (variable) { | 574 switch (variable) { |
| 596 case NPPVpluginNeedsXEmbed: | 575 case NPPVpluginNeedsXEmbed: |
| 597 *static_cast<NPBool *>(value) = g_xembed_support; | 576 *static_cast<NPBool *>(value) = g_xembed_support; |
| 598 return NPERR_NO_ERROR; | 577 return NPERR_NO_ERROR; |
| 599 default: | 578 default: |
| 600 return NPERR_INVALID_PARAM; | 579 return NPERR_INVALID_PARAM; |
| 601 } | 580 } |
| 602 return NPERR_NO_ERROR; | 581 return NPERR_NO_ERROR; |
| 603 } | 582 } |
| 604 | 583 |
| 584 NPError InitializePlugin() { |
| 585 if (!o3d::SetupOutOfMemoryHandler()) |
| 586 return NPERR_MODULE_LOAD_FAILED_ERROR; |
| 587 |
| 588 // Initialize the AtExitManager so that base singletons can be |
| 589 // destroyed properly. |
| 590 g_at_exit_manager.reset(new base::AtExitManager()); |
| 591 |
| 592 CommandLine::Init(0, NULL); |
| 593 InitLogging("debug.log", |
| 594 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, |
| 595 logging::DONT_LOCK_LOG_FILE, |
| 596 logging::APPEND_TO_OLD_LOG_FILE); |
| 597 |
| 598 DLOG(INFO) << "NP_Initialize"; |
| 599 |
| 600 // Check for XEmbed support in the browser. |
| 601 NPBool xembed_support = 0; |
| 602 NPError err = NPN_GetValue(NULL, NPNVSupportsXEmbedBool, &xembed_support); |
| 603 if (err != NPERR_NO_ERROR) |
| 604 xembed_support = 0; |
| 605 |
| 606 if (xembed_support) { |
| 607 // Check for Gtk2 toolkit support in the browser. |
| 608 NPNToolkitType toolkit = static_cast<NPNToolkitType>(0); |
| 609 err = NPN_GetValue(NULL, NPNVToolkit, &toolkit); |
| 610 if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2) |
| 611 xembed_support = 0; |
| 612 } |
| 613 g_xembed_support = xembed_support != 0; |
| 614 |
| 615 return NPERR_NO_ERROR; |
| 616 } |
| 617 |
| 618 } // end anonymous namespace |
| 619 |
| 620 #if defined(O3D_INTERNAL_PLUGIN) |
| 621 namespace o3d { |
| 622 #else |
| 605 extern "C" { | 623 extern "C" { |
| 606 NPError InitializePlugin() { | 624 #endif |
| 607 if (!o3d::SetupOutOfMemoryHandler()) | 625 |
| 608 return NPERR_MODULE_LOAD_FAILED_ERROR; | 626 NPError OSCALL NP_Initialize(NPNetscapeFuncs *browserFuncs, |
| 609 | 627 NPPluginFuncs *pluginFuncs) { |
| 610 // Initialize the AtExitManager so that base singletons can be | 628 NPError retval = InitializeNPNApi(browserFuncs); |
| 611 // destroyed properly. | 629 if (retval != NPERR_NO_ERROR) return retval; |
| 612 g_at_exit_manager.reset(new base::AtExitManager()); | 630 NP_GetEntryPoints(pluginFuncs); |
| 613 | 631 return InitializePlugin(); |
| 614 CommandLine::Init(0, NULL); | 632 } |
| 615 InitLogging("debug.log", | 633 |
| 616 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, | 634 NPError OSCALL NP_Shutdown(void) { |
| 617 logging::DONT_LOCK_LOG_FILE, | 635 HANDLE_CRASHES; |
| 618 logging::APPEND_TO_OLD_LOG_FILE); | 636 DLOG(INFO) << "NP_Shutdown"; |
| 619 | 637 |
| 620 DLOG(INFO) << "NP_Initialize"; | 638 CommandLine::Terminate(); |
| 621 | 639 |
| 622 // Check for XEmbed support in the browser. | 640 // Force all base singletons to be destroyed. |
| 623 NPBool xembed_support = 0; | 641 g_at_exit_manager.reset(NULL); |
| 624 NPError err = NPN_GetValue(NULL, NPNVSupportsXEmbedBool, &xembed_support); | 642 |
| 625 if (err != NPERR_NO_ERROR) | 643 return NPERR_NO_ERROR; |
| 626 xembed_support = 0; | 644 } |
| 627 | 645 |
| 628 if (xembed_support) { | 646 } // namespace o3d / extern "C" |
| 629 // Check for Gtk2 toolkit support in the browser. | 647 |
| 630 NPNToolkitType toolkit = static_cast<NPNToolkitType>(0); | 648 namespace o3d { |
| 631 err = NPN_GetValue(NULL, NPNVToolkit, &toolkit); | 649 |
| 632 if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2) | 650 void RenderOnDemandCallbackHandler::Run() { |
| 633 xembed_support = 0; | 651 DrawPlugin(obj_); |
| 634 } | 652 } |
| 635 g_xembed_support = xembed_support != 0; | 653 |
| 636 | 654 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, |
| 637 return NPERR_NO_ERROR; | 655 char *argn[], char *argv[], NPSavedData *saved) { |
| 656 HANDLE_CRASHES; |
| 657 |
| 658 PluginObject* pluginObject = glue::_o3d::PluginObject::Create( |
| 659 instance); |
| 660 instance->pdata = pluginObject; |
| 661 glue::_o3d::InitializeGlue(instance); |
| 662 pluginObject->Init(argc, argn, argv); |
| 663 |
| 664 // Get the metrics for the system setup |
| 665 GetUserConfigMetrics(); |
| 666 return NPERR_NO_ERROR; |
| 667 } |
| 668 |
| 669 NPError NPP_Destroy(NPP instance, NPSavedData **save) { |
| 670 HANDLE_CRASHES; |
| 671 PluginObject *obj = static_cast<PluginObject*>(instance->pdata); |
| 672 if (obj) { |
| 673 if (obj->xt_widget_) { |
| 674 // NOTE: This crashes. Not sure why, possibly the widget has |
| 675 // already been destroyed, but we haven't received a SetWindow(NULL). |
| 676 // XtRemoveEventHandler(obj->xt_widget_, ExposureMask, False, |
| 677 // LinuxExposeHandler, obj); |
| 678 obj->xt_widget_ = NULL; |
| 679 } |
| 680 if (obj->xt_interval_) { |
| 681 XtRemoveTimeOut(obj->xt_interval_); |
| 682 obj->xt_interval_ = 0; |
| 683 } |
| 684 if (obj->timeout_id_) { |
| 685 g_source_remove(obj->timeout_id_); |
| 686 obj->timeout_id_ = 0; |
| 687 } |
| 688 if (obj->gtk_container_) { |
| 689 gtk_widget_destroy(obj->gtk_container_); |
| 690 gtk_widget_unref(obj->gtk_container_); |
| 691 obj->gtk_container_ = NULL; |
| 692 } |
| 693 obj->window_ = 0; |
| 694 obj->display_ = NULL; |
| 695 |
| 696 obj->TearDown(); |
| 697 NPN_ReleaseObject(obj); |
| 698 instance->pdata = NULL; |
| 638 } | 699 } |
| 639 | 700 |
| 640 NPError OSCALL NP_Initialize(NPNetscapeFuncs *browserFuncs, | 701 return NPERR_NO_ERROR; |
| 641 NPPluginFuncs *pluginFuncs) { | 702 } |
| 642 NPError retval = InitializeNPNApi(browserFuncs); | 703 |
| 643 if (retval != NPERR_NO_ERROR) return retval; | 704 |
| 644 NP_GetEntryPoints(pluginFuncs); | 705 NPError NPP_SetWindow(NPP instance, NPWindow *window) { |
| 645 return InitializePlugin(); | 706 HANDLE_CRASHES; |
| 707 PluginObject *obj = static_cast<PluginObject*>(instance->pdata); |
| 708 |
| 709 NPSetWindowCallbackStruct *cb_struct = |
| 710 static_cast<NPSetWindowCallbackStruct *>(window->ws_info); |
| 711 Window xwindow = reinterpret_cast<Window>(window->window); |
| 712 if (xwindow != obj->window_) { |
| 713 Display *display = cb_struct->display; |
| 714 Window drawable = xwindow; |
| 715 if (g_xembed_support) { |
| 716 // We asked for a XEmbed plugin, the xwindow is a GtkSocket, we create |
| 717 // a GtkPlug to go into it. |
| 718 obj->gtk_container_ = gtk_plug_new(xwindow); |
| 719 gtk_widget_set_double_buffered(obj->gtk_container_, FALSE); |
| 720 gtk_widget_add_events(obj->gtk_container_, |
| 721 GDK_BUTTON_PRESS_MASK | |
| 722 GDK_BUTTON_RELEASE_MASK | |
| 723 GDK_SCROLL_MASK | |
| 724 GDK_KEY_PRESS_MASK | |
| 725 GDK_KEY_RELEASE_MASK | |
| 726 GDK_POINTER_MOTION_MASK | |
| 727 GDK_EXPOSURE_MASK | |
| 728 GDK_ENTER_NOTIFY_MASK | |
| 729 GDK_LEAVE_NOTIFY_MASK); |
| 730 g_signal_connect(G_OBJECT(obj->gtk_container_), "event", |
| 731 G_CALLBACK(GtkEventCallback), obj); |
| 732 gtk_widget_show(obj->gtk_container_); |
| 733 drawable = GDK_WINDOW_XID(obj->gtk_container_->window); |
| 734 obj->timeout_id_ = g_timeout_add(10, GtkTimeoutCallback, obj); |
| 735 } else { |
| 736 // No XEmbed support, the xwindow is a Xt Widget. |
| 737 Widget widget = XtWindowToWidget(display, xwindow); |
| 738 if (!widget) { |
| 739 DLOG(ERROR) << "window is not a Widget"; |
| 740 return NPERR_MODULE_LOAD_FAILED_ERROR; |
| 741 } |
| 742 obj->xt_widget_ = widget; |
| 743 XtAddEventHandler(widget, ExposureMask, 0, LinuxExposeHandler, obj); |
| 744 XtAddEventHandler(widget, KeyPressMask|KeyReleaseMask, 0, |
| 745 LinuxKeyHandler, obj); |
| 746 XtAddEventHandler(widget, ButtonPressMask|ButtonReleaseMask, 0, |
| 747 LinuxMouseButtonHandler, obj); |
| 748 XtAddEventHandler(widget, PointerMotionMask, 0, |
| 749 LinuxMouseMoveHandler, obj); |
| 750 XtAddEventHandler(widget, EnterWindowMask|LeaveWindowMask, 0, |
| 751 LinuxEnterLeaveHandler, obj); |
| 752 obj->xt_app_context_ = XtWidgetToApplicationContext(widget); |
| 753 obj->xt_interval_ = |
| 754 XtAppAddTimeOut(obj->xt_app_context_, 10, LinuxTimer, obj); |
| 755 } |
| 756 |
| 757 // Create and assign the graphics context. |
| 758 o3d::DisplayWindowLinux default_display; |
| 759 default_display.set_display(display); |
| 760 default_display.set_window(drawable); |
| 761 |
| 762 obj->CreateRenderer(default_display); |
| 763 obj->client()->Init(); |
| 764 obj->client()->SetRenderOnDemandCallback( |
| 765 new RenderOnDemandCallbackHandler(obj)); |
| 766 obj->display_ = display; |
| 767 obj->window_ = xwindow; |
| 646 } | 768 } |
| 647 | 769 obj->Resize(window->width, window->height); |
| 648 NPError OSCALL NP_Shutdown(void) { | 770 |
| 649 HANDLE_CRASHES; | 771 return NPERR_NO_ERROR; |
| 650 DLOG(INFO) << "NP_Shutdown"; | 772 } |
| 651 | 773 |
| 652 CommandLine::Terminate(); | 774 // Called when the browser has finished attempting to stream data to |
| 653 | 775 // a file as requested. If fname == NULL the attempt was not successful. |
| 654 // Force all base singletons to be destroyed. | 776 void NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname) { |
| 655 g_at_exit_manager.reset(NULL); | 777 HANDLE_CRASHES; |
| 656 | 778 PluginObject *obj = static_cast<PluginObject*>(instance->pdata); |
| 657 return NPERR_NO_ERROR; | 779 StreamManager *stream_manager = obj->stream_manager(); |
| 658 } | 780 |
| 659 | 781 stream_manager->SetStreamFile(stream, fname); |
| 660 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, | 782 } |
| 661 char *argn[], char *argv[], NPSavedData *saved) { | 783 |
| 662 HANDLE_CRASHES; | 784 int16 NPP_HandleEvent(NPP instance, void *event) { |
| 663 | 785 HANDLE_CRASHES; |
| 664 PluginObject* pluginObject = glue::_o3d::PluginObject::Create( | 786 return 0; |
| 665 instance); | 787 } |
| 666 instance->pdata = pluginObject; | 788 } // namespace o3d |
| 667 glue::_o3d::InitializeGlue(instance); | 789 |
| 668 pluginObject->Init(argc, argn, argv); | 790 namespace glue { |
| 669 | 791 namespace _o3d { |
| 670 // Get the metrics for the system setup | 792 |
| 671 GetUserConfigMetrics(); | 793 bool PluginObject::GetDisplayMode(int id, o3d::DisplayMode *mode) { |
| 672 return NPERR_NO_ERROR; | 794 return false; |
| 673 } | 795 } |
| 674 | 796 |
| 675 NPError NPP_Destroy(NPP instance, NPSavedData **save) { | 797 // TODO: Where should this really live? It's platform-specific, but in |
| 676 HANDLE_CRASHES; | 798 // PluginObject, which mainly lives in cross/o3d_glue.h+cc. |
| 677 PluginObject *obj = static_cast<PluginObject*>(instance->pdata); | 799 bool PluginObject::RequestFullscreenDisplay() { |
| 678 if (obj) { | 800 // TODO: Unimplemented. |
| 679 if (obj->xt_widget_) { | 801 return false; |
| 680 // NOTE: This crashes. Not sure why, possibly the widget has | 802 } |
| 681 // already been destroyed, but we haven't received a SetWindow(NULL). | 803 |
| 682 // XtRemoveEventHandler(obj->xt_widget_, ExposureMask, False, | 804 void PluginObject::CancelFullscreenDisplay() { |
| 683 // LinuxExposeHandler, obj); | 805 // TODO: Unimplemented. |
| 684 obj->xt_widget_ = NULL; | 806 } |
| 685 } | 807 } // namespace _o3d |
| 686 if (obj->xt_interval_) { | 808 } // namespace glue |
| 687 XtRemoveTimeOut(obj->xt_interval_); | |
| 688 obj->xt_interval_ = 0; | |
| 689 } | |
| 690 if (obj->timeout_id_) { | |
| 691 g_source_remove(obj->timeout_id_); | |
| 692 obj->timeout_id_ = 0; | |
| 693 } | |
| 694 if (obj->gtk_container_) { | |
| 695 gtk_widget_destroy(obj->gtk_container_); | |
| 696 gtk_widget_unref(obj->gtk_container_); | |
| 697 obj->gtk_container_ = NULL; | |
| 698 } | |
| 699 obj->window_ = 0; | |
| 700 obj->display_ = NULL; | |
| 701 | |
| 702 obj->TearDown(); | |
| 703 NPN_ReleaseObject(obj); | |
| 704 instance->pdata = NULL; | |
| 705 } | |
| 706 | |
| 707 return NPERR_NO_ERROR; | |
| 708 } | |
| 709 | |
| 710 | |
| 711 NPError NPP_SetWindow(NPP instance, NPWindow *window) { | |
| 712 HANDLE_CRASHES; | |
| 713 PluginObject *obj = static_cast<PluginObject*>(instance->pdata); | |
| 714 | |
| 715 NPSetWindowCallbackStruct *cb_struct = | |
| 716 static_cast<NPSetWindowCallbackStruct *>(window->ws_info); | |
| 717 Window xwindow = reinterpret_cast<Window>(window->window); | |
| 718 if (xwindow != obj->window_) { | |
| 719 Display *display = cb_struct->display; | |
| 720 Window drawable = xwindow; | |
| 721 if (g_xembed_support) { | |
| 722 // We asked for a XEmbed plugin, the xwindow is a GtkSocket, we create | |
| 723 // a GtkPlug to go into it. | |
| 724 obj->gtk_container_ = gtk_plug_new(xwindow); | |
| 725 gtk_widget_set_double_buffered(obj->gtk_container_, FALSE); | |
| 726 gtk_widget_add_events(obj->gtk_container_, | |
| 727 GDK_BUTTON_PRESS_MASK | | |
| 728 GDK_BUTTON_RELEASE_MASK | | |
| 729 GDK_SCROLL_MASK | | |
| 730 GDK_KEY_PRESS_MASK | | |
| 731 GDK_KEY_RELEASE_MASK | | |
| 732 GDK_POINTER_MOTION_MASK | | |
| 733 GDK_EXPOSURE_MASK | | |
| 734 GDK_ENTER_NOTIFY_MASK | | |
| 735 GDK_LEAVE_NOTIFY_MASK); | |
| 736 g_signal_connect(G_OBJECT(obj->gtk_container_), "event", | |
| 737 G_CALLBACK(GtkEventCallback), obj); | |
| 738 gtk_widget_show(obj->gtk_container_); | |
| 739 drawable = GDK_WINDOW_XID(obj->gtk_container_->window); | |
| 740 obj->timeout_id_ = g_timeout_add(10, GtkTimeoutCallback, obj); | |
| 741 } else { | |
| 742 // No XEmbed support, the xwindow is a Xt Widget. | |
| 743 Widget widget = XtWindowToWidget(display, xwindow); | |
| 744 if (!widget) { | |
| 745 DLOG(ERROR) << "window is not a Widget"; | |
| 746 return NPERR_MODULE_LOAD_FAILED_ERROR; | |
| 747 } | |
| 748 obj->xt_widget_ = widget; | |
| 749 XtAddEventHandler(widget, ExposureMask, 0, LinuxExposeHandler, obj); | |
| 750 XtAddEventHandler(widget, KeyPressMask|KeyReleaseMask, 0, | |
| 751 LinuxKeyHandler, obj); | |
| 752 XtAddEventHandler(widget, ButtonPressMask|ButtonReleaseMask, 0, | |
| 753 LinuxMouseButtonHandler, obj); | |
| 754 XtAddEventHandler(widget, PointerMotionMask, 0, | |
| 755 LinuxMouseMoveHandler, obj); | |
| 756 XtAddEventHandler(widget, EnterWindowMask|LeaveWindowMask, 0, | |
| 757 LinuxEnterLeaveHandler, obj); | |
| 758 obj->xt_app_context_ = XtWidgetToApplicationContext(widget); | |
| 759 obj->xt_interval_ = | |
| 760 XtAppAddTimeOut(obj->xt_app_context_, 10, LinuxTimer, obj); | |
| 761 } | |
| 762 | |
| 763 // Create and assign the graphics context. | |
| 764 o3d::DisplayWindowLinux default_display; | |
| 765 default_display.set_display(display); | |
| 766 default_display.set_window(drawable); | |
| 767 | |
| 768 obj->CreateRenderer(default_display); | |
| 769 obj->client()->Init(); | |
| 770 obj->client()->SetRenderOnDemandCallback( | |
| 771 new RenderOnDemandCallbackHandler(obj)); | |
| 772 obj->display_ = display; | |
| 773 obj->window_ = xwindow; | |
| 774 } | |
| 775 obj->Resize(window->width, window->height); | |
| 776 | |
| 777 return NPERR_NO_ERROR; | |
| 778 } | |
| 779 | |
| 780 // Called when the browser has finished attempting to stream data to | |
| 781 // a file as requested. If fname == NULL the attempt was not successful. | |
| 782 void NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname) { | |
| 783 HANDLE_CRASHES; | |
| 784 PluginObject *obj = static_cast<PluginObject*>(instance->pdata); | |
| 785 StreamManager *stream_manager = obj->stream_manager(); | |
| 786 | |
| 787 stream_manager->SetStreamFile(stream, fname); | |
| 788 } | |
| 789 | |
| 790 int16 NPP_HandleEvent(NPP instance, void *event) { | |
| 791 HANDLE_CRASHES; | |
| 792 return 0; | |
| 793 } | |
| 794 }; // end extern "C" | |
| OLD | NEW |