97 lines
3.1 KiB
Diff
97 lines
3.1 KiB
Diff
--- a/browser/modules/DirectoryLinksProvider.jsm
|
|
+++ b/browser/modules/DirectoryLinksProvider.jsm
|
|
@@ -86,7 +86,7 @@ var DirectoryLinksProvider = {
|
|
* @return the selected locale or "en-US" if none is selected
|
|
*/
|
|
get locale() {
|
|
- return Services.locale.getRequestedLocale() || "en-US";
|
|
+ return "en-US";
|
|
},
|
|
|
|
/**
|
|
@@ -138,13 +138,6 @@ var DirectoryLinksProvider = {
|
|
},
|
|
|
|
_fetchAndCacheLinks: function DirectoryLinksProvider_fetchAndCacheLinks(uri) {
|
|
- // Replace with the same display locale used for selecting links data
|
|
- uri = uri.replace("%LOCALE%", this.locale);
|
|
- uri = uri.replace("%CHANNEL%", UpdateUtils.UpdateChannel);
|
|
-
|
|
- return this._downloadJsonData(uri).then(json => {
|
|
- return OS.File.writeAtomic(this._directoryFilePath, json, {tmpPath: this._directoryFilePath + ".tmp"});
|
|
- });
|
|
},
|
|
|
|
/**
|
|
@@ -153,33 +146,6 @@ var DirectoryLinksProvider = {
|
|
* @return promise resolved to json string, "{}" returned if status != 200
|
|
*/
|
|
_downloadJsonData: function DirectoryLinksProvider__downloadJsonData(uri) {
|
|
- return new Promise((resolve, reject) => {
|
|
- let xmlHttp = this._newXHR();
|
|
-
|
|
- xmlHttp.onload = function(aResponse) {
|
|
- let json = this.responseText;
|
|
- if (this.status && this.status != 200) {
|
|
- json = "{}";
|
|
- }
|
|
- resolve(json);
|
|
- };
|
|
-
|
|
- xmlHttp.onerror = function(e) {
|
|
- reject("Fetching " + uri + " results in error code: " + e.target.status);
|
|
- };
|
|
-
|
|
- try {
|
|
- xmlHttp.open("GET", uri);
|
|
- // Override the type so XHR doesn't complain about not well-formed XML
|
|
- xmlHttp.overrideMimeType(DIRECTORY_LINKS_TYPE);
|
|
- // Set the appropriate request type for servers that require correct types
|
|
- xmlHttp.setRequestHeader("Content-Type", DIRECTORY_LINKS_TYPE);
|
|
- xmlHttp.send();
|
|
- } catch (e) {
|
|
- reject("Error fetching " + uri);
|
|
- Cu.reportError(e);
|
|
- }
|
|
- });
|
|
},
|
|
|
|
/**
|
|
@@ -187,30 +187,6 @@
|
|
* @return promise resolved immediately if no download needed, or upon completion
|
|
*/
|
|
_fetchAndCacheLinksIfNecessary: function DirectoryLinksProvider_fetchAndCacheLinksIfNecessary(forceDownload = false) {
|
|
- if (this._downloadDeferred) {
|
|
- // fetching links already - just return the promise
|
|
- return this._downloadDeferred.promise;
|
|
- }
|
|
-
|
|
- if (forceDownload || this._needsDownload) {
|
|
- this._downloadDeferred = PromiseUtils.defer();
|
|
- this._fetchAndCacheLinks(this._linksURL).then(() => {
|
|
- // the new file was successfully downloaded and cached, so update a timestamp
|
|
- this._lastDownloadMS = Date.now();
|
|
- this._downloadDeferred.resolve();
|
|
- this._downloadDeferred = null;
|
|
- this._callObservers("onManyLinksChanged")
|
|
- },
|
|
- error => {
|
|
- this._downloadDeferred.resolve();
|
|
- this._downloadDeferred = null;
|
|
- this._callObservers("onDownloadFail");
|
|
- });
|
|
- return this._downloadDeferred.promise;
|
|
- }
|
|
-
|
|
- // download is not needed
|
|
- return Promise.resolve();
|
|
},
|
|
|
|
/**
|
|
@@ -376,3 +318,4 @@ var DirectoryLinksProvider = {
|
|
this._observers.clear();
|
|
}
|
|
};
|
|
+
|
|
|