r=jst. 30067. we now expose OSCPU, vendor and product attributes of the user agent string through the JS navigator object.

This commit is contained in:
valeski%netscape.com 2000-03-21 22:39:54 +00:00
Родитель e34b119ffa
Коммит d4b0de78fc
6 изменённых файлов: 185 добавлений и 4 удалений

Просмотреть файл

@ -52,6 +52,16 @@ public:
NS_IMETHOD GetPlatform(nsString& aPlatform)=0;
NS_IMETHOD GetOscpu(nsString& aOSCPU)=0;
NS_IMETHOD GetVendor(nsString& aVendor)=0;
NS_IMETHOD GetVendorSub(nsString& aVendorSub)=0;
NS_IMETHOD GetProduct(nsString& aProduct)=0;
NS_IMETHOD GetProductSub(nsString& aProductSub)=0;
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins)=0;
NS_IMETHOD GetSecurityPolicy(nsString& aSecurityPolicy)=0;
@ -75,6 +85,11 @@ public:
NS_IMETHOD GetLanguage(nsString& aLanguage); \
NS_IMETHOD GetMimeTypes(nsIDOMMimeTypeArray** aMimeTypes); \
NS_IMETHOD GetPlatform(nsString& aPlatform); \
NS_IMETHOD GetOscpu(nsString& aOSCPU); \
NS_IMETHOD GetVendor(nsString& aVendor); \
NS_IMETHOD GetVendorSub(nsString& aVendorSub); \
NS_IMETHOD GetProduct(nsString& aProduct); \
NS_IMETHOD GetProductSub(nsString& aProductSub); \
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins); \
NS_IMETHOD GetSecurityPolicy(nsString& aSecurityPolicy); \
NS_IMETHOD GetUserAgent(nsString& aUserAgent); \
@ -92,6 +107,11 @@ public:
NS_IMETHOD GetLanguage(nsString& aLanguage) { return _to GetLanguage(aLanguage); } \
NS_IMETHOD GetMimeTypes(nsIDOMMimeTypeArray** aMimeTypes) { return _to GetMimeTypes(aMimeTypes); } \
NS_IMETHOD GetPlatform(nsString& aPlatform) { return _to GetPlatform(aPlatform); } \
NS_IMETHOD GetOscpu(nsString& aOSCPU) { return _to GetOscpu(aOSCPU); } \
NS_IMETHOD GetVendor(nsString& aVendor) { return _to GetVendor(aVendor); }\
NS_IMETHOD GetVendorSub(nsString& aVendorSub) { return _to GetVendorSub(aVendorSub); } \
NS_IMETHOD GetProduct(nsString& aProduct) { return _to GetProduct(aProduct); } \
NS_IMETHOD GetProductSub(nsString& aProductSub) { return _to GetProductSub(aProductSub); } \
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins) { return _to GetPlugins(aPlugins); } \
NS_IMETHOD GetSecurityPolicy(nsString& aSecurityPolicy) { return _to GetSecurityPolicy(aSecurityPolicy); } \
NS_IMETHOD GetUserAgent(nsString& aUserAgent) { return _to GetUserAgent(aUserAgent); } \

Просмотреть файл

@ -8,6 +8,11 @@ interface Navigator {
readonly attribute DOMString language;
readonly attribute MimeTypeArray mimeTypes;
readonly attribute DOMString platform;
readonly attribute DOMString oscpu;
readonly attribute DOMString vendor;
readonly attribute DOMString vendorSub;
readonly attribute DOMString product;
readonly attribute DOMString productSub;
readonly attribute PluginArray plugins;
readonly attribute DOMString securityPolicy;
readonly attribute DOMString userAgent;

Просмотреть файл

@ -652,6 +652,11 @@ enum nsDOMProp {
NS_DOM_PROP_NAVIGATOR_LANGUAGE,
NS_DOM_PROP_NAVIGATOR_MIMETYPES,
NS_DOM_PROP_NAVIGATOR_PLATFORM,
NS_DOM_PROP_NAVIGATOR_VENDOR,
NS_DOM_PROP_NAVIGATOR_VENDORSUB,
NS_DOM_PROP_NAVIGATOR_PRODUCT,
NS_DOM_PROP_NAVIGATOR_PRODUCTSUB,
NS_DOM_PROP_NAVIGATOR_OSCPU,
NS_DOM_PROP_NAVIGATOR_PLUGINS,
NS_DOM_PROP_NAVIGATOR_PREFERENCE,
NS_DOM_PROP_NAVIGATOR_SECURITYPOLICY,

Просмотреть файл

@ -651,6 +651,11 @@
"navigator.language", \
"navigator.mimetypes", \
"navigator.platform", \
"navigator.oscpu", \
"navigator.vendor", \
"navigator.vendorSub", \
"navigator.product", \
"navigator.productSub", \
"navigator.plugins", \
"navigator.preference", \
"navigator.securitypolicy", \

Просмотреть файл

@ -3724,6 +3724,82 @@ NS_IMETHODIMP NavigatorImpl::GetPlatform(nsString& aPlatform)
return res;
}
NS_IMETHODIMP NavigatorImpl::GetOscpu(nsString& aOSCPU)
{
nsresult res;
nsCOMPtr<nsIHTTPProtocolHandler> service(do_GetService(kHTTPHandlerCID, &res));
if (NS_SUCCEEDED(res) && (nsnull != service))
{
PRUnichar *oscpu = nsnull;
res = service->GetOscpu(&oscpu);
aOSCPU = oscpu;
Recycle(oscpu);
}
return res;
}
NS_IMETHODIMP NavigatorImpl::GetVendor(nsString& aVendor)
{
nsresult res;
nsCOMPtr<nsIHTTPProtocolHandler> service(do_GetService(kHTTPHandlerCID, &res));
if (NS_SUCCEEDED(res) && (nsnull != service))
{
PRUnichar *vendor = nsnull;
res = service->GetVendor(&vendor);
aVendor = vendor;
Recycle(vendor);
}
return res;
}
NS_IMETHODIMP NavigatorImpl::GetVendorSub(nsString& aVendorSub)
{
nsresult res;
nsCOMPtr<nsIHTTPProtocolHandler> service(do_GetService(kHTTPHandlerCID, &res));
if (NS_SUCCEEDED(res) && (nsnull != service))
{
PRUnichar *vendor = nsnull;
res = service->GetVendorSub(&vendor);
aVendorSub = vendor;
Recycle(vendor);
}
return res;
}
NS_IMETHODIMP NavigatorImpl::GetProduct(nsString& aProduct)
{
nsresult res;
nsCOMPtr<nsIHTTPProtocolHandler> service(do_GetService(kHTTPHandlerCID, &res));
if (NS_SUCCEEDED(res) && (nsnull != service))
{
PRUnichar *product = nsnull;
res = service->GetProduct(&product);
aProduct = product;
Recycle(product);
}
return res;
}
NS_IMETHODIMP NavigatorImpl::GetProductSub(nsString& aProductSub)
{
nsresult res;
nsCOMPtr<nsIHTTPProtocolHandler> service(do_GetService(kHTTPHandlerCID, &res));
if (NS_SUCCEEDED(res) && (nsnull != service))
{
PRUnichar *productSub = nsnull;
res = service->GetProductSub(&productSub);
aProductSub = productSub;
Recycle(productSub);
}
return res;
}
NS_IMETHODIMP NavigatorImpl::GetSecurityPolicy(nsString& aSecurityPolicy)
{
return NS_OK;

Просмотреть файл

@ -56,10 +56,15 @@ enum Navigator_slots {
NAVIGATOR_LANGUAGE = -4,
NAVIGATOR_MIMETYPES = -5,
NAVIGATOR_PLATFORM = -6,
NAVIGATOR_PLUGINS = -7,
NAVIGATOR_SECURITYPOLICY = -8,
NAVIGATOR_USERAGENT = -9,
NAVIGATOR_COOKIEENABLED = -10
NAVIGATOR_OSCPU = -7,
NAVIGATOR_VENDOR = -8,
NAVIGATOR_VENDORSUB = -9,
NAVIGATOR_PRODUCT = -10,
NAVIGATOR_PRODUCTSUB = -11,
NAVIGATOR_PLUGINS = -12,
NAVIGATOR_SECURITYPOLICY = -13,
NAVIGATOR_USERAGENT = -14,
NAVIGATOR_COOKIEENABLED = -15
};
/***********************************************************************/
@ -155,6 +160,66 @@ GetNavigatorProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
case NAVIGATOR_OSCPU:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NAVIGATOR_OSCPU, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsAutoString prop;
rv = a->GetOscpu(prop);
if (NS_SUCCEEDED(rv)) {
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
}
break;
}
case NAVIGATOR_VENDOR:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NAVIGATOR_VENDOR, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsAutoString prop;
rv = a->GetVendor(prop);
if (NS_SUCCEEDED(rv)) {
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
}
break;
}
case NAVIGATOR_VENDORSUB:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NAVIGATOR_VENDORSUB, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsAutoString prop;
rv = a->GetVendorSub(prop);
if (NS_SUCCEEDED(rv)) {
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
}
break;
}
case NAVIGATOR_PRODUCT:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NAVIGATOR_PRODUCT, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsAutoString prop;
rv = a->GetProduct(prop);
if (NS_SUCCEEDED(rv)) {
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
}
break;
}
case NAVIGATOR_PRODUCTSUB:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NAVIGATOR_PRODUCT, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsAutoString prop;
rv = a->GetProductSub(prop);
if (NS_SUCCEEDED(rv)) {
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
}
break;
}
case NAVIGATOR_PLUGINS:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NAVIGATOR_PLUGINS, PR_FALSE);
@ -421,6 +486,11 @@ static JSPropertySpec NavigatorProperties[] =
{"language", NAVIGATOR_LANGUAGE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"mimeTypes", NAVIGATOR_MIMETYPES, JSPROP_ENUMERATE | JSPROP_READONLY},
{"platform", NAVIGATOR_PLATFORM, JSPROP_ENUMERATE | JSPROP_READONLY},
{"oscpu", NAVIGATOR_OSCPU, JSPROP_ENUMERATE | JSPROP_READONLY},
{"vendor", NAVIGATOR_VENDOR, JSPROP_ENUMERATE | JSPROP_READONLY},
{"vendorSub", NAVIGATOR_VENDORSUB, JSPROP_ENUMERATE | JSPROP_READONLY},
{"product", NAVIGATOR_PRODUCT, JSPROP_ENUMERATE | JSPROP_READONLY},
{"productSub", NAVIGATOR_PRODUCTSUB, JSPROP_ENUMERATE | JSPROP_READONLY},
{"plugins", NAVIGATOR_PLUGINS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"securityPolicy", NAVIGATOR_SECURITYPOLICY, JSPROP_ENUMERATE | JSPROP_READONLY},
{"userAgent", NAVIGATOR_USERAGENT, JSPROP_ENUMERATE | JSPROP_READONLY},