From d314a1e24e31a920894a5415e13b406d769d7ab4 Mon Sep 17 00:00:00 2001 From: "michaelp%netscape.com" Date: Sun, 22 Nov 1998 00:22:35 +0000 Subject: [PATCH] changed UserAgent string reporting. --- modules/plugin/base/src/nsPluginHostImpl.cpp | 39 +++++++++++++++----- modules/plugin/nglsrc/nsPluginHostImpl.cpp | 39 +++++++++++++++----- 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index fe1614b3c390..68796620ee31 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -37,6 +37,14 @@ #include "winbase.h" #endif +//uncomment this to use netlib to determine what the +//user agent string is. we really *want* to do this, +//can't today since netlib returns 4.05, but this +//version of plugin functionality really supports +//5.0 level features. once netlib is returning +//5.0x, then we can turn this on again. MMP +//#define USE_NETLIB_FOR_USER_AGENT + static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID); static NS_DEFINE_IID(kIPluginInstancePeerIID, NS_IPLUGININSTANCEPEER_IID); static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID); @@ -696,20 +704,31 @@ nsresult nsPluginHostImpl :: ReloadPlugins(PRBool reloadPages) nsresult nsPluginHostImpl :: UserAgent(const char **retstring) { + nsresult res; + +#ifdef USE_NETLIB_FOR_USER_AGENT nsString ua; nsINetService *service = nsnull; - nsresult res = nsServiceManager::GetService(kNetServiceCID, - kINetServiceIID, - (nsISupports **)&service); - if ((NS_OK == res) && (nsnull != service)) { - res = service->GetUserAgent(ua); - if (NS_OK == res) - *retstring = ua.ToNewCString(); - else - *retstring = nsnull; - NS_RELEASE(service); + res = nsServiceManager::GetService(kNetServiceCID, + kINetServiceIID, + (nsISupports **)&service); + if ((NS_OK == res) && (nsnull != service)) + { + res = service->GetUserAgent(ua); + + if (NS_OK == res) + *retstring = ua.ToNewCString(); + else + *retstring = nsnull; + + NS_RELEASE(service); } +#else + *retstring = (const char *)"Mozilla/5.0 [en] (Windows;I)"; + res = NS_OK; +#endif + return res; } diff --git a/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/modules/plugin/nglsrc/nsPluginHostImpl.cpp index fe1614b3c390..68796620ee31 100644 --- a/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -37,6 +37,14 @@ #include "winbase.h" #endif +//uncomment this to use netlib to determine what the +//user agent string is. we really *want* to do this, +//can't today since netlib returns 4.05, but this +//version of plugin functionality really supports +//5.0 level features. once netlib is returning +//5.0x, then we can turn this on again. MMP +//#define USE_NETLIB_FOR_USER_AGENT + static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID); static NS_DEFINE_IID(kIPluginInstancePeerIID, NS_IPLUGININSTANCEPEER_IID); static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID); @@ -696,20 +704,31 @@ nsresult nsPluginHostImpl :: ReloadPlugins(PRBool reloadPages) nsresult nsPluginHostImpl :: UserAgent(const char **retstring) { + nsresult res; + +#ifdef USE_NETLIB_FOR_USER_AGENT nsString ua; nsINetService *service = nsnull; - nsresult res = nsServiceManager::GetService(kNetServiceCID, - kINetServiceIID, - (nsISupports **)&service); - if ((NS_OK == res) && (nsnull != service)) { - res = service->GetUserAgent(ua); - if (NS_OK == res) - *retstring = ua.ToNewCString(); - else - *retstring = nsnull; - NS_RELEASE(service); + res = nsServiceManager::GetService(kNetServiceCID, + kINetServiceIID, + (nsISupports **)&service); + if ((NS_OK == res) && (nsnull != service)) + { + res = service->GetUserAgent(ua); + + if (NS_OK == res) + *retstring = ua.ToNewCString(); + else + *retstring = nsnull; + + NS_RELEASE(service); } +#else + *retstring = (const char *)"Mozilla/5.0 [en] (Windows;I)"; + res = NS_OK; +#endif + return res; }