зеркало из https://github.com/mozilla/pjs.git
Bug 227032. cleanup nsDownloadProxy a bit, mostly:
deal with prefs service or the pref not being there use nsIPrefBranch for do_GetService instead of a separate QI r=neil.parkwaycc.co.uk sr=darin
This commit is contained in:
Родитель
c8ec26dcc4
Коммит
16da642042
|
@ -53,7 +53,7 @@ class nsDownloadProxy : public nsIDownload,
|
|||
public:
|
||||
|
||||
nsDownloadProxy() { }
|
||||
virtual ~nsDownloadProxy() { };
|
||||
virtual ~nsDownloadProxy() { }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
@ -65,26 +65,30 @@ public:
|
|||
nsIWebBrowserPersist* aPersist) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDownloadManager> dm = do_GetService("@mozilla.org/download-manager;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = dm->AddDownload(aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime, aPersist, getter_AddRefs(mInner));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRInt32 behavior = 0;
|
||||
nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
|
||||
PRInt32 behavior;
|
||||
nsCOMPtr<nsIPrefBranch> branch = do_GetService("@mozilla.org/preferences-service;1", &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = branch->GetIntPref(DOWNLOAD_MANAGER_BEHAVIOR_PREF, &behavior);
|
||||
if (NS_FAILED(rv))
|
||||
behavior = 0;
|
||||
|
||||
branch->GetIntPref(DOWNLOAD_MANAGER_BEHAVIOR_PREF, &behavior);
|
||||
if (behavior == 0)
|
||||
return dm->Open(nsnull, this);
|
||||
if (behavior == 1) {
|
||||
rv = dm->Open(nsnull, this);
|
||||
else if (behavior == 1) {
|
||||
nsAutoString path;
|
||||
rv = aTarget->GetPath(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_ConvertUCS2toUTF8 utf8Path(path);
|
||||
return dm->OpenProgressDialogFor(utf8Path, nsnull, PR_TRUE);
|
||||
rv = dm->OpenProgressDialogFor(utf8Path, nsnull, PR_TRUE);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче