diff options
author | Ascrod <32915892+Ascrod@users.noreply.github.com> | 2018-05-13 09:35:23 -0400 |
---|---|---|
committer | Ascrod <32915892+Ascrod@users.noreply.github.com> | 2018-05-15 21:06:41 -0500 |
commit | 9ef464a5ac0a17135a0f7b4fef070bb4f7fbe44c (patch) | |
tree | 05dd6c130cbbb80e5512a5c199c010aa4b3516e5 /browser | |
parent | b70d884598e1e14b99190e1e5c349553ff59849b (diff) | |
download | uxp-9ef464a5ac0a17135a0f7b4fef070bb4f7fbe44c.tar.gz |
Change Reader API to use events, remove messaging.
Diffstat (limited to 'browser')
-rw-r--r-- | browser/base/content/tab-content.js | 2 | ||||
-rw-r--r-- | browser/modules/ReaderParent.jsm | 53 |
2 files changed, 1 insertions, 54 deletions
diff --git a/browser/base/content/tab-content.js b/browser/base/content/tab-content.js index 7e803796ab..a57dc66074 100644 --- a/browser/base/content/tab-content.js +++ b/browser/base/content/tab-content.js @@ -307,7 +307,7 @@ var AboutReaderListener = { if (content.document.body) { // Update the toolbar icon to show the "reader active" icon. sendAsyncMessage("Reader:UpdateReaderButton"); - new AboutReader(global, content, this._articlePromise); + new AboutReader(content, this._articlePromise); this._articlePromise = null; } break; diff --git a/browser/modules/ReaderParent.jsm b/browser/modules/ReaderParent.jsm index fcc0cc92b7..c81aa9905b 100644 --- a/browser/modules/ReaderParent.jsm +++ b/browser/modules/ReaderParent.jsm @@ -19,8 +19,6 @@ const gStringBundle = Services.strings.createBundle("chrome://global/locale/abou var ReaderParent = { MESSAGES: [ - "Reader:ArticleGet", - "Reader:FaviconRequest", "Reader:UpdateReaderButton", ], @@ -33,38 +31,6 @@ var ReaderParent = { receiveMessage(message) { switch (message.name) { - case "Reader:ArticleGet": - this._getArticle(message.data.url, message.target).then((article) => { - // Make sure the target browser is still alive before trying to send data back. - if (message.target.messageManager) { - message.target.messageManager.sendAsyncMessage("Reader:ArticleData", { article: article }); - } - }, e => { - if (e && e.newURL) { - // Make sure the target browser is still alive before trying to send data back. - if (message.target.messageManager) { - message.target.messageManager.sendAsyncMessage("Reader:ArticleData", { newURL: e.newURL }); - } - } - }); - break; - - case "Reader:FaviconRequest": { - if (message.target.messageManager) { - let faviconUrl = PlacesUtils.promiseFaviconLinkUrl(message.data.url); - faviconUrl.then(function onResolution(favicon) { - message.target.messageManager.sendAsyncMessage("Reader:FaviconReturn", { - url: message.data.url, - faviconUrl: favicon.path.replace(/^favicon:/, "") - }); - }, - function onRejection(reason) { - Cu.reportError("Error requesting favicon URL for about:reader content: " + reason); - }).catch(Cu.reportError); - } - break; - } - case "Reader:UpdateReaderButton": { let browser = message.target; if (message.data && message.data.isArticle !== undefined) { @@ -132,24 +98,5 @@ var ReaderParent = { let win = event.target.ownerGlobal; let browser = win.gBrowser.selectedBrowser; browser.messageManager.sendAsyncMessage("Reader:ToggleReaderMode"); - }, - - /** - * Gets an article for a given URL. This method will download and parse a document. - * - * @param url The article URL. - * @param browser The browser where the article is currently loaded. - * @return {Promise} - * @resolves JS object representing the article, or null if no article is found. - */ - async _getArticle(url, browser) { - return await ReaderMode.downloadAndParseDocument(url).catch(e => { - if (e && e.newURL) { - // Pass up the error so we can navigate the browser in question to the new URL: - throw e; - } - Cu.reportError("Error downloading and parsing document: " + e); - return null; - }); } }; |