зеркало из https://github.com/mozilla/gecko-dev.git
Bug 717231 - Downloads are not added to the Download Manager (stock ICS 4.0.3) [r=mbrubeck]
This commit is contained in:
Родитель
0155326158
Коммит
158b1d0c69
|
@ -18,6 +18,7 @@
|
|||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
|
|
|
@ -547,6 +547,10 @@ var BrowserApp = {
|
|||
printSettings.headerStrLeft = "";
|
||||
printSettings.headerStrRight = "";
|
||||
|
||||
// Create a valid mimeInfo for the PDF
|
||||
let ms = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
|
||||
let mimeInfo = ms.getFromTypeAndExtension("application/pdf", "pdf");
|
||||
|
||||
let webBrowserPrint = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebBrowserPrint);
|
||||
|
||||
let cancelable = {
|
||||
|
@ -556,7 +560,7 @@ var BrowserApp = {
|
|||
}
|
||||
let download = dm.addDownload(Ci.nsIDownloadManager.DOWNLOAD_TYPE_DOWNLOAD,
|
||||
aBrowser.currentURI,
|
||||
Services.io.newFileURI(file), "", null,
|
||||
Services.io.newFileURI(file), "", mimeInfo,
|
||||
Date.now() * 1000, null, cancelable);
|
||||
|
||||
webBrowserPrint.print(printSettings, download);
|
||||
|
|
|
@ -140,16 +140,20 @@ var Downloads = {
|
|||
} else if (aTopic == "dl-done") {
|
||||
msgKey = "alertDownloadsDone";
|
||||
|
||||
let message = {
|
||||
gecko: {
|
||||
type: "Downloads:Done",
|
||||
displayName: download.displayName,
|
||||
path: download.targetFile.path,
|
||||
size: download.size,
|
||||
mimeType: download.MIMEInfo ? download.MIMEInfo.type : ""
|
||||
}
|
||||
};
|
||||
sendMessageToJava(message);
|
||||
// In order to get the fileSize to be correct for "Save as PDF", we need
|
||||
// let the local file be safely written before accessing it.
|
||||
setTimeout(function() {
|
||||
let message = {
|
||||
gecko: {
|
||||
type: "Downloads:Done",
|
||||
displayName: download.displayName,
|
||||
path: download.targetFile.path,
|
||||
size: download.targetFile.fileSize,
|
||||
mimeType: download.MIMEInfo ? download.MIMEInfo.type : ""
|
||||
}
|
||||
};
|
||||
sendMessageToJava(message);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
if (msgKey)
|
||||
|
|
Загрузка…
Ссылка в новой задаче