observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-approve-change", PR_FALSE); observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-change-teardown", PR_FALSE); observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-after-change", PR_FALSE);
observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-approve-change", PR_TRUE); observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-change-teardown", PR_TRUE); observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-after-change", PR_TRUE);
int main(int argc, char *argv[]){    printf("\nYou are embedded, man!\n\n");        // Sophisticated command-line parsing in action    char *szFirstURL = "http://www.mozilla.org/projects/embedding";	char *szDefaultProfile = nsnull;	int argn;	for (argn = 1; argn < argc; argn++)	{		if (stricmp("-P", argv[argn]) == 0)		{			if (argn + 1 < argc)			{				szDefaultProfile = argv[++argn];			}		}		else		{	        szFirstURL = argv[argn];		}    }	strncpy(gFirstURL, szFirstURL, sizeof(gFirstURL) - 1);    ghInstanceApp = GetModuleHandle(NULL);    ghInstanceResources = GetModuleHandle(NULL);	// Initialize global strings    TCHAR szTitle[MAX_LOADSTRING];	LoadString(ghInstanceResources, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);	MyRegisterClass(ghInstanceApp);    // Init Embedding APIs    NS_InitEmbedding(nsnull, nsnull);	// Choose the new profile	if (!ChooseNewProfile(TRUE, szDefaultProfile))    {        NS_TermEmbedding();        return 1;    }	// Now register an observer to watch for profile changes    nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1"));    ProfileChangeObserver *observer = new ProfileChangeObserver;    observer->AddRef();    observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-approve-change", PR_FALSE);    observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-change-teardown", PR_FALSE);    observerService->AddObserver(NS_STATIC_CAST(nsIObserver *, observer), "profile-after-change", PR_FALSE);    InitializeWindowCreator();    // Open the initial browser window    OpenWebPage(gFirstURL);	// Main message loop.    // NOTE: We use a fake event and a timeout in order to process idle stuff for    //       Mozilla every 1/10th of a second.    PRBool runCondition = PR_TRUE;    WPARAM rv;    rv = AppCallbacks::RunEventLoop(runCondition);    observer->Release();    // Close down Embedding APIs    NS_TermEmbedding();    return rv;}