*aDefaultArgs = ToNewUnicode(args); return NS_OK;
nsCOMPtr<nsIPref> prefs(do_GetService(kCPrefServiceCID)); if (!prefs) return NS_ERROR_FAILURE;  nsCOMPtr<nsIGlobalHistory> history(do_GetService(kCGlobalHistoryCID));  PRBool override = PR_FALSE; rv = prefs->GetBoolPref(PREF_HOMEPAGE_OVERRIDE, &override); if (NS_SUCCEEDED(rv) && override) { rv = prefs->GetLocalizedUnicharPref(PREF_HOMEPAGE_OVERRIDE_URL, getter_Copies(url)); if (NS_SUCCEEDED(rv) && (const PRUnichar *)url) { rv = prefs->SetBoolPref(PREF_HOMEPAGE_OVERRIDE, PR_FALSE); } }  nsAutoString tmp(url); if (!url || !tmp.Length()) { PRInt32 choice = 0; rv = prefs->GetIntPref(PREF_BROWSER_STARTUP_PAGE, &choice); if (NS_SUCCEEDED(rv)) { switch (choice) { case 1: rv = prefs->GetLocalizedUnicharPref(PREF_BROWSER_STARTUP_HOMEPAGE, getter_Copies(url)); tmp = url; break; case 2: if (history) { nsXPIDLCString curl; rv = history->GetLastPageVisted(getter_Copies(curl)); tmp = NS_ConvertUTF8toUCS2((const char *)curl); } break; case 0: default: args.AssignWithConversion("about:blank"); break; } } }  if (NS_SUCCEEDED(rv) && tmp.Length()) { args = tmp; }  *aDefaultArgs = args.ToNewUnicode(); return NS_OK;
NS_IMETHODIMP nsBrowserContentHandler::GetDefaultArgs(PRUnichar **aDefaultArgs){  if (!aDefaultArgs)    return NS_ERROR_NULL_POINTER;  nsresult rv;  nsAutoString args;  nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));  if (!prefs) return NS_ERROR_FAILURE;  if (NeedHomepageOverride(prefs)) {    nsXPIDLString url;    rv = prefs->GetLocalizedUnicharPref(PREF_HOMEPAGE_OVERRIDE_URL, getter_Copies(url));    if (NS_SUCCEEDED(rv) && (const PRUnichar *)url) {      args = url;    }  }  if (args.IsEmpty()) {    PRInt32 choice = 0;    rv = prefs->GetIntPref(PREF_BROWSER_STARTUP_PAGE, &choice);    if (NS_SUCCEEDED(rv)) {      switch (choice) {        case 1: {          // skip the code below          return GetHomePageGroup(prefs, aDefaultArgs);        }        case 2: {          nsCOMPtr<nsIBrowserHistory> history(do_GetService(kCGlobalHistoryCID));          if (history) {            nsXPIDLCString curl;            rv = history->GetLastPageVisited(getter_Copies(curl));            args.AssignWithConversion(curl);          }          break;        }        case 0:        default:          // fall through to about:blank below          break;      }    }    // the default, in case we fail somewhere    if (args.IsEmpty())      args.Assign(NS_LITERAL_STRING("about:blank"));  }  *aDefaultArgs = ToNewUnicode(args);  return NS_OK;}