From 7a8fca2a06fae65f612effcf6e4126393a2fce6f Mon Sep 17 00:00:00 2001 From: Abhinav Koppula Date: Wed, 18 Mar 2015 16:22:00 -0400 Subject: [PATCH] Bug 1127337 - Show article favicon in the browser tab in reader mode. r=jaws --- browser/modules/ReaderParent.jsm | 14 +++++++++++++- toolkit/components/places/PlacesUtils.jsm | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/browser/modules/ReaderParent.jsm b/browser/modules/ReaderParent.jsm index 50e698f842c5..3b4f76d7278c 100644 --- a/browser/modules/ReaderParent.jsm +++ b/browser/modules/ReaderParent.jsm @@ -13,6 +13,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Task.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils","resource://gre/modules/PlacesUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode", "resource://gre/modules/ReaderMode.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "ReadingList", "resource:///modules/readinglist/ReadingList.jsm"); @@ -56,7 +57,18 @@ let ReaderParent = { break; case "Reader:FaviconRequest": { - // XXX: To implement. + 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:ListStatusRequest": diff --git a/toolkit/components/places/PlacesUtils.jsm b/toolkit/components/places/PlacesUtils.jsm index 03fc0ec4fb8a..4d3f139a583f 100644 --- a/toolkit/components/places/PlacesUtils.jsm +++ b/toolkit/components/places/PlacesUtils.jsm @@ -1562,7 +1562,7 @@ this.PlacesUtils = { uri = PlacesUtils.favicons.getFaviconLinkForIcon(uri); deferred.resolve(uri); } else { - deferred.reject(); + deferred.reject("favicon not found for uri"); } }); return deferred.promise;