Bug 104173. Don't use nsIAppShellComponent in AccessProxy. r=dveditz, sr=alecf

This commit is contained in:
aaronl%netscape.com 2001-10-11 18:46:26 +00:00
Родитель 8547f74ac9
Коммит 3175501764
6 изменённых файлов: 41 добавлений и 45 удалений

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

@ -49,6 +49,7 @@ REQUIRES = xpcom \
mozcomps \
pref \
necko \
appstartup \
$(NULL)
EXPORT_LIBRARY = 1
IS_COMPONENT = 1

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

@ -42,6 +42,7 @@ REQUIRES = xpcom \
locale \
mozcomps \
pref \
appstartup \
$(NULL)
XPIDLSRCS= .\nsIAccessProxy.idl \

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

@ -30,8 +30,8 @@
#include "nsCOMPtr.h"
#include "nsMemory.h"
#include "nsIServiceManager.h"
#include "nsIObserverService.h"
#include "nsIGenericFactory.h"
#include "nsIAppShellComponent.h"
#include "nsIWebProgress.h"
#include "nsIDocumentLoader.h"
#include "nsCURILoader.h"
@ -50,7 +50,6 @@
#include "nsIDocument.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsIFrameSelection.h"
#include "nsICaret.h"
// Header for this class
@ -62,7 +61,7 @@
////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS4(nsAccessProxy, nsIAppShellComponent, nsISupportsWeakReference, nsIWebProgressListener, nsIDOMEventListener)
NS_IMPL_ISUPPORTS4(nsAccessProxy, nsIObserver, nsISupportsWeakReference, nsIWebProgressListener, nsIDOMEventListener)
nsAccessProxy* nsAccessProxy::mInstance = nsnull;
@ -164,27 +163,35 @@ NS_IMETHODIMP nsAccessProxy::HandleEvent(nsIDOMEvent* aEvent)
// This method gets called on application startup
NS_IMETHODIMP nsAccessProxy::Initialize(nsIAppShellService *anAppShell,
nsICmdLineService *aCmdLineService)
NS_IMETHODIMP nsAccessProxy::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *aData)
{
nsCOMPtr<nsIWebProgress> progress(do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID));
nsresult rv = NS_ERROR_FAILURE;
if (progress) {
rv = progress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener*,this));
if (NS_SUCCEEDED(rv))
AddRef();
static PRBool accessProxyInstalled;
nsresult rv = NS_OK;
nsDependentString aTopicString(aTopic);
if (accessProxyInstalled && aTopicString.Equals(NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID)))
return Release();
if (!accessProxyInstalled && aTopicString.Equals(NS_LITERAL_STRING(APPSTARTUP_CATEGORY))) {
accessProxyInstalled = PR_TRUE; // Set to TRUE even for failure cases - we don't want to try more than once
nsCOMPtr<nsIWebProgress> progress(do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID));
rv = NS_ERROR_FAILURE;
if (progress) {
rv = progress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener*,this));
if (NS_SUCCEEDED(rv))
AddRef();
}
// install xpcom shutdown observer
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIObserverService> observerService(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
rv = observerService->AddObserver(this, NS_LITERAL_STRING(NS_XPCOM_SHUTDOWN_OBSERVER_ID).get());
}
}
return rv;
}
// This method gets called on application shutdown
NS_IMETHODIMP nsAccessProxy::Shutdown()
{
Release();
return NS_OK;
}
NS_IMETHODIMP nsAccessProxy::OnStateChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRInt32 aStateFlags, PRUint32 aStatus)
@ -284,4 +291,3 @@ NS_IMETHODIMP nsAccessProxy::OnSecurityChange(nsIWebProgress *aWebProgress,
return NS_OK;
}

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

@ -34,9 +34,10 @@
#include "nsIAccessProxy.h"
#include "nsIDOMEventListener.h"
#include "nsIAppShellComponent.h"
#include "nsIWebProgressListener.h"
#include "nsWeakReference.h"
#include "nsIObserver.h"
#include "nsIAppStartupNotifier.h"
/**
@ -52,7 +53,7 @@
class nsAccessProxy : public nsIDOMEventListener,
public nsIAppShellComponent,
public nsIObserver,
public nsIWebProgressListener,
public nsSupportsWeakReference
{
@ -63,7 +64,7 @@ public:
NS_DEFINE_STATIC_CID_ACCESSOR(NS_ACCESSPROXY_CID);
NS_DECL_ISUPPORTS // This macro expands into declaration of nsISupports interface
NS_DECL_NSIAPPSHELLCOMPONENT
NS_DECL_NSIOBSERVER
NS_DECL_NSIWEBPROGRESSLISTENER
//NS_DECL_NSIACCESSPROXY

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

@ -30,12 +30,10 @@
#include "nsIGenericFactory.h"
#include "nsAccessProxy.h"
#include "nsIServiceManager.h"
#include "nsIAppShellComponent.h"
#include "nsIRegistry.h"
#include "prprf.h"
#include "nsCRT.h"
#define NS_ACESSPROXY_CONTRACTID NS_IAPPSHELLCOMPONENT_CONTRACTID "/accessproxy;1"
#include "nsICategoryManager.h"
////////////////////////////////////////////////////////////////////////
// Define a table of CIDs implemented by this module along with other
@ -54,22 +52,12 @@ static NS_METHOD nsAccessProxyRegistrationProc(nsIComponentManager *aCompMgr,
// This function performs the extra step of installing us as
// an application component. This makes sure that we're
// initialized on application startup.
// get the registry
nsIRegistry* registry;
nsresult rv = nsServiceManager::GetService(NS_REGISTRY_CONTRACTID,
NS_GET_IID(nsIRegistry), (nsISupports**)&registry);
if (NS_SUCCEEDED(rv)) {
registry->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry);
char buffer[256];
char *cid = nsAccessProxy::GetCID().ToString();
PR_snprintf(buffer, sizeof buffer, "%s/%s", NS_IAPPSHELLCOMPONENT_KEY,
cid ? cid : "unknown" );
nsCRT::free(cid);
nsRegistryKey key;
rv = registry->AddSubtree(nsIRegistry::Common, buffer, &key);
nsServiceManager::ReleaseService(NS_REGISTRY_CONTRACTID, registry);
}
nsresult rv;
nsCOMPtr<nsICategoryManager> categoryManager(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
rv = categoryManager->AddCategoryEntry(APPSTARTUP_CATEGORY, "Access Proxy",
"service," NS_ACCESSPROXY_CONTRACTID, PR_TRUE, PR_TRUE, nsnull);
return rv;
}

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

@ -38,15 +38,14 @@
#include "nsIDOMEvent.h"
#define NS_ACCESSPROXY_CID \
{ 0x28c13ee3, 0xca0c, 0x4395, { 0xbe, 0x98, 0xd1, 0x26, 0xea, 0xd3, 0xb9, 0x41 } }
{ 0x5500c0d7, 0xdcc3, 0x4786, { 0xb4, 0x2f, 0xc2, 0x74, 0xb8, 0xc0, 0x7f, 0x72 } }
#define NS_ACCESSPROXY_CONTRACTID NS_IAPPSHELLCOMPONENT_CONTRACTID "/accessproxy;1"
#define NS_ACCESSPROXY_CONTRACTID "@mozilla.org/accessproxy;1"
%}
interface nsIDOMEvent;
[uuid(57e45180-7b41-4815-beec-6cac25dfac57)]
[uuid(27B1B140-2939-432a-9B59-3A4C6B11B6C3)]
interface nsIAccessProxy : nsISupports
{
void handleEvent(in nsIDOMEvent event);