diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1880,8 +1880,10 @@ pref("dom.ipc.reportProcessHangs", true) // Enable ReadingList browser UI by default. pref("browser.readinglist.enabled", true); pref("browser.readinglist.sidebarEverOpened", false); // Enable the readinglist engine by default. pref("readinglist.scheduler.enabled", true); pref("readinglist.server", "https://readinglist.services.mozilla.com/v1"); + +pref("pocket.enabled", true); diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -7781,8 +7781,78 @@ let PanicButtonNotifier = { Cu.reportError(ex); } }, close: function() { let popup = document.getElementById("panic-button-success-notification"); popup.hidePopup(); }, }; + +let PocketButton = { + onCommand: function(aURI) { + dump("Pocketing " + aURI.spec + "\n"); + + // Is user is already logged in to Pocket (via FxA or pocket.com cookies) + if (this.isLoggedIn()) { + this.sendLink(aURI); + return; + } + + // Need to show a panel asking the user to create an FxA account (or + // opt-in to using Pocket if they already do?), or log in with an existing + // pocket.com account. Each action opens a new tab with the relevant page. + this.showCreateAccount(); + // XXX do we want to pocket aURI for the page they initiated this on? + }, + + isLoggedIn: function() { + dump("isLoggedIn?\n"); + return (Math.random() < 0.5); + }, + + sendLink: function(aURI) { + dump("sendLink?\n"); + this.showLinkSent(); + // pocket-send-panel + }, + + showCreateAccount: function() { + dump("showCreateAccount\n"); + let panel = document.getElementById("pocket-signin-panel"); + panel.hidden = false; + let anchor = this._getButtonAnchor(); + panel.openPopup(anchor, "bottomcenter topleft", 0, 0, false, false); + }, + + showLinkSent: function() { + dump("showLinkSent\n"); + let panel = document.getElementById("pocket-send-panel"); + panel.hidden = false; + let anchor = this._getButtonAnchor(); + panel.openPopup(anchor, "bottomcenter topleft", 0, 0, false, false); + }, + + _getButtonAnchor: function() { + // XXX Why is this so gross? Is there no better way? + //