bool nsMailGNOMEIntegration::CheckHandlerMatchesAppName(const nsACString &handler) const { gint argc; gchar **argv; nsCAutoString command(handler); if (g_shell_parse_argv(command.get(), &argc, &argv, NULL)) { command.Assign(argv[0]); g_strfreev(argv); } else { return false; } return KeyMatchesAppName(command.get()); }
PRBool nsGNOMEShellService::CheckHandlerMatchesAppName(const nsACString &handler) const { gint argc; gchar **argv; nsCAutoString command(handler); // The string will be something of the form: [/path/to/]browser "%s" // We want to remove all of the parameters and get just the binary name. if (g_shell_parse_argv(command.get(), &argc, &argv, NULL) && argc > 0) { command.Assign(argv[0]); g_strfreev(argv); } if (!KeyMatchesAppName(command.get())) return PR_FALSE; // the handler is set to another app return PR_TRUE; }
NS_IMETHODIMP nsGNOMEShellService::IsDefaultBrowser(PRBool aStartupCheck, PRBool* aIsDefaultBrowser) { *aIsDefaultBrowser = PR_FALSE; if (aStartupCheck) mCheckedThisSession = PR_TRUE; nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); PRBool enabled; nsCAutoString handler; for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) { if (!appProtocols[i].essential) continue; handler.Truncate(); gconf->GetAppForProtocol(nsDependentCString(appProtocols[i].name), &enabled, handler); // The string will be something of the form: [/path/to/]browser "%s" // We want to remove all of the parameters and get just the binary name. gint argc; gchar **argv; if (g_shell_parse_argv(handler.get(), &argc, &argv, NULL) && argc > 0) { handler.Assign(argv[0]); g_strfreev(argv); } if (!KeyMatchesAppName(handler.get()) || !enabled) return NS_OK; // the handler is disabled or set to another app } *aIsDefaultBrowser = PR_TRUE; return NS_OK; }