зеркало из https://github.com/mozilla/pjs.git
fix for bug 46488 r=valeski, sr=waterson
make the content DLL an HTTP startup listener, so that loading the content DLL doesn't load HTTP
This commit is contained in:
Родитель
f9b58c6023
Коммит
e2d0e02e30
|
@ -39,13 +39,14 @@ CPPSRCS = \
|
|||
nsContentDLF.cpp \
|
||||
nsContentFactory.cpp \
|
||||
nsContentModule.cpp \
|
||||
nsContentHTTPStartup.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifndef MKSHLIB_FORCE_ALL
|
||||
CPPSRCS += dlldeps.cpp
|
||||
endif
|
||||
|
||||
EXPORTS = nsContentCID.h $(BUILD_DATE)
|
||||
EXPORTS = nsContentCID.h
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/libgkconevents_s.$(LIB_SUFFIX) \
|
||||
|
@ -95,7 +96,7 @@ INCLUDES += -I$(srcdir)/../base/src \
|
|||
|
||||
GARBAGE+=$(BUILD_DATE)
|
||||
|
||||
$(BUILD_DATE):
|
||||
$(BUILD_DATE): gbdate.pl
|
||||
$(RM) $@
|
||||
$(PERL) $(srcdir)/gbdate.pl > $@
|
||||
|
||||
|
|
|
@ -24,4 +24,4 @@
|
|||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
|
||||
# localtime returns year minus 1900
|
||||
$year = $year + 1900;
|
||||
printf("#define PRODUCT_VERSION \"%04d%02d%02d\"\n", $year, 1+$mon, $mday);
|
||||
printf("#define PRODUCT_VERSION NS_LITERAL_STRING(\"%04d%02d%02d\").get()\n", $year, 1+$mon, $mday);
|
||||
|
|
|
@ -27,13 +27,12 @@ DEFINES=-D_IMPL_NS_HTML
|
|||
MODULE=raptor
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS=dlldeps.cpp nsContentDLF.cpp nsContentFactory.cpp nsContentModule.cpp
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\dlldeps.obj \
|
||||
.\$(OBJDIR)\nsContentDLF.obj \
|
||||
.\$(OBJDIR)\nsContentFactory.obj \
|
||||
.\$(OBJDIR)\nsContentModule.obj \
|
||||
.\$(OBJDIR)\nsContentHTTPStartup.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS=nsContentCID.h
|
||||
|
@ -93,14 +92,7 @@ clobber::
|
|||
rm -f $(DIST)\lib\$(DLLNAME).lib
|
||||
rm -f gbdate.h
|
||||
|
||||
!if !EXIST ( gbdate.h )
|
||||
|
||||
gbdate.h::
|
||||
gbdate.h:: gbdate.pl
|
||||
$(PERL) gbdate.pl > gbdate.h
|
||||
|
||||
!else
|
||||
|
||||
gbdate.h::
|
||||
|
||||
!endif
|
||||
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsContentHTTPStartup.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "gbdate.h"
|
||||
|
||||
#define PRODUCT_NAME NS_LITERAL_STRING("Gecko").get()
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver)
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::Observe( nsISupports *aSubject,
|
||||
const PRUnichar *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (nsCRT::strcmp(aTopic, NS_HTTP_STARTUP_TOPIC) != 0)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCOMPtr<nsIHTTPProtocolHandler> http(do_QueryInterface(aSubject));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProduct(PRODUCT_NAME);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProductSub(PRODUCT_VERSION);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::RegisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString previousEntry;
|
||||
rv = catMan->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY,
|
||||
"Content UserAgent Setter",
|
||||
NS_CONTENTHTTPSTARTUP_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE,
|
||||
getter_Copies(previousEntry));
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::UnregisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIObserver.h"
|
||||
|
||||
#define NS_CONTENTHTTPSTARTUP_CONTRACTID \
|
||||
"@mozilla.org/content/http-startup;1"
|
||||
|
||||
/* c2f6ef7e-afd5-4be4-a1f5-c824efa4231b */
|
||||
#define NS_CONTENTHTTPSTARTUP_CID \
|
||||
{ 0xc2f6ef7e, 0xafd5, 0x4be4, \
|
||||
{0xa1, 0xf5, 0xc8, 0x24, 0xef, 0xa4, 0x23, 0x1b} }
|
||||
|
||||
class nsContentHTTPStartup : public nsIObserver
|
||||
{
|
||||
public:
|
||||
nsContentHTTPStartup() { NS_INIT_ISUPPORTS(); }
|
||||
virtual ~nsContentHTTPStartup() {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
public:
|
||||
static nsresult RegisterHTTPStartup();
|
||||
static nsresult UnregisterHTTPStartup();
|
||||
|
||||
private:
|
||||
nsresult setUserAgent();
|
||||
|
||||
};
|
|
@ -56,8 +56,7 @@
|
|||
|
||||
#include "nsRange.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "gbdate.h"
|
||||
#include "nsContentHTTPStartup.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#define PRODUCT_NAME "Gecko"
|
||||
|
||||
|
@ -66,7 +65,6 @@
|
|||
#include "nsXULContentUtils.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kHTTPHandlerCID, NS_IHTTPHANDLER_CID);
|
||||
static nsContentModule *gModule = NULL;
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
|
||||
|
@ -216,8 +214,6 @@ nsContentModule::Initialize()
|
|||
}
|
||||
}
|
||||
|
||||
SetUserAgent();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -377,6 +373,8 @@ static Components gComponents[] = {
|
|||
#endif
|
||||
{ "Controller Command Manager", NS_CONTROLLERCOMMANDMANAGER_CID,
|
||||
"@mozilla.org/content/controller-command-manager;1", },
|
||||
{ "Content HTTP Startup Listener", NS_CONTENTHTTPSTARTUP_CID,
|
||||
NS_CONTENTHTTPSTARTUP_CONTRACTID, },
|
||||
};
|
||||
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]))
|
||||
|
||||
|
@ -407,8 +405,11 @@ nsContentModule::RegisterSelf(nsIComponentManager *aCompMgr,
|
|||
cp++;
|
||||
}
|
||||
|
||||
rv = RegisterDocumentFactories(aCompMgr, aPath);
|
||||
// not fatal if these fail
|
||||
nsContentHTTPStartup::RegisterHTTPStartup();
|
||||
|
||||
rv = RegisterDocumentFactories(aCompMgr, aPath);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -433,6 +434,7 @@ nsContentModule::UnregisterSelf(nsIComponentManager* aCompMgr,
|
|||
cp++;
|
||||
}
|
||||
|
||||
nsContentHTTPStartup::UnregisterHTTPStartup();
|
||||
UnregisterDocumentFactories(aCompMgr, aPath);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -448,20 +450,3 @@ nsContentModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
nsContentModule::SetUserAgent( void )
|
||||
{
|
||||
nsString productName; productName.AssignWithConversion(PRODUCT_NAME);
|
||||
nsString productVersion; productVersion.AssignWithConversion(PRODUCT_VERSION);
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCOMPtr<nsIHTTPProtocolHandler> theService(do_GetService(kHTTPHandlerCID,
|
||||
&rv));
|
||||
|
||||
if( NS_SUCCEEDED(rv) && (nsnull != theService) )
|
||||
{
|
||||
rv = theService->SetProduct(productName.GetUnicode());
|
||||
|
||||
rv = theService->SetProductSub(productVersion.GetUnicode());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,6 @@ protected:
|
|||
void UnregisterDocumentFactories(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath);
|
||||
|
||||
void SetUserAgent();
|
||||
|
||||
PRBool mInitialized;
|
||||
// static nsIFactory* gFactory;
|
||||
static nsIScriptNameSetRegistry* gRegistry;
|
||||
|
|
|
@ -24,4 +24,4 @@
|
|||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
|
||||
# localtime returns year minus 1900
|
||||
$year = $year + 1900;
|
||||
printf("#define PRODUCT_VERSION \"%04d%02d%02d\"\n", $year, 1+$mon, $mday);
|
||||
printf("#define PRODUCT_VERSION NS_LITERAL_STRING(\"%04d%02d%02d\").get()\n", $year, 1+$mon, $mday);
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsContentHTTPStartup.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "gbdate.h"
|
||||
|
||||
#define PRODUCT_NAME NS_LITERAL_STRING("Gecko").get()
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver)
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::Observe( nsISupports *aSubject,
|
||||
const PRUnichar *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (nsCRT::strcmp(aTopic, NS_HTTP_STARTUP_TOPIC) != 0)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCOMPtr<nsIHTTPProtocolHandler> http(do_QueryInterface(aSubject));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProduct(PRODUCT_NAME);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProductSub(PRODUCT_VERSION);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::RegisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString previousEntry;
|
||||
rv = catMan->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY,
|
||||
"Content UserAgent Setter",
|
||||
NS_CONTENTHTTPSTARTUP_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE,
|
||||
getter_Copies(previousEntry));
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentHTTPStartup::UnregisterHTTPStartup()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager>
|
||||
catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIObserver.h"
|
||||
|
||||
#define NS_CONTENTHTTPSTARTUP_CONTRACTID \
|
||||
"@mozilla.org/content/http-startup;1"
|
||||
|
||||
/* c2f6ef7e-afd5-4be4-a1f5-c824efa4231b */
|
||||
#define NS_CONTENTHTTPSTARTUP_CID \
|
||||
{ 0xc2f6ef7e, 0xafd5, 0x4be4, \
|
||||
{0xa1, 0xf5, 0xc8, 0x24, 0xef, 0xa4, 0x23, 0x1b} }
|
||||
|
||||
class nsContentHTTPStartup : public nsIObserver
|
||||
{
|
||||
public:
|
||||
nsContentHTTPStartup() { NS_INIT_ISUPPORTS(); }
|
||||
virtual ~nsContentHTTPStartup() {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
public:
|
||||
static nsresult RegisterHTTPStartup();
|
||||
static nsresult UnregisterHTTPStartup();
|
||||
|
||||
private:
|
||||
nsresult setUserAgent();
|
||||
|
||||
};
|
Загрузка…
Ссылка в новой задаче