зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1041516
part 1: clean up pref code in shell service, r=bsmedberg
--HG-- extra : transplant_source : %B5%B9%11%7D%FE%86%85%7E%A5%10%11%5D%3B%1EZ%A4%B3%EF%0B%D8
This commit is contained in:
Родитель
3d51439a7d
Коммит
6907736c0d
|
@ -326,29 +326,25 @@ nsGNOMEShellService::GetShouldCheckDefaultBrowser(bool* aResult)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||||
if (pserve)
|
if (NS_FAILED(rv)) {
|
||||||
pserve->GetBranch("", getter_AddRefs(prefs));
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
if (prefs)
|
return prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult);
|
||||||
prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsGNOMEShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
|
nsGNOMEShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||||
if (pserve)
|
if (NS_FAILED(rv)) {
|
||||||
pserve->GetBranch("", getter_AddRefs(prefs));
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
if (prefs)
|
return prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
|
||||||
prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -90,7 +90,7 @@ nsMacShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,27 +104,25 @@ nsMacShellService::GetShouldCheckDefaultBrowser(bool* aResult)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||||
if (pserve)
|
if (NS_FAILED(rv)) {
|
||||||
pserve->GetBranch("", getter_AddRefs(prefs));
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult);
|
return prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult);
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMacShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
|
nsMacShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||||
if (pserve)
|
if (NS_FAILED(rv)) {
|
||||||
pserve->GetBranch("", getter_AddRefs(prefs));
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
|
return prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -275,20 +275,15 @@ nsWindowsShellService::ShortcutMaintenance()
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
NS_NAMED_LITERAL_CSTRING(prefName, "browser.taskbar.lastgroupid");
|
NS_NAMED_LITERAL_CSTRING(prefName, "browser.taskbar.lastgroupid");
|
||||||
nsCOMPtr<nsIPrefService> prefs =
|
nsCOMPtr<nsIPrefBranch> prefs =
|
||||||
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||||
if (!prefs)
|
if (!prefs)
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
|
||||||
prefs->GetBranch(nullptr, getter_AddRefs(prefBranch));
|
|
||||||
if (!prefBranch)
|
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
|
|
||||||
nsCOMPtr<nsISupportsString> prefString;
|
nsCOMPtr<nsISupportsString> prefString;
|
||||||
rv = prefBranch->GetComplexValue(prefName.get(),
|
rv = prefs->GetComplexValue(prefName.get(),
|
||||||
NS_GET_IID(nsISupportsString),
|
NS_GET_IID(nsISupportsString),
|
||||||
getter_AddRefs(prefString));
|
getter_AddRefs(prefString));
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
nsAutoString version;
|
nsAutoString version;
|
||||||
prefString->GetData(version);
|
prefString->GetData(version);
|
||||||
|
@ -304,9 +299,9 @@ nsWindowsShellService::ShortcutMaintenance()
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
prefString->SetData(appId);
|
prefString->SetData(appId);
|
||||||
rv = prefBranch->SetComplexValue(prefName.get(),
|
rv = prefs->SetComplexValue(prefName.get(),
|
||||||
NS_GET_IID(nsISupportsString),
|
NS_GET_IID(nsISupportsString),
|
||||||
prefString);
|
prefString);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
NS_WARNING("Couldn't set last user model id!");
|
NS_WARNING("Couldn't set last user model id!");
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
@ -722,13 +717,11 @@ nsWindowsShellService::GetShouldCheckDefaultBrowser(bool* aResult)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
rv = pserve->GetBranch("", getter_AddRefs(prefs));
|
}
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
return prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult);
|
return prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult);
|
||||||
}
|
}
|
||||||
|
@ -736,14 +729,11 @@ nsWindowsShellService::GetShouldCheckDefaultBrowser(bool* aResult)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
|
nsWindowsShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
if (NS_FAILED(rv)) {
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
return rv;
|
||||||
|
}
|
||||||
rv = pserve->GetBranch("", getter_AddRefs(prefs));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
return prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
|
return prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче