NS_IMETHODIMP nsGNOMEShellService::IsDefaultBrowser(PRBool aStartupCheck, PRBool* aIsDefaultBrowser) { *aIsDefaultBrowser = PR_FALSE; if (aStartupCheck) mCheckedThisSession = PR_TRUE; nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID); PRBool enabled; nsCAutoString handler; nsCOMPtr<nsIGIOMimeApp> gioApp; for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) { if (!appProtocols[i].essential) continue; if (gconf) { handler.Truncate(); gconf->GetAppForProtocol(nsDependentCString(appProtocols[i].name), &enabled, handler); if (!CheckHandlerMatchesAppName(handler) || !enabled) return NS_OK; // the handler is disabled or set to another app } if (giovfs) { handler.Truncate(); giovfs->GetAppForURIScheme(nsDependentCString(appProtocols[i].name), getter_AddRefs(gioApp)); if (!gioApp) return NS_OK; gioApp->GetCommand(handler); if (!CheckHandlerMatchesAppName(handler)) return NS_OK; // the handler is set to another app } } *aIsDefaultBrowser = PR_TRUE; return NS_OK; }
bool nsMailGNOMEIntegration::checkDefault(const char* const *aProtocols, unsigned int aLength) { nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID); bool enabled; nsCAutoString handler; nsresult rv; for (unsigned int i = 0; i < aLength; ++i) { if (gconf) { handler.Truncate(); rv = gconf->GetAppForProtocol(nsDependentCString(aProtocols[i]), &enabled, handler); if (NS_SUCCEEDED(rv) && (!CheckHandlerMatchesAppName(handler) || !enabled)) { return false; } } if (giovfs) { handler.Truncate(); nsCOMPtr<nsIGIOMimeApp> app; rv = giovfs->GetAppForURIScheme(nsDependentCString(aProtocols[i]), getter_AddRefs(app)); if (NS_FAILED(rv) || !app) { return false; } rv = app->GetCommand(handler); if (NS_SUCCEEDED(rv) && !CheckHandlerMatchesAppName(handler)) { return false; } } } return true; }