Bug 1114624 - Don't register the legacy nsIDownloadManager implementation of nsITransfer by default anymore. r=mak,marco,margaret,fabrice

This commit is contained in:
Paolo Amadini 2015-02-05 11:19:01 +00:00
Родитель 1c1f940fd9
Коммит c3952b24ed
10 изменённых файлов: 2 добавлений и 143 удалений

Просмотреть файл

@ -1171,20 +1171,3 @@ Services.obs.addObserver(function resetProfile(subject, topic, data) {
.getService(Ci.nsIAppStartup); .getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eForceQuit); appStartup.quit(Ci.nsIAppStartup.eForceQuit);
}, 'b2g-reset-profile', false); }, 'b2g-reset-profile', false);
/**
* CID of our implementation of nsITransfer.
*/
const kTransferCid = Components.ID("{1b4c85df-cbdd-4bb6-b04e-613caece083c}");
/**
* Contract ID of the service implementing nsITransfer.
*/
const kTransferContractId = "@mozilla.org/transfer;1";
// Override Toolkit's nsITransfer implementation with the one from the
// JavaScript API for downloads. This will eventually be removed when
// nsIDownloadManager will not be available anymore (bug 851471).
Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
.registerFactory(kTransferCid, "",
kTransferContractId, null);

Просмотреть файл

@ -1,3 +0,0 @@
component {49507fe5-2cee-4824-b6a3-e999150ce9b8} DownloadsStartup.js
contract @mozilla.org/browser/downloadsstartup;1 {49507fe5-2cee-4824-b6a3-e999150ce9b8}
category profile-after-change DownloadsStartup @mozilla.org/browser/downloadsstartup;1

Просмотреть файл

@ -1,62 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80 filetype=javascript: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* This component enables the JavaScript API for downloads at startup. This
* will eventually be removed when nsIDownloadManager will not be available
* anymore (bug 851471).
*/
"use strict";
////////////////////////////////////////////////////////////////////////////////
//// Globals
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
/**
* CID and Contract ID of the JavaScript implementation of nsITransfer.
*/
const kTransferCid = Components.ID("{1b4c85df-cbdd-4bb6-b04e-613caece083c}");
const kTransferContractId = "@mozilla.org/transfer;1";
////////////////////////////////////////////////////////////////////////////////
//// DownloadsStartup
function DownloadsStartup() { }
DownloadsStartup.prototype = {
classID: Components.ID("{49507fe5-2cee-4824-b6a3-e999150ce9b8}"),
_xpcom_factory: XPCOMUtils.generateSingletonFactory(DownloadsStartup),
//////////////////////////////////////////////////////////////////////////////
//// nsISupports
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
//////////////////////////////////////////////////////////////////////////////
//// nsIObserver
observe: function DS_observe(aSubject, aTopic, aData)
{
// Override Toolkit's nsITransfer implementation with the one from the
// JavaScript API for downloads.
Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
.registerFactory(kTransferCid, "",
kTransferContractId, null);
},
};
////////////////////////////////////////////////////////////////////////////////
//// Module
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DownloadsStartup]);

Просмотреть файл

@ -9,11 +9,6 @@ BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
JAR_MANIFESTS += ['jar.mn'] JAR_MANIFESTS += ['jar.mn']
EXTRA_COMPONENTS += [
'BrowserDownloads.manifest',
'DownloadsStartup.js',
]
EXTRA_JS_MODULES += [ EXTRA_JS_MODULES += [
'DownloadsCommon.jsm', 'DownloadsCommon.jsm',
'DownloadsLogger.jsm', 'DownloadsLogger.jsm',

Просмотреть файл

@ -383,8 +383,6 @@
@RESPATH@/browser/components/nsBrowserGlue.js @RESPATH@/browser/components/nsBrowserGlue.js
@RESPATH@/browser/components/nsSetDefaultBrowser.manifest @RESPATH@/browser/components/nsSetDefaultBrowser.manifest
@RESPATH@/browser/components/nsSetDefaultBrowser.js @RESPATH@/browser/components/nsSetDefaultBrowser.js
@RESPATH@/browser/components/BrowserDownloads.manifest
@RESPATH@/browser/components/DownloadsStartup.js
@RESPATH@/browser/components/devtools-clhandler.manifest @RESPATH@/browser/components/devtools-clhandler.manifest
@RESPATH@/browser/components/devtools-clhandler.js @RESPATH@/browser/components/devtools-clhandler.js
@RESPATH@/browser/components/webideCli.js @RESPATH@/browser/components/webideCli.js

Просмотреть файл

@ -21,24 +21,6 @@ let Log = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog.i.bi
XPCOMUtils.defineLazyGetter(this, "strings", XPCOMUtils.defineLazyGetter(this, "strings",
() => Services.strings.createBundle("chrome://browser/locale/browser.properties")); () => Services.strings.createBundle("chrome://browser/locale/browser.properties"));
/**
* CID of Downloads.jsm's implementation of nsITransfer.
*/
const kTransferCid = Components.ID("{1b4c85df-cbdd-4bb6-b04e-613caece083c}");
/**
* Contract ID of the service implementing nsITransfer.
*/
const kTransferContractId = "@mozilla.org/transfer;1";
// Override Toolkit's nsITransfer implementation with the one from the
// JavaScript API for downloads. This will eventually be removed when
// nsIDownloadManager will not be available anymore (bug 851471). The
// old code in this module will be removed in bug 899110.
Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
.registerFactory(kTransferCid, "",
kTransferContractId, null);
Object.defineProperty(this, "window", Object.defineProperty(this, "window",
{ get: () => Services.wm.getMostRecentWindow("navigator:browser") }); { get: () => Services.wm.getMostRecentWindow("navigator:browser") });

Просмотреть файл

@ -189,7 +189,6 @@ static const Module::ContractIDEntry kToolkitContracts[] = {
#endif #endif
{ NS_DOWNLOADMANAGER_CONTRACTID, &kNS_DOWNLOADMANAGER_CID }, { NS_DOWNLOADMANAGER_CONTRACTID, &kNS_DOWNLOADMANAGER_CID },
{ NS_DOWNLOADPLATFORM_CONTRACTID, &kNS_DOWNLOADPLATFORM_CID }, { NS_DOWNLOADPLATFORM_CONTRACTID, &kNS_DOWNLOADPLATFORM_CID },
{ NS_TRANSFER_CONTRACTID, &kNS_DOWNLOAD_CID },
{ NS_FIND_SERVICE_CONTRACTID, &kNS_FIND_SERVICE_CID }, { NS_FIND_SERVICE_CONTRACTID, &kNS_FIND_SERVICE_CID },
{ NS_TYPEAHEADFIND_CONTRACTID, &kNS_TYPEAHEADFIND_CID }, { NS_TYPEAHEADFIND_CONTRACTID, &kNS_TYPEAHEADFIND_CID },
#ifdef MOZ_URL_CLASSIFIER #ifdef MOZ_URL_CLASSIFIER

Просмотреть файл

@ -1,8 +1,2 @@
component {1b4c85df-cbdd-4bb6-b04e-613caece083c} DownloadLegacy.js component {1b4c85df-cbdd-4bb6-b04e-613caece083c} DownloadLegacy.js
contract @mozilla.org/transfer;1 {1b4c85df-cbdd-4bb6-b04e-613caece083c}
# The following contract definition is commented out because the same contract
# is also implemented in "toolkit/components/downloads". To use the component
# in this folder experimentally, the contract must be registered manually. When
# the other folder is not included in builds anymore (bug 851471), we'll be able
# to define the contract implementation in this manifest.
# contract @mozilla.org/transfer;1 {1b4c85df-cbdd-4bb6-b04e-613caece083c}

Просмотреть файл

@ -320,13 +320,7 @@ function promiseStartLegacyDownload(aSourceUrl, aOptions) {
persist.persistFlags |= persist.persistFlags |=
Ci.nsIWebBrowserPersist.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION; Ci.nsIWebBrowserPersist.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
// We must create the nsITransfer implementation using its class ID because let transfer = Cc["@mozilla.org/transfer;1"].createInstance(Ci.nsITransfer);
// the "@mozilla.org/transfer;1" contract is currently implemented in
// "toolkit/components/downloads". When the other folder is not included in
// builds anymore (bug 851471), we'll be able to use the contract ID.
let transfer =
Components.classesByID["{1b4c85df-cbdd-4bb6-b04e-613caece083c}"]
.createInstance(Ci.nsITransfer);
let deferred = Promise.defer(); let deferred = Promise.defer();
@ -833,18 +827,4 @@ add_task(function test_common_initialize()
registrar.unregisterFactory(cid, mockFactory); registrar.unregisterFactory(cid, mockFactory);
registrar.registerFactory(cid, "", contractID, oldFactory); registrar.registerFactory(cid, "", contractID, oldFactory);
}); });
// We must also make sure that nsIExternalHelperAppService uses the
// JavaScript implementation of nsITransfer, because the
// "@mozilla.org/transfer;1" contract is currently implemented in
// "toolkit/components/downloads". When the other folder is not included in
// builds anymore (bug 851471), we'll not need to do this anymore.
let transferContractID = "@mozilla.org/transfer;1";
let transferNewCid = Components.ID("{1b4c85df-cbdd-4bb6-b04e-613caece083c}");
let transferCid = registrar.contractIDToCID(transferContractID);
registrar.registerFactory(transferNewCid, "", transferContractID, null);
do_register_cleanup(function () {
registrar.registerFactory(transferCid, "", transferContractID, null);
});
}); });

Просмотреть файл

@ -142,13 +142,6 @@ this.startup = function(window) {
// Wait for XUL window loading // Wait for XUL window loading
yield deferredWindowLoad.promise; yield deferredWindowLoad.promise;
// Override Toolkit's nsITransfer implementation with the one from the
// JavaScript API for downloads. This will eventually be removed when
// nsIDownloadManager will not be available anymore (bug 851471).
Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
.registerFactory(Components.ID("{1b4c85df-cbdd-4bb6-b04e-613caece083c}"),
"", "@mozilla.org/transfer;1", null);
// Load these modules here because they aren't needed right at startup, // Load these modules here because they aren't needed right at startup,
// but they need to be loaded to perform some initialization steps. // but they need to be loaded to perform some initialization steps.
Cu.import("resource://gre/modules/Payment.jsm"); Cu.import("resource://gre/modules/Payment.jsm");