Bug 1042876 - Update newtab endpoints to new v2/links [r=adw]

Point to new endpoints that can be strict on types, so request the appropriate content type.
This commit is contained in:
Ed Lee 2014-07-23 14:33:13 -07:00
Родитель 14f090dfa9
Коммит b06eddffed
4 изменённых файлов: 6 добавлений и 92 удалений

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

@ -1531,7 +1531,7 @@ pref("browser.newtabpage.rows", 3);
pref("browser.newtabpage.columns", 5);
// directory tiles download URL
pref("browser.newtabpage.directory.source", "chrome://global/content/directoryLinks.json");
pref("browser.newtabpage.directory.source", "https://tiles.up.mozillalabs.com/v2/links/fetch");
// endpoint to send newtab click and view pings
pref("browser.newtabpage.directory.ping", "https://tiles.up.mozillalabs.com/v2/links/");

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

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

@ -37,9 +37,6 @@ toolkit.jar:
* content/global/customizeToolbar.js (customizeToolbar.js)
content/global/customizeToolbar.xul (customizeToolbar.xul)
content/global/devicestorage.properties (devicestorage.properties)
#ifndef ANDROID
content/global/directoryLinks.json (directoryLinks.json)
#endif
content/global/editMenuOverlay.js (editMenuOverlay.js)
*+ content/global/editMenuOverlay.xul (editMenuOverlay.xul)
content/global/finddialog.js (finddialog.js)

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

@ -28,6 +28,7 @@ XPCOMUtils.defineLazyGetter(this, "gTextDecoder", () => {
// The filename where directory links are stored locally
const DIRECTORY_LINKS_FILE = "directoryLinks.json";
const DIRECTORY_LINKS_TYPE = "application/json";
// The preference that tells whether to match the OS locale
const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
@ -194,7 +195,6 @@ let DirectoryLinksProvider = {
_fetchAndCacheLinks: function DirectoryLinksProvider_fetchAndCacheLinks(uri) {
let deferred = Promise.defer();
let xmlHttp = new XMLHttpRequest();
xmlHttp.overrideMimeType("application/json");
let self = this;
xmlHttp.onload = function(aResponse) {
@ -217,6 +217,10 @@ let DirectoryLinksProvider = {
try {
xmlHttp.open('POST', 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(JSON.stringify({
locale: this.locale,
}));