Search
SailfishOS Open Build Service
>
Projects
>
home:siteshwar
:
branches:nemo:devel:mw
>
xulrunner-qt5
> _service:tar_git:0014-Revert-patchset-for-bug-1114594.-Contributes-JB32870.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File _service:tar_git:0014-Revert-patchset-for-bug-1114594.-Contributes-JB32870.patch of Package xulrunner-qt5
From f61b773e51ecf16909d018ad1e5af527ba92153d Mon Sep 17 00:00:00 2001 From: Dmitry Rozhkov <dmitry.rozhkov@jolla.com> Date: Thu, 5 Nov 2015 17:28:02 +0200 Subject: [PATCH 14/15] Revert patchset for bug 1114594. Contributes JB32870 WIP drop nsHelperAppDlg.js --- b2g/components/HelperAppDialog.js | 8 +++++++ browser/metro/components/HelperAppDialog.js | 4 ++++ mobile/android/components/HelperAppDialog.js | 5 ++++ .../downloads/test/unit/downloads_manifest.js | 4 +++- toolkit/components/jsdownloads/test/unit/head.js | 9 +++++++ toolkit/mozapps/downloads/nsHelperAppDlg.js | 16 +++++++++++++ toolkit/mozapps/downloads/nsHelperAppDlg.manifest | 2 -- .../exthandler/nsExternalHelperAppService.cpp | 24 ++++++++++++------- .../exthandler/nsIHelperAppLauncherDialog.idl | 28 +++++++++++++++++++++- .../tests/mochitest/test_unsafeBidiChars.xhtml | 3 +++ .../exthandler/tests/unit_ipc/test_encoding.js | 4 +++- 11 files changed, 94 insertions(+), 13 deletions(-) diff --git a/b2g/components/HelperAppDialog.js b/b2g/components/HelperAppDialog.js index 6a7bb79..cc5288a 100644 --- a/b2g/components/HelperAppDialog.js +++ b/b2g/components/HelperAppDialog.js @@ -33,6 +33,14 @@ HelperAppLauncherDialog.prototype = { aLauncher.saveToDisk(null, false); }, + promptForSaveToFile: function(aLauncher, + aContext, + aDefaultFile, + aSuggestedFileExt, + aForcePrompt) { + throw Cr.NS_ERROR_NOT_AVAILABLE; + }, + promptForSaveToFileAsync: function(aLauncher, aContext, aDefaultFile, diff --git a/browser/metro/components/HelperAppDialog.js b/browser/metro/components/HelperAppDialog.js index f189db0..257d156 100644 --- a/browser/metro/components/HelperAppDialog.js +++ b/browser/metro/components/HelperAppDialog.js @@ -138,6 +138,10 @@ HelperAppLauncherDialog.prototype = { messageContainer.appendChild(fragment); }, + promptForSaveToFile: function hald_promptForSaveToFile(aLauncher, aContext, aDefaultFile, aSuggestedFileExt, aForcePrompt) { + throw new Components.Exception("Async version must be used", Cr.NS_ERROR_NOT_AVAILABLE); + }, + promptForSaveToFileAsync: function hald_promptForSaveToFileAsync(aLauncher, aContext, aDefaultFile, aSuggestedFileExt, aForcePrompt) { let file = null; let prefs = Services.prefs; diff --git a/mobile/android/components/HelperAppDialog.js b/mobile/android/components/HelperAppDialog.js index d2e2d10..97d4269 100644 --- a/mobile/android/components/HelperAppDialog.js +++ b/mobile/android/components/HelperAppDialog.js @@ -236,6 +236,11 @@ HelperAppLauncherDialog.prototype = { Services.prefs.clearUserPref(this._getPrefName(mime)); }, + promptForSaveToFile: function () { + throw new Components.Exception("Async version must be used", + Cr.NS_ERROR_NOT_AVAILABLE); + }, + promptForSaveToFileAsync: function (aLauncher, aContext, aDefaultFile, aSuggestedFileExt, aForcePrompt) { Task.spawn(function* () { diff --git a/toolkit/components/downloads/test/unit/downloads_manifest.js b/toolkit/components/downloads/test/unit/downloads_manifest.js index 7bef411..a24622a 100644 --- a/toolkit/components/downloads/test/unit/downloads_manifest.js +++ b/toolkit/components/downloads/test/unit/downloads_manifest.js @@ -15,7 +15,9 @@ HelperAppDlg.prototype = { show: function (launcher, ctx, reason) { launcher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.saveToDisk; launcher.launchWithApplication(null, false); - } + }, + + promptForSaveToFile: function (launcher, ctx, defaultFile, suggestedExtension, forcePrompt) { } } diff --git a/toolkit/components/jsdownloads/test/unit/head.js b/toolkit/components/jsdownloads/test/unit/head.js index c959d43..111b0ff 100644 --- a/toolkit/components/jsdownloads/test/unit/head.js +++ b/toolkit/components/jsdownloads/test/unit/head.js @@ -802,6 +802,15 @@ add_task(function test_common_initialize() createInstance: function (aOuter, aIid) { return { QueryInterface: XPCOMUtils.generateQI([Ci.nsIHelperAppLauncherDialog]), + promptForSaveToFile: function (aLauncher, aWindowContext, + aDefaultFileName, + aSuggestedFileExtension, + aForcePrompt) + { + throw new Components.Exception( + "Synchronous promptForSaveToFile not implemented.", + Cr.NS_ERROR_NOT_AVAILABLE); + }, promptForSaveToFileAsync: function (aLauncher, aWindowContext, aDefaultFileName, aSuggestedFileExtension, diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.js b/toolkit/mozapps/downloads/nsHelperAppDlg.js index 43653f9..a99b526 100644 --- a/toolkit/mozapps/downloads/nsHelperAppDlg.js +++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js @@ -204,6 +204,22 @@ nsUnknownContentTypeDialog.prototype = { bundle.GetStringFromName("badPermissions")); }, + // promptForSaveToFile: Display file picker dialog and return selected file. + // This is called by the External Helper App Service + // after the ucth dialog calls |saveToDisk| with a null + // target filename (no target, therefore user must pick). + // + // Alternatively, if the user has selected to have all + // files download to a specific location, return that + // location and don't ask via the dialog. + // + // Note - this function is called without a dialog, so it cannot access any part + // of the dialog XUL as other functions on this object do. + + promptForSaveToFile: function(aLauncher, aContext, aDefaultFile, aSuggestedFileExtension, aForcePrompt) { + throw new Components.Exception("Async version must be used", Components.results.NS_ERROR_NOT_AVAILABLE); + }, + promptForSaveToFileAsync: function(aLauncher, aContext, aDefaultFile, aSuggestedFileExtension, aForcePrompt) { var result = null; diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.manifest b/toolkit/mozapps/downloads/nsHelperAppDlg.manifest index 8824b45..e69de29 100644 --- a/toolkit/mozapps/downloads/nsHelperAppDlg.manifest +++ b/toolkit/mozapps/downloads/nsHelperAppDlg.manifest @@ -1,2 +0,0 @@ -component {F68578EB-6EC2-4169-AE19-8C6243F0ABE1} nsHelperAppDlg.js -contract @mozilla.org/helperapplauncherdialog;1 {F68578EB-6EC2-4169-AE19-8C6243F0ABE1} diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 6f87a87..00a92cc 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -2237,16 +2237,24 @@ void nsExternalAppHandler::RequestSaveDestination(const nsAFlatString &aDefaultF // picker is up would cause Cancel() to be called, and the dialog would be // released, which would release this object too, which would crash. // See Bug 249143 + nsIFile* fileToUse; nsRefPtr<nsExternalAppHandler> kungFuDeathGrip(this); nsCOMPtr<nsIHelperAppLauncherDialog> dlg(mDialog); - - rv = mDialog->PromptForSaveToFileAsync(this, - GetDialogParent(), - aDefaultFile.get(), - aFileExtension.get(), - mForceSave); - if (NS_FAILED(rv)) { - Cancel(NS_BINDING_ABORTED); + rv = mDialog->PromptForSaveToFile(this, + GetDialogParent(), + aDefaultFile.get(), + aFileExtension.get(), + mForceSave, &fileToUse); + + if (rv == NS_ERROR_NOT_AVAILABLE) { + // we need to use the async version -> nsIHelperAppLauncherDialog.promptForSaveToFileAsync. + rv = mDialog->PromptForSaveToFileAsync(this, + GetDialogParent(), + aDefaultFile.get(), + aFileExtension.get(), + mForceSave); + } else { + SaveDestinationAvailable(rv == NS_OK ? fileToUse : nullptr); } } diff --git a/uriloader/exthandler/nsIHelperAppLauncherDialog.idl b/uriloader/exthandler/nsIHelperAppLauncherDialog.idl index f8190e7..d15f133 100644 --- a/uriloader/exthandler/nsIHelperAppLauncherDialog.idl +++ b/uriloader/exthandler/nsIHelperAppLauncherDialog.idl @@ -21,7 +21,7 @@ interface nsIFile; * will access methods of the nsIHelperAppLauncher passed in to show() * in order to cause a "save to disk" or "open using" action. */ -[scriptable, uuid(bfc739f3-8d75-4034-a6f8-1039a5996bad)] +[scriptable, uuid(3ae4dca8-ac91-4891-adcf-3fbebed6170e)] interface nsIHelperAppLauncherDialog : nsISupports { /** * This request is passed to the helper app dialog because Gecko can not @@ -58,6 +58,32 @@ interface nsIHelperAppLauncherDialog : nsISupports { in unsigned long aReason); /** + * Invoke a save-to-file dialog instead of the full fledged helper app dialog. + * Returns the a nsIFile for the file name/location selected. + * + * @param aLauncher + * A nsIHelperAppLauncher to be invoked when a file is selected. + * @param aWindowContext + * Window associated with action. + * @param aDefaultFileName + * Default file name to provide (can be null) + * @param aSuggestedFileExtension + * Sugested file extension + * @param aForcePrompt + * Set to true to force prompting the user for thet file + * name/location, otherwise perferences may control if the user is + * prompted. + * + * @throws NS_ERROR_NOT_AVAILABLE if the async version of this function + * should be used. + */ + nsIFile promptForSaveToFile(in nsIHelperAppLauncher aLauncher, + in nsISupports aWindowContext, + in wstring aDefaultFileName, + in wstring aSuggestedFileExtension, + in boolean aForcePrompt); + + /** * Async invoke a save-to-file dialog instead of the full fledged helper app * dialog. When the file is chosen (or the dialog is closed), the callback * in aLauncher (aLauncher.saveDestinationAvailable) is called with the diff --git a/uriloader/exthandler/tests/mochitest/test_unsafeBidiChars.xhtml b/uriloader/exthandler/tests/mochitest/test_unsafeBidiChars.xhtml index 3e5fa41..6363e55 100644 --- a/uriloader/exthandler/tests/mochitest/test_unsafeBidiChars.xhtml +++ b/uriloader/exthandler/tests/mochitest/test_unsafeBidiChars.xhtml @@ -84,6 +84,9 @@ function load() { "The filename should be correctly sanitized"); gCallback(); }, + promptForSaveToFile: function(aLauncher, aWindowContext, aDefaultFileName, aSuggestedFileExtension, aForcePrompt) { + return null; + }, QueryInterface: function(aIID) { netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); if (aIID.equals(SpecialPowers.Ci.nsISupports) || diff --git a/uriloader/exthandler/tests/unit_ipc/test_encoding.js b/uriloader/exthandler/tests/unit_ipc/test_encoding.js index a46c899..ea6a981 100644 --- a/uriloader/exthandler/tests/unit_ipc/test_encoding.js +++ b/uriloader/exthandler/tests/unit_ipc/test_encoding.js @@ -61,7 +61,9 @@ HelperAppDlg.prototype = { show: function (launcher, ctx, reason, usePrivateUI) { launcher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.saveToFile; launcher.launchWithApplication(null, false); - } + }, + + promptForSaveToFile: function (launcher, ctx, defaultFile, suggestedExtension, forcePrompt) { } } // Stolen from XPCOMUtils, since this handy function is not public there -- 2.1.4