From 13daa302c065ab83898204f98e0964127da0e551 Mon Sep 17 00:00:00 2001 From: "dmaclach@chromium.org" Date: Tue, 24 May 2011 20:37:58 +0000 Subject: Negotiate Mac event and drawing model support This will help performance on our main thread, and will future proof us. BUG=NONE TEST=BUILD Review URL: http://codereview.chromium.org/6992033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86478 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/host/host_plugin.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'remoting') diff --git a/remoting/host/host_plugin.cc b/remoting/host/host_plugin.cc index 371d91f..4713d6b 100644 --- a/remoting/host/host_plugin.cc +++ b/remoting/host/host_plugin.cc @@ -595,6 +595,44 @@ class HostNPPlugin { } bool Init(int16 argc, char** argn, char** argv, NPSavedData* saved) { +#if defined(OS_MACOSX) + // Use the modern CoreGraphics and Cocoa models when available, since + // QuickDraw and Carbon are deprecated. + // The drawing and event models don't change anything for this plugin, since + // none of the functions affected by the models actually do anything. + // This does however keep the plugin from breaking when Chromium eventually + // drops support for QuickDraw and Carbon, and it also keeps the browser + // from sending Null Events once a second to support old Carbon based + // timers. + // Chromium should always be supporting the newer models. + + // Sanity check to see if Chromium supports the CoreGraphics drawing model. + NPBool supports_core_graphics = false; + NPError err = g_npnetscape_funcs->getvalue(instance_, + NPNVsupportsCoreGraphicsBool, + &supports_core_graphics); + if (err == NPERR_NO_ERROR && supports_core_graphics) { + // Switch to CoreGraphics drawing model. + g_npnetscape_funcs->setvalue(instance_, NPPVpluginDrawingModel, + reinterpret_cast(NPDrawingModelCoreGraphics)); + } else { + LOG(ERROR) << "No Core Graphics support"; + return false; + } + + // Sanity check to see if Chromium supports the Cocoa event model. + NPBool supports_cocoa = false; + err = g_npnetscape_funcs->getvalue(instance_, NPNVsupportsCocoaBool, + &supports_cocoa); + if (err == NPERR_NO_ERROR && supports_cocoa) { + // Switch to Cocoa event model. + g_npnetscape_funcs->setvalue(instance_, NPPVpluginEventModel, + reinterpret_cast(NPEventModelCocoa)); + } else { + LOG(ERROR) << "No Cocoa Event Model support"; + return false; + } +#endif // OS_MACOSX return true; } -- cgit v1.1