Bug 1215694 move pocket to a system addon, r=Gijs, r=glandium

part 1: reorganize file locations, r=Gijs
  part 2: remove built-in pocket code, r=Gijs
  part 3: l10n support, r=glandium
  part 4: move code/functionality from part 2 into the addon, r=Gijs
  part 5: remove dead code, r=Gijs
  part 6: create a simple api for addons to add to reader mode, r=Gijs
  part 7: various test fixes related to cui behaviour and pocket, r=me
This commit is contained in:
Shane Caraveo 2015-12-29 15:40:52 -08:00
parent c0d31dc405
commit 6d58cc3ee1
106 changed files with 799 additions and 759 deletions

View File

@ -1611,13 +1611,6 @@ pref("reader.parse-node-limit", 0);
// and because (normally) these errors are not persisted anywhere. // and because (normally) these errors are not persisted anywhere.
pref("reader.errors.includeURLs", true); pref("reader.errors.includeURLs", true);
pref("browser.pocket.enabled", true);
pref("browser.pocket.api", "api.getpocket.com");
pref("browser.pocket.site", "getpocket.com");
pref("browser.pocket.oAuthConsumerKey", "40249-e88c401e1b1f2242d9e441c4");
pref("browser.pocket.useLocaleList", true);
pref("browser.pocket.enabledLocales", "cs de en-GB en-US en-ZA es-ES es-MX fr hu it ja ja-JP-mac ko nl pl pt-BR pt-PT ru zh-CN zh-TW");
pref("view_source.tab", true); pref("view_source.tab", true);
pref("dom.serviceWorkers.enabled", true); pref("dom.serviceWorkers.enabled", true);

View File

@ -79,10 +79,6 @@
label="&saveLinkCmd.label;" label="&saveLinkCmd.label;"
accesskey="&saveLinkCmd.accesskey;" accesskey="&saveLinkCmd.accesskey;"
oncommand="gContextMenu.saveLink();"/> oncommand="gContextMenu.saveLink();"/>
<menuitem id="context-savelinktopocket"
label="&saveLinkToPocketCmd.label;"
accesskey="&saveLinkToPocketCmd.accesskey;"
oncommand="gContextMenu.saveLinkToPocket();"/>
<menu id="context-marklinkMenu" label="&social.marklinkMenu.label;" <menu id="context-marklinkMenu" label="&social.marklinkMenu.label;"
accesskey="&social.marklinkMenu.accesskey;"> accesskey="&social.marklinkMenu.accesskey;">
<menupopup/> <menupopup/>
@ -270,10 +266,6 @@
label="&savePageCmd.label;" label="&savePageCmd.label;"
accesskey="&savePageCmd.accesskey2;" accesskey="&savePageCmd.accesskey2;"
oncommand="gContextMenu.savePageAs();"/> oncommand="gContextMenu.savePageAs();"/>
<menuitem id="context-pocket"
label="&saveToPocketCmd.label;"
accesskey="&saveToPocketCmd.accesskey;"
oncommand="gContextMenu.savePageToPocket();"/>
<menu id="context-markpageMenu" label="&social.markpageMenu.label;" <menu id="context-markpageMenu" label="&social.markpageMenu.label;"
accesskey="&social.markpageMenu.accesskey;"> accesskey="&social.markpageMenu.accesskey;">
<menupopup/> <menupopup/>

View File

@ -413,7 +413,6 @@
oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);" oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);"
onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);" onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
onpopupshowing="BookmarkingUI.onMainMenuPopupShowing(event); onpopupshowing="BookmarkingUI.onMainMenuPopupShowing(event);
BookmarkingUI.updatePocketItemVisibility('menu_');
if (!this.parentNode._placesView) if (!this.parentNode._placesView)
new PlacesMenu(event, 'place:folder=BOOKMARKS_MENU');" new PlacesMenu(event, 'place:folder=BOOKMARKS_MENU');"
tooltip="bhTooltip" popupsinherittooltip="true"> tooltip="bhTooltip" popupsinherittooltip="true">
@ -422,12 +421,6 @@
command="Browser:ShowAllBookmarks" command="Browser:ShowAllBookmarks"
key="manBookmarkKb"/> key="manBookmarkKb"/>
<menuseparator id="organizeBookmarksSeparator"/> <menuseparator id="organizeBookmarksSeparator"/>
<menuitem id="menu_pocket" label="&pocketMenuitem.label;"
#ifndef XP_MACOSX
class="menuitem-iconic"
#endif
oncommand="openUILink(Pocket.listURL, event);"/>
<menuseparator id="menu_pocketSeparator"/>
<menuitem id="menu_bookmarkThisPage" <menuitem id="menu_bookmarkThisPage"
command="Browser:AddBookmarkAs" command="Browser:AddBookmarkAs"
observes="bookmarkThisPageBroadcaster" observes="bookmarkThisPageBroadcaster"

View File

@ -1554,12 +1554,6 @@ var BookmarkingUI = {
PlacesCommandHook.updateBookmarkAllTabsCommand(); PlacesCommandHook.updateBookmarkAllTabsCommand();
}, },
updatePocketItemVisibility: function BUI_updatePocketItemVisibility(prefix) {
let hidden = !CustomizableUI.getPlacementOfWidget("pocket-button");
document.getElementById(prefix + "pocket").hidden = hidden;
document.getElementById(prefix + "pocketSeparator").hidden = hidden;
},
_showBookmarkedNotification: function BUI_showBookmarkedNotification() { _showBookmarkedNotification: function BUI_showBookmarkedNotification() {
function getCenteringTransformForRects(rectToPosition, referenceRect) { function getCenteringTransformForRects(rectToPosition, referenceRect) {
let topDiff = referenceRect.top - rectToPosition.top; let topDiff = referenceRect.top - rectToPosition.top;
@ -1681,7 +1675,6 @@ var BookmarkingUI = {
onPanelMenuViewShowing: function BUI_onViewShowing(aEvent) { onPanelMenuViewShowing: function BUI_onViewShowing(aEvent) {
this._updateBookmarkPageMenuItem(); this._updateBookmarkPageMenuItem();
this.updatePocketItemVisibility("panelMenu_");
// Update checked status of the toolbar toggle. // Update checked status of the toolbar toggle.
let viewToolbar = document.getElementById("panelMenu_viewBookmarksToolbar"); let viewToolbar = document.getElementById("panelMenu_viewBookmarksToolbar");
let personalToolbar = document.getElementById("PersonalToolbar"); let personalToolbar = document.getElementById("PersonalToolbar");

View File

@ -1348,9 +1348,8 @@ SocialMarks = {
// also means that populateToolbarPalette must be called prior to using this // also means that populateToolbarPalette must be called prior to using this
// method, otherwise you get a big fat zero. For our use case with context // method, otherwise you get a big fat zero. For our use case with context
// menu's, this is ok. // menu's, this is ok.
let tbh = this._toolbarHelper;
return [p for (p of Social.providers) if (p.markURL && return [p for (p of Social.providers) if (p.markURL &&
document.getElementById(tbh.idFromOrigin(p.origin)))]; document.getElementById(this._toolbarHelper.idFromOrigin(p.origin)))];
}, },
populateContextMenu: function() { populateContextMenu: function() {

View File

@ -53,37 +53,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "WindowsUIUtils",
"@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils"); "@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils");
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager", XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
"resource://gre/modules/LightweightThemeManager.jsm"); "resource://gre/modules/LightweightThemeManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
"resource:///modules/Pocket.jsm");
// Can't use XPCOMUtils for these because the scripts try to define the variables
// on window, and so the defineProperty inside defineLazyGetter fails.
Object.defineProperty(window, "pktApi", {
get: function() {
// Avoid this getter running again:
delete window.pktApi;
Services.scriptloader.loadSubScript("chrome://browser/content/pocket/pktApi.js", window);
return window.pktApi;
},
configurable: true,
enumerable: true
});
function pktUIGetter(prop) {
return {
get: function() {
// Avoid either of these getters running again:
delete window.pktUI;
delete window.pktUIMessaging;
Services.scriptloader.loadSubScript("chrome://browser/content/pocket/main.js", window);
return window[prop];
},
configurable: true,
enumerable: true
};
}
Object.defineProperty(window, "pktUI", pktUIGetter("pktUI"));
Object.defineProperty(window, "pktUIMessaging", pktUIGetter("pktUIMessaging"));
XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", function() { XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", function() {
return Services.strings.createBundle('chrome://browser/locale/browser.properties'); return Services.strings.createBundle('chrome://browser/locale/browser.properties');

View File

@ -620,9 +620,9 @@
fullscreentoolbar="true" mode="icons" customizable="true" fullscreentoolbar="true" mode="icons" customizable="true"
iconsize="small" iconsize="small"
#ifdef MOZ_DEV_EDITION #ifdef MOZ_DEV_EDITION
defaultset="urlbar-container,search-container,developer-button,bookmarks-menu-button,pocket-button,downloads-button,home-button,loop-button" defaultset="urlbar-container,search-container,developer-button,bookmarks-menu-button,downloads-button,home-button,loop-button"
#else #else
defaultset="urlbar-container,search-container,bookmarks-menu-button,pocket-button,downloads-button,home-button,loop-button" defaultset="urlbar-container,search-container,bookmarks-menu-button,downloads-button,home-button,loop-button"
#endif #endif
customizationtarget="nav-bar-customization-target" customizationtarget="nav-bar-customization-target"
overflowable="true" overflowable="true"
@ -798,7 +798,6 @@
oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);" oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);"
onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);" onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
onpopupshowing="BookmarkingUI.onPopupShowing(event); onpopupshowing="BookmarkingUI.onPopupShowing(event);
BookmarkingUI.updatePocketItemVisibility('BMB_');
BookmarkingUI.attachPlacesView(event, this);" BookmarkingUI.attachPlacesView(event, this);"
tooltip="bhTooltip" popupsinherittooltip="true"> tooltip="bhTooltip" popupsinherittooltip="true">
<menuitem id="BMB_viewBookmarksSidebar" <menuitem id="BMB_viewBookmarksSidebar"
@ -815,11 +814,6 @@
command="Browser:ShowAllBookmarks" command="Browser:ShowAllBookmarks"
key="manBookmarkKb"/> key="manBookmarkKb"/>
<menuseparator/> <menuseparator/>
<menuitem id="BMB_pocket"
class="menuitem-iconic bookmark-item subviewbutton"
label="&pocketMenuitem.label;"
oncommand="openUILink(Pocket.listURL, event);"/>
<menuseparator id="BMB_pocketSeparator"/>
<menuitem id="BMB_subscribeToPageMenuitem" <menuitem id="BMB_subscribeToPageMenuitem"
#ifndef XP_MACOSX #ifndef XP_MACOSX
class="menuitem-iconic subviewbutton" class="menuitem-iconic subviewbutton"

View File

@ -11,10 +11,6 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
"resource:///modules/CustomizableUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
"resource:///modules/Pocket.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LoginHelper", XPCOMUtils.defineLazyModuleGetter(this, "LoginHelper",
"resource://gre/modules/LoginHelper.jsm"); "resource://gre/modules/LoginHelper.jsm");
@ -216,25 +212,6 @@ nsContextMenu.prototype = {
SimpleServiceDiscovery.services.length > 0 && SimpleServiceDiscovery.services.length > 0 &&
CastingApps.getServicesForVideo(this.target).length > 0; CastingApps.getServicesForVideo(this.target).length > 0;
this.setItemAttr("context-castvideo", "disabled", !shouldShowCast); this.setItemAttr("context-castvideo", "disabled", !shouldShowCast);
this.initPocketItems();
},
initPocketItems: function CM_initPocketItems() {
var showSaveCurrentPageToPocket = !(this.onTextInput || this.onLink ||
this.isContentSelected || this.onImage ||
this.onCanvas || this.onVideo || this.onAudio);
let targetURI = (this.onSaveableLink || this.onPlainTextLink) ? this.linkURI : this.browser.currentURI;
let canPocket = CustomizableUI.getPlacementOfWidget("pocket-button") &&
window.pktApi && window.pktApi.isUserLoggedIn();
canPocket = canPocket && (targetURI.schemeIs("http") || targetURI.schemeIs("https") ||
(targetURI.schemeIs("about") && ReaderMode.getOriginalUrl(targetURI.spec)));
canPocket = canPocket && window.gBrowser && this.browser.getTabBrowser() == window.gBrowser;
this.showItem("context-pocket", canPocket && showSaveCurrentPageToPocket);
let showSaveLinkToPocket = canPocket && !showSaveCurrentPageToPocket &&
(this.onSaveableLink || this.onPlainTextLink);
this.showItem("context-savelinktopocket", showSaveLinkToPocket);
}, },
initViewItems: function CM_initViewItems() { initViewItems: function CM_initViewItems() {
@ -1721,14 +1698,6 @@ nsContextMenu.prototype = {
saveBrowser(this.browser); saveBrowser(this.browser);
}, },
saveLinkToPocket: function CM_saveLinkToPocket() {
Pocket.savePage(this.browser, this.linkURL);
},
savePageToPocket: function CM_saveToPocket() {
Pocket.savePage(this.browser, this.browser.currentURI.spec, this.browser.contentTitle);
},
printFrame: function CM_printFrame() { printFrame: function CM_printFrame() {
PrintUtils.printWindow(this.frameOuterWindowID, this.browser); PrintUtils.printWindow(this.frameOuterWindowID, this.browser);
}, },

View File

@ -12,7 +12,7 @@ var manifest2 = { // used for testing install
origin: "https://test1.example.com", origin: "https://test1.example.com",
sidebarURL: "https://test1.example.com/browser/browser/base/content/test/social/social_sidebar_empty.html", sidebarURL: "https://test1.example.com/browser/browser/base/content/test/social/social_sidebar_empty.html",
iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png", iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png",
version: 1 version: "1.0"
}; };
var manifestUpgrade = { // used for testing install var manifestUpgrade = { // used for testing install
name: "provider 3", name: "provider 3",
@ -20,7 +20,7 @@ var manifestUpgrade = { // used for testing install
sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html", sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html",
workerURL: "https://test2.example.com/browser/browser/base/content/test/social/social_worker.js", workerURL: "https://test2.example.com/browser/browser/base/content/test/social/social_worker.js",
iconURL: "https://test2.example.com/browser/browser/base/content/test/general/moz.png", iconURL: "https://test2.example.com/browser/browser/base/content/test/general/moz.png",
version: 1 version: "1.0"
}; };
function test() { function test() {

View File

@ -48,7 +48,6 @@ function test() {
CustomizableUI.removeWidgetFromArea("social-share-button", CustomizableUI.AREA_NAVBAR) CustomizableUI.removeWidgetFromArea("social-share-button", CustomizableUI.AREA_NAVBAR)
shareButton.remove(); shareButton.remove();
} }
ok(CustomizableUI.inDefaultState, "Should start in default state.");
next(); next();
}); });
} }

View File

@ -13,7 +13,7 @@ var manifest = { // used for testing install
unmarkedIcon: "https://test1.example.com/browser/browser/base/content/test/social/checked.jpg", unmarkedIcon: "https://test1.example.com/browser/browser/base/content/test/social/checked.jpg",
iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png", iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png",
version: 1 version: "1.0"
}; };
function test() { function test() {

View File

@ -13,25 +13,20 @@ var manifest2 = { // used for testing install
unmarkedIcon: "https://test1.example.com/browser/browser/base/content/test/social/checked.jpg", unmarkedIcon: "https://test1.example.com/browser/browser/base/content/test/social/checked.jpg",
iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png", iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png",
version: 1 version: "1.0"
}; };
var manifest3 = { // used for testing install var manifest3 = { // used for testing install
name: "provider test2", name: "provider test2",
origin: "https://test2.example.com", origin: "https://test2.example.com",
sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html", sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html",
iconURL: "https://test2.example.com/browser/browser/base/content/test/general/moz.png", iconURL: "https://test2.example.com/browser/browser/base/content/test/general/moz.png",
version: 1 version: "1.0"
}; };
function test() { function test() {
waitForExplicitFinish(); waitForExplicitFinish();
runSocialTests(tests, undefined, undefined, function () { runSocialTests(tests, undefined, undefined, finish);
// Bug 1232207 - something breaks this on aurora on most platforms
// ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
CustomizableUI.reset();
finish();
});
} }
var tests = { var tests = {

View File

@ -8,18 +8,14 @@ function makeMarkProvider(origin) {
markedIcon: "https://" + origin + ".example.com/browser/browser/base/content/test/social/unchecked.jpg", markedIcon: "https://" + origin + ".example.com/browser/browser/base/content/test/social/unchecked.jpg",
unmarkedIcon: "https://" + origin + ".example.com/browser/browser/base/content/test/social/checked.jpg", unmarkedIcon: "https://" + origin + ".example.com/browser/browser/base/content/test/social/checked.jpg",
iconURL: "https://" + origin + ".example.com/browser/browser/base/content/test/general/moz.png", iconURL: "https://" + origin + ".example.com/browser/browser/base/content/test/general/moz.png",
version: 1 version: "1.0"
} }
} }
function test() { function test() {
waitForExplicitFinish(); waitForExplicitFinish();
runSocialTests(tests, undefined, undefined, function () { runSocialTests(tests, undefined, undefined, finish);
ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
CustomizableUI.reset();
finish();
});
} }
var tests = { var tests = {

View File

@ -17,14 +17,14 @@ var manifest2 = { // used for testing install
workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js", workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js",
statusURL: "https://test1.example.com/browser/browser/base/content/test/social/social_panel.html", statusURL: "https://test1.example.com/browser/browser/base/content/test/social/social_panel.html",
iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png", iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png",
version: 1 version: "1.0"
}; };
var manifest3 = { // used for testing install var manifest3 = { // used for testing install
name: "provider test2", name: "provider test2",
origin: "https://test2.example.com", origin: "https://test2.example.com",
sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html", sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html",
iconURL: "https://test2.example.com/browser/browser/base/content/test/general/moz.png", iconURL: "https://test2.example.com/browser/browser/base/content/test/general/moz.png",
version: 1 version: "1.0"
}; };
@ -45,7 +45,6 @@ function test() {
Services.prefs.clearUserPref("social.remote-install.enabled"); Services.prefs.clearUserPref("social.remote-install.enabled");
// just in case the tests failed, clear these here as well // just in case the tests failed, clear these here as well
Services.prefs.clearUserPref("social.whitelist"); Services.prefs.clearUserPref("social.whitelist");
ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
CustomizableUI.reset(); CustomizableUI.reset();
finishcb(); finishcb();
}); });

View File

@ -22,7 +22,7 @@ var data = {
"author": "Shane Caraveo, Mozilla", "author": "Shane Caraveo, Mozilla",
// optional // optional
"version": 1 "version": "1.0"
} }
function activate(node) { function activate(node) {

View File

@ -20,7 +20,7 @@ var data = {
"author": "Shane Caraveo, Mozilla", "author": "Shane Caraveo, Mozilla",
// optional // optional
"version": 1 "version": "1.0"
} }
function activate(node) { function activate(node) {

View File

@ -126,7 +126,7 @@ onconnect = function(e) {
case "social.manifest": case "social.manifest":
if (updatingManifest) { if (updatingManifest) {
updatingManifest = false; updatingManifest = false;
event.data.data.version = 2; event.data.data.version = "2.0";
apiPort.postMessage({topic: 'social.manifest-set', data: event.data.data}); apiPort.postMessage({topic: 'social.manifest-set', data: event.data.data});
} else if (testPort) { } else if (testPort) {
testPort.postMessage({topic:"social.manifest", data: event.data.data}); testPort.postMessage({topic:"social.manifest", data: event.data.data});

View File

@ -126,18 +126,6 @@ static RedirEntry kRedirMap[] = {
nsIAboutModule::URI_MUST_LOAD_IN_CHILD | nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
nsIAboutModule::MAKE_UNLINKABLE | nsIAboutModule::MAKE_UNLINKABLE |
nsIAboutModule::HIDE_FROM_ABOUTABOUT }, nsIAboutModule::HIDE_FROM_ABOUTABOUT },
{
"pocket-saved", "chrome://browser/content/pocket/panels/saved.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT |
nsIAboutModule::MAKE_UNLINKABLE },
{
"pocket-signup", "chrome://browser/content/pocket/panels/signup.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT |
nsIAboutModule::MAKE_UNLINKABLE },
}; };
static const int kRedirTotal = ArrayLength(kRedirMap); static const int kRedirTotal = ArrayLength(kRedirMap);

View File

@ -117,8 +117,6 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "looppanel", &kNS_BROWSER_ABOUT_REDIRECTOR_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "looppanel", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "loopconversation", &kNS_BROWSER_ABOUT_REDIRECTOR_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "loopconversation", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "reader", &kNS_BROWSER_ABOUT_REDIRECTOR_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "reader", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "pocket-saved", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "pocket-signup", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
#if defined(XP_WIN) #if defined(XP_WIN)
{ NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID }, { NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID },
{ NS_EDGEREADINGLISTEXTRACTOR_CONTRACTID, &kNS_EDGEREADINGLISTEXTRACTOR_CID }, { NS_EDGEREADINGLISTEXTRACTOR_CONTRACTID, &kNS_EDGEREADINGLISTEXTRACTOR_CID },

View File

@ -56,7 +56,7 @@ const kSubviewEvents = [
* The current version. We can use this to auto-add new default widgets as necessary. * The current version. We can use this to auto-add new default widgets as necessary.
* (would be const but isn't because of testing purposes) * (would be const but isn't because of testing purposes)
*/ */
var kVersion = 5; var kVersion = 6;
/** /**
* Buttons removed from built-ins by version they were removed. kVersion must be * Buttons removed from built-ins by version they were removed. kVersion must be
@ -64,7 +64,8 @@ var kVersion = 5;
* version the button is removed in as the value. e.g. "pocket-button": 5 * version the button is removed in as the value. e.g. "pocket-button": 5
*/ */
var ObsoleteBuiltinButtons = { var ObsoleteBuiltinButtons = {
"loop-button": 5 "loop-button": 5,
"pocket-button": 6
}; };
/** /**
@ -222,15 +223,6 @@ var CustomizableUIInternal = {
"loop-button", "loop-button",
]; ];
// Insert the Pocket button after the bookmarks button if it's present.
for (let widgetDefinition of CustomizableWidgets) {
if (widgetDefinition.id == "pocket-button") {
let idx = navbarPlacements.indexOf("bookmarks-menu-button") + 1;
navbarPlacements.splice(idx, 0, widgetDefinition.id);
break;
}
}
if (Services.prefs.getBoolPref(kPrefWebIDEInNavbar)) { if (Services.prefs.getBoolPref(kPrefWebIDEInNavbar)) {
navbarPlacements.push("webide-button"); navbarPlacements.push("webide-button");
} }
@ -3473,8 +3465,8 @@ this.CustomizableUI = {
* *
* null // if the widget is not placed anywhere (ie in the palette) * null // if the widget is not placed anywhere (ie in the palette)
*/ */
getPlacementOfWidget: function(aWidgetId) { getPlacementOfWidget: function(aWidgetId, aOnlyRegistered=true, aDeadAreas=false) {
return CustomizableUIInternal.getPlacementOfWidget(aWidgetId, true); return CustomizableUIInternal.getPlacementOfWidget(aWidgetId, aOnlyRegistered, aDeadAreas);
}, },
/** /**
* Check if a widget can be removed from the area it's in. * Check if a widget can be removed from the area it's in.

View File

@ -18,18 +18,12 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUIUtils",
"resource:///modules/PlacesUIUtils.jsm"); "resource:///modules/PlacesUIUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "RecentlyClosedTabsAndWindowsMenuUtils", XPCOMUtils.defineLazyModuleGetter(this, "RecentlyClosedTabsAndWindowsMenuUtils",
"resource:///modules/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm"); "resource:///modules/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
"resource:///modules/Pocket.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ShortcutUtils", XPCOMUtils.defineLazyModuleGetter(this, "ShortcutUtils",
"resource://gre/modules/ShortcutUtils.jsm"); "resource://gre/modules/ShortcutUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu", XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
"resource://gre/modules/CharsetMenu.jsm"); "resource://gre/modules/CharsetMenu.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm"); "resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SocialService",
"resource://gre/modules/SocialService.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SyncedTabs", XPCOMUtils.defineLazyModuleGetter(this, "SyncedTabs",
"resource://services-sync/SyncedTabs.jsm"); "resource://services-sync/SyncedTabs.jsm");
@ -1225,68 +1219,6 @@ if (Services.prefs.getBoolPref("privacy.panicButton.enabled")) {
}); });
} }
if (Services.prefs.getBoolPref("browser.pocket.enabled")) {
let isEnabledForLocale = true;
if (Services.prefs.getBoolPref("browser.pocket.useLocaleList")) {
let chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry);
let browserLocale = chromeRegistry.getSelectedLocale("browser");
let enabledLocales = [];
try {
enabledLocales = Services.prefs.getCharPref("browser.pocket.enabledLocales").split(' ');
} catch (ex) {
Cu.reportError(ex);
}
isEnabledForLocale = enabledLocales.indexOf(browserLocale) != -1;
}
if (isEnabledForLocale) {
let pocketButton = {
id: "pocket-button",
defaultArea: CustomizableUI.AREA_NAVBAR,
introducedInVersion: "pref",
type: "view",
viewId: "PanelUI-pocketView",
// Use forwarding functions here to avoid loading Pocket.jsm on startup:
onViewShowing: function() {
return Pocket.onPanelViewShowing.apply(this, arguments);
},
onViewHiding: function() {
return Pocket.onPanelViewHiding.apply(this, arguments);
},
// If the user has the "classic" Pocket add-on installed, use that instead
// and destroy the widget.
conditionalDestroyPromise: new Promise(resolve => {
AddonManager.getAddonByID("isreaditlater@ideashower.com", addon => {
resolve(addon && addon.isActive);
});
}),
};
CustomizableWidgets.push(pocketButton);
CustomizableUI.addListener(pocketButton);
// Uninstall the Pocket social provider if it exists, but only if we haven't
// already uninstalled it in this manner. That way the user can reinstall
// it if they prefer it without its being uninstalled every time they start
// the browser.
let origin = "https://getpocket.com";
SocialService.getProvider(origin, provider => {
if (provider) {
let pref = "social.backup.getpocket-com";
if (!Services.prefs.prefHasUserValue(pref)) {
let str = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
str.data = JSON.stringify(provider.manifest);
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
SocialService.uninstallProvider(origin, () => {});
}
}
});
}
}
#ifdef E10S_TESTING_ONLY #ifdef E10S_TESTING_ONLY
var e10sDisabled = false; var e10sDisabled = false;
#ifdef XP_MACOSX #ifdef XP_MACOSX

View File

@ -191,10 +191,6 @@
observes="bookmarkThisPageBroadcaster" observes="bookmarkThisPageBroadcaster"
command="Browser:AddBookmarkAs" command="Browser:AddBookmarkAs"
onclick="PanelUI.hide();"/> onclick="PanelUI.hide();"/>
<toolbarseparator id="panelMenu_pocketSeparator"/>
<toolbarbutton id="panelMenu_pocket" label="&pocketMenuitem.label;"
class="subviewbutton cui-withicon"
oncommand="openUILink(Pocket.listURL, event);"/>
<toolbarseparator/> <toolbarseparator/>
<toolbarbutton id="panelMenu_viewBookmarksSidebar" <toolbarbutton id="panelMenu_viewBookmarksSidebar"
label="&viewBookmarksSidebar2.label;" label="&viewBookmarksSidebar2.label;"
@ -310,12 +306,6 @@
</vbox> </vbox>
</panelview> </panelview>
<panelview id="PanelUI-pocketView" flex="1">
<vbox class="panel-subview-body">
</vbox>
</panelview>
</panelmultiview> </panelmultiview>
<!-- These menupopups are located here to prevent flickering, <!-- These menupopups are located here to prevent flickering,
see bug 492960 comment 20. --> see bug 492960 comment 20. -->

View File

@ -15,7 +15,6 @@ DIRS += [
'migration', 'migration',
'newtab', 'newtab',
'places', 'places',
'pocket',
'preferences', 'preferences',
'privatebrowsing', 'privatebrowsing',
'search', 'search',

View File

@ -1,48 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
browser.jar:
content/browser/pocket/main.js
content/browser/pocket/pktApi.js
content/browser/pocket/panels/saved.html (panels/saved.html)
content/browser/pocket/panels/signup.html (panels/signup.html)
content/browser/pocket/panels/css/normalize.css (panels/css/normalize.css)
content/browser/pocket/panels/css/firasans.css (panels/css/firasans.css)
content/browser/pocket/panels/css/saved.css (panels/css/saved.css)
content/browser/pocket/panels/css/signup.css (panels/css/signup.css)
content/browser/pocket/panels/fonts/FiraSans-Regular.woff (panels/fonts/FiraSans-Regular.woff)
content/browser/pocket/panels/img/pocketerror@1x.png (panels/img/pocketerror@1x.png)
content/browser/pocket/panels/img/pocketerror@2x.png (panels/img/pocketerror@2x.png)
content/browser/pocket/panels/img/pocketlogo@1x.png (panels/img/pocketlogo@1x.png)
content/browser/pocket/panels/img/pocketlogo@2x.png (panels/img/pocketlogo@2x.png)
content/browser/pocket/panels/img/pocketlogosolo@1x.png (panels/img/pocketlogosolo@1x.png)
content/browser/pocket/panels/img/pocketlogosolo@2x.png (panels/img/pocketlogosolo@2x.png)
content/browser/pocket/panels/img/pocketmenuitem16.png (panels/img/pocketmenuitem16.png)
content/browser/pocket/panels/img/pocketmenuitem16@2x.png (panels/img/pocketmenuitem16@2x.png)
content/browser/pocket/panels/img/pocketsignup_button@1x.png (panels/img/pocketsignup_button@1x.png)
content/browser/pocket/panels/img/pocketsignup_button@2x.png (panels/img/pocketsignup_button@2x.png)
content/browser/pocket/panels/img/pocketsignup_devices@1x.png (panels/img/pocketsignup_devices@1x.png)
content/browser/pocket/panels/img/pocketsignup_devices@2x.png (panels/img/pocketsignup_devices@2x.png)
content/browser/pocket/panels/img/pocketsignup_hero@1x.png (panels/img/pocketsignup_hero@1x.png)
content/browser/pocket/panels/img/pocketsignup_hero@2x.png (panels/img/pocketsignup_hero@2x.png)
content/browser/pocket/panels/img/signup_firefoxlogo@1x.png (panels/img/signup_firefoxlogo@1x.png)
content/browser/pocket/panels/img/signup_firefoxlogo@2x.png (panels/img/signup_firefoxlogo@2x.png)
content/browser/pocket/panels/img/signup_help@1x.png (panels/img/signup_help@1x.png)
content/browser/pocket/panels/img/signup_help@2x.png (panels/img/signup_help@2x.png)
content/browser/pocket/panels/img/tag_close@1x.png (panels/img/tag_close@1x.png)
content/browser/pocket/panels/img/tag_close@2x.png (panels/img/tag_close@2x.png)
content/browser/pocket/panels/img/tag_closeactive@1x.png (panels/img/tag_closeactive@1x.png)
content/browser/pocket/panels/img/tag_closeactive@2x.png (panels/img/tag_closeactive@2x.png)
content/browser/pocket/panels/js/messages.js (panels/js/messages.js)
content/browser/pocket/panels/js/saved.js (panels/js/saved.js)
content/browser/pocket/panels/js/signup.js (panels/js/signup.js)
content/browser/pocket/panels/js/tmpl.js (panels/js/tmpl.js)
content/browser/pocket/panels/js/vendor/jquery-2.1.1.min.js (panels/js/vendor/jquery-2.1.1.min.js)
content/browser/pocket/panels/js/vendor/handlebars.runtime.js (panels/js/vendor/handlebars.runtime.js)
content/browser/pocket/panels/js/vendor/jquery.tokeninput.min.js (panels/js/vendor/jquery.tokeninput.min.js)
content/browser/pocket/panels/tmpl/saved_premiumextras.handlebars (panels/tmpl/saved_premiumextras.handlebars)
content/browser/pocket/panels/tmpl/saved_premiumshell.handlebars (panels/tmpl/saved_premiumshell.handlebars)
content/browser/pocket/panels/tmpl/saved_shell.handlebars (panels/tmpl/saved_shell.handlebars)
content/browser/pocket/panels/tmpl/signup_shell.handlebars (panels/tmpl/signup_shell.handlebars)
content/browser/pocket/panels/tmpl/signupstoryboard_shell.handlebars (panels/tmpl/signupstoryboard_shell.handlebars)

View File

@ -9,25 +9,7 @@ var gContentWindow;
var hasWebIDE = Services.prefs.getBoolPref("devtools.webide.widget.enabled"); var hasWebIDE = Services.prefs.getBoolPref("devtools.webide.widget.enabled");
var hasPocket = false; var hasPocket = Services.prefs.getBoolPref("extensions.pocket.enabled");
if (Services.prefs.getBoolPref("browser.pocket.enabled")) {
let isEnabledForLocale = true;
if (Services.prefs.getBoolPref("browser.pocket.useLocaleList")) {
let chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIXULChromeRegistry);
let browserLocale = chromeRegistry.getSelectedLocale("browser");
let enabledLocales = [];
try {
enabledLocales = Services.prefs.getCharPref("browser.pocket.enabledLocales").split(' ');
} catch (ex) {
Cu.reportError(ex);
}
isEnabledForLocale = enabledLocales.indexOf(browserLocale) != -1;
}
if (isEnabledForLocale) {
hasPocket = true;
}
}
function test() { function test() {
requestLongerTimeout(2); requestLongerTimeout(2);

View File

@ -62,7 +62,7 @@ function checkPanelIsHidden(aPanel) {
is(button.hasAttribute("open"), false, "Pocket button should know that the panel is closed"); is(button.hasAttribute("open"), false, "Pocket button should know that the panel is closed");
} }
if (Services.prefs.getBoolPref("browser.pocket.enabled")) { if (Services.prefs.getBoolPref("extensions.pocket.enabled")) {
let placement = CustomizableUI.getPlacementOfWidget("pocket-button"); let placement = CustomizableUI.getPlacementOfWidget("pocket-button");
// Add the button to the nav-bar by default. // Add the button to the nav-bar by default.

View File

@ -7,5 +7,6 @@
DIRS += [ DIRS += [
'loop', 'loop',
'pdfjs', 'pdfjs',
'pocket',
'shumway', 'shumway',
] ]

502
browser/extensions/pocket/bootstrap.js vendored Normal file
View File

@ -0,0 +1,502 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const {classes: Cc, interfaces: Ci, utils: Cu, manager: Cm} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://services-common/utils.js");
Cu.import("resource://gre/modules/Preferences.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
"resource:///modules/RecentWindow.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
"resource:///modules/CustomizableUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SocialService",
"resource://gre/modules/SocialService.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode",
"resource://gre/modules/ReaderMode.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Pocket",
"chrome://pocket/content/Pocket.jsm");
XPCOMUtils.defineLazyGetter(this, "gPocketBundle", function() {
return Services.strings.createBundle("chrome://pocket/locale/pocket.properties");
});
const PREF_BRANCH = "extensions.pocket.";
const PREFS = {
enabled: true, // bug 1229937, figure out ui tour support
api: "api.getpocket.com",
site: "getpocket.com",
oAuthConsumerKey: "40249-e88c401e1b1f2242d9e441c4"
};
function setDefaultPrefs() {
let branch = Services.prefs.getDefaultBranch(PREF_BRANCH);
for (let [key, val] in Iterator(PREFS)) {
switch (typeof val) {
case "boolean":
branch.setBoolPref(key, val);
break;
case "number":
branch.setIntPref(key, val);
break;
case "string":
branch.setCharPref(key, val);
break;
}
}
}
function* allBrowserWindows() {
var winEnum = Services.wm.getEnumerator("navigator:browser");
while (winEnum.hasMoreElements()) {
let win = winEnum.getNext();
// skip closed windows
if (win.closed)
continue;
yield win;
}
}
function createElementWithAttrs(document, type, attrs) {
let element = document.createElement(type);
Object.keys(attrs).forEach(function (attr) {
element.setAttribute(attr, attrs[attr]);
})
return element;
}
function CreatePocketWidget(reason) {
let id = "pocket-button"
let widget = CustomizableUI.getWidget(id);
// The widget is only null if we've created then destroyed the widget.
// Once we've actually called createWidget the provider will be set to
// PROVIDER_API.
if (widget && widget.provider == CustomizableUI.PROVIDER_API)
return;
// if upgrading from builtin version and the button was placed in ui,
// seenWidget will not be null
let seenWidget = CustomizableUI.getPlacementOfWidget("pocket-button", false, true);
let pocketButton = {
id: "pocket-button",
defaultArea: CustomizableUI.AREA_NAVBAR,
introducedInVersion: "pref",
type: "view",
viewId: "PanelUI-pocketView",
label: gPocketBundle.GetStringFromName("pocket-button.label"),
tooltiptext: gPocketBundle.GetStringFromName("pocket-button.tooltiptext"),
// Use forwarding functions here to avoid loading Pocket.jsm on startup:
onViewShowing: function() {
return Pocket.onPanelViewShowing.apply(this, arguments);
},
onViewHiding: function() {
return Pocket.onPanelViewHiding.apply(this, arguments);
},
onBeforeCreated: function(doc) {
// Bug 1223127,CUI should make this easier to do.
if (doc.getElementById("PanelUI-pocketView"))
return;
let view = doc.createElement("panelview");
view.id = "PanelUI-pocketView";
let panel = doc.createElement("vbox");
panel.setAttribute("class", "panel-subview-body");
view.appendChild(panel);
doc.getElementById("PanelUI-multiView").appendChild(view);
}
};
CustomizableUI.createWidget(pocketButton);
CustomizableUI.addListener(pocketButton);
// placed is null if location is palette
let placed = CustomizableUI.getPlacementOfWidget("pocket-button");
// a first time install will always have placed the button somewhere, and will
// not have a placement prior to creating the widget. Thus, !seenWidget &&
// placed.
if (reason == ADDON_ENABLE && !seenWidget && placed) {
// initially place the button after the bookmarks button if it is in the UI
let widgets = CustomizableUI.getWidgetIdsInArea(CustomizableUI.AREA_NAVBAR);
let bmbtn = widgets.indexOf("bookmarks-menu-button");
if (bmbtn > -1) {
CustomizableUI.moveWidgetWithinArea("pocket-button", bmbtn + 1);
}
}
// Uninstall the Pocket social provider if it exists, but only if we haven't
// already uninstalled it in this manner. That way the user can reinstall
// it if they prefer it without its being uninstalled every time they start
// the browser.
let origin = "https://getpocket.com";
SocialService.getProvider(origin, provider => {
if (provider) {
let pref = "social.backup.getpocket-com";
if (!Services.prefs.prefHasUserValue(pref)) {
let str = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
str.data = JSON.stringify(provider.manifest);
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
SocialService.uninstallProvider(origin, () => {});
}
}
});
};
// PocketContextMenu
// When the context menu is opened check if we need to build and enable pocket UI.
var PocketContextMenu = {
init: function() {
Services.obs.addObserver(this, "on-build-contextmenu", false);
},
shutdown: function() {
Services.obs.removeObserver(this, "on-build-contextmenu");
// loop through windows and remove context menus
// iterate through all windows and add pocket to them
for (let win of allBrowserWindows()) {
let document = win.document;
for (let id in ["context-pocket", "context-savelinktopocket"]) {
let element = document.getElementById(id);
if (element)
element.remove();
}
}
},
observe: function(aSubject, aTopic, aData) {
let subject = aSubject.wrappedJSObject;;
let document = subject.menu.ownerDocument;
let window = document.defaultView;
let pocketEnabled = CustomizableUI.getPlacementOfWidget("pocket-button");
let showSaveCurrentPageToPocket = !(subject.onTextInput || subject.onLink ||
subject.isContentSelected || subject.onImage ||
subject.onCanvas || subject.onVideo || subject.onAudio);
let targetUrl = subject.onLink ? subject.linkUrl : subject.pageUrl;
let targetURI = Services.io.newURI(targetUrl, null, null);
let canPocket = pocketEnabled && (targetURI.schemeIs("http") || targetURI.schemeIs("https") ||
(targetURI.schemeIs("about") && ReaderMode.getOriginalUrl(targetUrl)));
let showSaveLinkToPocket = canPocket && !showSaveCurrentPageToPocket && subject.onLink;
// create menu entries if necessary
let menu = document.getElementById("context-pocket");
if (!menu) {
menu = createElementWithAttrs(document, "menuitem", {
"id": "context-pocket",
"label": gPocketBundle.GetStringFromName("saveToPocketCmd.label"),
"accesskey": gPocketBundle.GetStringFromName("saveToPocketCmd.accesskey"),
"oncommand": "Pocket.savePage(gContextMenu.browser, gContextMenu.browser.currentURI.spec, gContextMenu.browser.contentTitle);"
});
let sibling = document.getElementById("context-savepage");
if (sibling.nextSibling) {
sibling.parentNode.insertBefore(menu, sibling.nextSibling);
} else {
sibling.parentNode.appendChild(menu);
}
}
menu.hidden = !(canPocket && showSaveCurrentPageToPocket);
menu = document.getElementById("context-savelinktopocket");
if (!menu) {
menu = createElementWithAttrs(document, "menuitem", {
"id": "context-savelinktopocket",
"label": gPocketBundle.GetStringFromName("saveLinkToPocketCmd.label"),
"accesskey": gPocketBundle.GetStringFromName("saveLinkToPocketCmd.accesskey"),
"oncommand": "Pocket.savePage(gContextMenu.browser, gContextMenu.linkURL);"
});
sibling = document.getElementById("context-savelink");
if (sibling.nextSibling) {
sibling.parentNode.insertBefore(menu, sibling.nextSibling);
} else {
sibling.parentNode.appendChild(menu);
}
}
menu.hidden = !showSaveLinkToPocket;
}
}
// PocketReader
// Listen for reader mode setup and add our button to the reader toolbar
var PocketReader = {
startup: function() {
let mm = Services.mm;
mm.addMessageListener("Reader:OnSetup", this);
mm.addMessageListener("Reader:Clicked-pocket-button", this);
mm.broadcastAsyncMessage("Reader:AddButton",
{ id: "pocket-button",
title: gPocketBundle.GetStringFromName("pocket-button.tooltiptext"),
image: "chrome://pocket/content/panels/img/pocket.svg#pocket-mark" });
},
shutdown: function() {
let mm = Services.mm;
mm.removeMessageListener("Reader:OnSetup", this);
mm.removeMessageListener("Reader:Clicked-pocket-button", this);
mm.broadcastAsyncMessage("Reader:RemoveButton", { id: "pocket-button" });
},
receiveMessage: function(message) {
switch (message.name) {
case "Reader:OnSetup": {
// tell the reader about our button. A chrome url here doesn't work, but
// we can use the resoure url.
message.target.messageManager.
sendAsyncMessage("Reader:AddButton", { id: "pocket-button",
title: gPocketBundle.GetStringFromName("pocket-button.tooltiptext"),
image: "chrome://pocket/content/panels/img/pocket.svg#pocket-mark"});
break;
}
case "Reader:Clicked-pocket-button": {
let doc = message.target.ownerDocument;
let pocketWidget = doc.getElementById("pocket-button");
let placement = CustomizableUI.getPlacementOfWidget("pocket-button");
if (placement) {
if (placement.area == CustomizableUI.AREA_PANEL) {
doc.defaultView.PanelUI.show().then(function() {
// The DOM node might not exist yet if the panel wasn't opened before.
pocketWidget = doc.getElementById("pocket-button");
pocketWidget.doCommand();
});
} else {
pocketWidget.doCommand();
}
}
break;
}
}
}
}
function pktUIGetter(prop, window) {
return {
get: function() {
// delete any getters for properties loaded from main.js so we only load main.js once
delete window.pktUI;
delete window.pktUIMessaging;
Services.scriptloader.loadSubScript("chrome://pocket/content/main.js", window);
return window[prop];
},
configurable: true,
enumerable: true
};
}
var PocketOverlay = {
startup: function(reason) {
this.registerStylesheet();
CreatePocketWidget(reason);
Services.obs.addObserver(this,
"browser-delayed-startup-finished",
false);
CustomizableUI.addListener(this);
PocketContextMenu.init();
PocketReader.startup();
if (reason == ADDON_ENABLE) {
for (let win of allBrowserWindows()) {
this.setWindowScripts(win);
this.updateWindow(win);
}
}
},
shutdown: function(reason) {
CustomizableUI.removeListener(this);
for (let window of allBrowserWindows()) {
for (let id of ["panelMenu_pocket", "menu_pocket", "BMB_pocket",
"panelMenu_pocketSeparator", "menu_pocketSeparator",
"BMB_pocketSeparator"]) {
let element = window.document.getElementById(id);
if (element)
element.remove();
}
// remove script getters/objects
delete window.Pocket;
delete window.pktUI;
delete window.pktUIMessaging;
}
CustomizableUI.destroyWidget("pocket-button");
PocketContextMenu.shutdown();
PocketReader.shutdown();
this.unregisterStylesheet();
},
observe: function(aSubject, aTopic, aData) {
// new browser window, initialize the "overlay"
let window = aSubject;
this.setWindowScripts(window);
this.updateWindow(window);
},
setWindowScripts: function(window) {
XPCOMUtils.defineLazyModuleGetter(window, "Pocket",
"chrome://pocket/content/Pocket.jsm");
// Can't use XPCOMUtils for these because the scripts try to define the variables
// on window, and so the defineProperty inside defineLazyGetter fails.
Object.defineProperty(window, "pktUI", pktUIGetter("pktUI", window));
Object.defineProperty(window, "pktUIMessaging", pktUIGetter("pktUIMessaging", window));
},
// called for each window as it is opened
updateWindow: function(window) {
// insert our three menu items
let document = window.document;
// add to bookmarksMenu
let sib = document.getElementById("menu_bookmarkThisPage");
if (sib && !document.getElementById("menu_pocket")) {
let menu = createElementWithAttrs(document, "menuitem", {
"id": "menu_pocket",
"label": gPocketBundle.GetStringFromName("pocketMenuitem.label"),
"class": "menuitem-iconic", // OSX only
"oncommand": "openUILink(Pocket.listURL, event);"
});
let sep = createElementWithAttrs(document, "menuseparator", {
"id": "menu_pocketSeparator"
});
sib.parentNode.insertBefore(menu, sib);
sib.parentNode.insertBefore(sep, sib);
}
// add to bookmarks-menu-button
sib = document.getElementById("BMB_subscribeToPageMenuitem");
if (sib && !document.getElementById("BMB_pocket")) {
let menu = createElementWithAttrs(document, "menuitem", {
"id": "BMB_pocket",
"label": gPocketBundle.GetStringFromName("pocketMenuitem.label"),
"class": "menuitem-iconic bookmark-item subviewbutton",
"oncommand": "openUILink(Pocket.listURL, event);"
});
let sep = createElementWithAttrs(document, "menuseparator", {
"id": "BMB_pocketSeparator"
});
sib.parentNode.insertBefore(menu, sib);
sib.parentNode.insertBefore(sep, sib);
}
// add to PanelUI-bookmarks
sib = document.getElementById("panelMenuBookmarkThisPage");
if (sib && !document.getElementById("panelMenu_pocket")) {
let menu = createElementWithAttrs(document, "toolbarbutton", {
"id": "panelMenu_pocket",
"label": gPocketBundle.GetStringFromName("pocketMenuitem.label"),
"class": "subviewbutton cui-withicon",
"oncommand": "openUILink(Pocket.listURL, event);"
});
let sep = createElementWithAttrs(document, "toolbarseparator", {
"id": "panelMenu_pocketSeparator"
});
// nextSibling is no-id toolbarseparator
// insert separator first then button
sib = sib.nextSibling;
sib.parentNode.insertBefore(sep, sib);
sib.parentNode.insertBefore(menu, sib);
}
this.updatePocketItemVisibility(document);
},
onWidgetAdded: function(aWidgetId, aArea, aPosition) {
for (let win of allBrowserWindows()) {
this.updatePocketItemVisibility(win.document);
}
},
onWidgetRemoved: function(aWidgetId, aArea, aPosition) {
for (let win of allBrowserWindows()) {
this.updatePocketItemVisibility(win.document);
}
},
onWidgetReset: function(aNode, aContainer) {
// CUI was reset and doesn't respect default area for API widgets, place our
// widget back to the default area
// initially place the button after the bookmarks button if it is in the UI
let widgets = CustomizableUI.getWidgetIdsInArea(CustomizableUI.AREA_NAVBAR);
let bmbtn = widgets.indexOf("bookmarks-menu-button");
if (bmbtn > -1) {
CustomizableUI.addWidgetToArea("pocket-button", CustomizableUI.AREA_NAVBAR, bmbtn + 1);
} else {
CustomizableUI.addWidgetToArea("pocket-button", CustomizableUI.AREA_NAVBAR);
}
},
updatePocketItemVisibility: function(doc) {
let hidden = !CustomizableUI.getPlacementOfWidget("pocket-button");
for (let prefix of ["panelMenu_", "menu_", "BMB_"]) {
let element = doc.getElementById(prefix + "pocket");
if (element) {
element.hidden = hidden;
doc.getElementById(prefix + "pocketSeparator").hidden = hidden;
}
}
// enable or disable reader button
if (hidden) {
PocketReader.shutdown();
} else {
PocketReader.startup();
}
},
registerStylesheet: function() {
let styleSheetService= Components.classes["@mozilla.org/content/style-sheet-service;1"]
.getService(Components.interfaces.nsIStyleSheetService);
let styleSheetURI = Services.io.newURI("chrome://pocket/skin/pocket.css", null, null);
styleSheetService.loadAndRegisterSheet(styleSheetURI, styleSheetService.AUTHOR_SHEET);
styleSheetURI = Services.io.newURI("chrome://pocket-shared/skin/pocket.css", null, null);
styleSheetService.loadAndRegisterSheet(styleSheetURI, styleSheetService.AUTHOR_SHEET);
},
unregisterStylesheet: function() {
let styleSheetService = Components.classes["@mozilla.org/content/style-sheet-service;1"]
.getService(Components.interfaces.nsIStyleSheetService);
let styleSheetURI = Services.io.newURI("chrome://pocket/skin/pocket.css", null, null);
if (styleSheetService.sheetRegistered(styleSheetURI, styleSheetService.AUTHOR_SHEET)) {
styleSheetService.unregisterSheet(styleSheetURI, styleSheetService.AUTHOR_SHEET);
}
styleSheetURI = Services.io.newURI("chrome://pocket-shared/skin/pocket.css", null, null);
if (styleSheetService.sheetRegistered(styleSheetURI, styleSheetService.AUTHOR_SHEET)) {
styleSheetService.unregisterSheet(styleSheetURI, styleSheetService.AUTHOR_SHEET);
}
}
}
// use enabled pref as a way for tests (e.g. test_contextmenu.html) to disable
// the addon when running.
function prefObserver(aSubject, aTopic, aData) {
let enabled = Services.prefs.getBoolPref("extensions.pocket.enabled");
if (enabled)
PocketOverlay.startup(ADDON_ENABLE);
else
PocketOverlay.shutdown(ADDON_DISABLE);
}
function startup(data, reason) {
AddonManager.getAddonByID("isreaditlater@ideashower.com", addon => {
if (addon && addon.isActive)
return;
setDefaultPrefs();
// migrate enabled pref
if (Services.prefs.prefHasUserValue("browser.pocket.enabled")) {
Services.prefs.setBoolPref("extensions.pocket.enabled", Services.prefs.getBoolPref("browser.pocket.enabled"));
Services.prefs.clearUserPref("browser.pocket.enabled");
}
// watch pref change and enable/disable if necessary
Services.prefs.addObserver("extensions.pocket.enabled", prefObserver, false);
if (Services.prefs.prefHasUserValue("extensions.pocket.enabled") &&
!Services.prefs.getBoolPref("extensions.pocket.enabled"))
return;
PocketOverlay.startup(reason);
});
}
function shutdown(data, reason) {
// For speed sake, we should only do a shutdown if we're being disabled.
// On an app shutdown, just let it fade away...
if (reason == ADDON_DISABLE) {
Services.prefs.removeObserver("extensions.pocket.enabled", prefObserver);
PocketOverlay.shutdown(reason);
}
}
function install() {
}
function uninstall() {
}

View File

@ -16,7 +16,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode",
"resource://gre/modules/ReaderMode.jsm"); "resource://gre/modules/ReaderMode.jsm");
var Pocket = { var Pocket = {
get site() { return Services.prefs.getCharPref("browser.pocket.site"); }, get site() { return Services.prefs.getCharPref("extensions.pocket.site"); },
get listURL() { return "https://" + Pocket.site + "/?src=ff_ext"; }, get listURL() { return "https://" + Pocket.site + "/?src=ff_ext"; },
/** /**
@ -37,7 +37,7 @@ var Pocket = {
if (urlToSave) { if (urlToSave) {
window.pktUI.tryToSaveUrl(urlToSave, titleToSave); window.pktUI.tryToSaveUrl(urlToSave, titleToSave);
} else { } else {
window.pktUI.pocketButtonOnCommand(); window.pktUI.tryToSaveCurrentPage();
} }
if (iframe.contentDocument && if (iframe.contentDocument &&

View File

@ -15,10 +15,10 @@
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -46,6 +46,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm"); "resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode", XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode",
"resource://gre/modules/ReaderMode.jsm"); "resource://gre/modules/ReaderMode.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "pktApi",
"chrome://pocket/content/pktApi.jsm");
var pktUI = (function() { var pktUI = (function() {
@ -61,125 +63,31 @@ var pktUI = (function() {
// wrong // wrong
var _panelId = 0; var _panelId = 0;
var prefBranch = Services.prefs.getBranch("browser.pocket.settings."); var prefBranch = Services.prefs.getBranch("extensions.pocket.settings.");
var overflowMenuWidth = 230; var overflowMenuWidth = 230;
var overflowMenuHeight = 475; var overflowMenuHeight = 475;
var savePanelWidth = 350; var savePanelWidth = 350;
var savePanelHeights = {collapsed: 153, expanded: 272}; var savePanelHeights = {collapsed: 153, expanded: 272};
/**
* Initalizes Pocket UI and panels
*/
function onLoad() {
if (inited)
return;
// Install the button (Only on first run, if a user removes the button, you do not want to restore it)
// TODO, only do this if in a certain language
// TODO - Ask Mozilla what the best way is to have this update when a user restores browser defaults
// TODO - this needs to run only on a main window - if the first run happens on a window without the toolbar, then it will never try to run it again
if (!prefBranch.prefHasUserValue('installed')) {
// If user has social add-on installed, uninstall it
if (Social.getManifestByOrigin("https://getpocket.com")) {
Social.uninstallProvider("https://getpocket.com", function(){ /* callback */ });
}
// if user has legacy pkt add-on installed, flag it so we can handle it correctly
prefBranch.setBoolPref('hasLegacyExtension', hasLegacyExtension());
var id = "pocket-menu-button";
var toolbar = document.getElementById("nav-bar");
var before = null;
// Is the bookmarks button in the toolbar?
if (toolbar.currentSet.match("bookmarks-menu-button")) {
var elem = document.getElementById("bookmarks-menu-button");
if (elem)
before = elem.nextElementSibling;
}
// Otherwise, just add it to the end of the toolbar (because before is null)
toolbar.insertItem(id, before);
toolbar.setAttribute("currentset", toolbar.currentSet);
document.persist(toolbar.id, "currentset");
prefBranch.setBoolPref('installed', true);
}
// Context Menu Event
document.getElementById('contentAreaContextMenu').addEventListener("popupshowing", contextOnPopupShowing, false);
// Hide the extension based on certain criteria
hideIntegrationIfNeeded();
inited = true;
}
/**
* Mark all Pocket integration chrome elements as hidden if certain criteria apply (ex: legacy Pocket extension users or unsupported languages)
*/
function hideIntegrationIfNeeded() {
var hideIntegration = false;
// Check if the user had the legacy extension the last time we looked
if (prefBranch.getBoolPref('hasLegacyExtension')) {
if (hasLegacyExtension()) {
hideIntegration = true; // they still have it, hide new native integration
}
else {
// if they originally had it, but no longer do, then we should remove the pref so we no longer have to check
prefBranch.setBoolPref('hasLegacyExtension', false);
}
}
// TODO
// If language other than launch languages (en-US currently) {
// hideIntegration = true;
//}
// Hide the integration if needed
if (hideIntegration) {
// Note, we don't hide the context menus here, that's handled in contextOnPopupShowing
var elements = ['pocket-menu-button', 'BMB_openPocketWebapp'];
for(var i=0; i<elements.length; i++) {
document.getElementById(elements[i]).setAttribute('hidden', true);
}
_isHidden = true;
}
else
_isHidden = false
}
// -- Event Handling -- // // -- Event Handling -- //
/** /**
* Event handler when Pocket toolbar button is pressed * Event handler when Pocket toolbar button is pressed
*/ */
function pocketButtonOnCommand(event) {
tryToSaveCurrentPage();
}
function pocketPanelDidShow(event) { function pocketPanelDidShow(event) {
if (_currentPanelDidShow) { if (_currentPanelDidShow) {
_currentPanelDidShow(event); _currentPanelDidShow(event);
} }
} }
function pocketPanelDidHide(event) { function pocketPanelDidHide(event) {
if (_currentPanelDidHide) { if (_currentPanelDidHide) {
_currentPanelDidHide(event); _currentPanelDidHide(event);
} }
// clear the panel // clear the panel
getPanelFrame().setAttribute('src', 'about:blank'); getPanelFrame().setAttribute('src', 'about:blank');
} }
@ -192,73 +100,6 @@ var pktUI = (function() {
openTabWithUrl('https://getpocket.com/a/', true); openTabWithUrl('https://getpocket.com/a/', true);
} }
/**
* Event handler when Pocket context menu button is presed
*/
// Determine which context menus to show before it's shown
function contextOnPopupShowing() {
var saveLinkId = "PKT_context_saveLink";
var savePageId = "PKT_context_savePage";
if (isHidden()) {
gContextMenu.showItem(saveLinkId, false);
gContextMenu.showItem(savePageId, false);
} else if ( (gContextMenu.onSaveableLink || ( gContextMenu.inDirList && gContextMenu.onLink )) ) {
gContextMenu.showItem(saveLinkId, true);
gContextMenu.showItem(savePageId, false);
} else if (gContextMenu.isTextSelected) {
gContextMenu.showItem(saveLinkId, false);
gContextMenu.showItem(savePageId, false);
} else if (!gContextMenu.onTextInput) {
gContextMenu.showItem(saveLinkId, false);
gContextMenu.showItem(savePageId, true);
} else {
gContextMenu.showItem(saveLinkId, false);
gContextMenu.showItem(savePageId, false);
}
}
function pocketContextSaveLinkOnCommand(event) {
// TODO : Unsafe CPOW Usage when saving with Page context menu (Ask Mozilla for help with this one)
var linkNode = gContextMenu.target || document.popupNode;
// Get parent node in case of text nodes (old safari versions)
if (linkNode.nodeType == Node.TEXT_NODE) {
linkNode = linkNode.parentNode;
}
// If for some reason, it's not an element node, abort
if (linkNode.nodeType != Node.ELEMENT_NODE) {
return;
}
// Try to get a link element in the parent chain as we can be in the
// last child element
var currentElement = linkNode;
while (currentElement !== null) {
if (currentElement.nodeType == Node.ELEMENT_NODE &&
currentElement.nodeName.toLowerCase() == 'a')
{
// We have a link element try to save it
linkNode = currentElement;
break;
}
currentElement = currentElement.parentNode;
}
var link = linkNode.href;
tryToSaveUrl(link);
event.stopPropagation();
}
function pocketContextSavePageOnCommand(event) {
tryToSaveCurrentPage();
}
// -- Communication to API -- // // -- Communication to API -- //
/** /**
@ -267,7 +108,7 @@ var pktUI = (function() {
function tryToSaveCurrentPage() { function tryToSaveCurrentPage() {
tryToSaveUrl(getCurrentUrl(), getCurrentTitle()); tryToSaveUrl(getCurrentUrl(), getCurrentTitle());
} }
function tryToSaveUrl(url, title) { function tryToSaveUrl(url, title) {
// If the user is logged in, go ahead and save the current page // If the user is logged in, go ahead and save the current page
@ -292,8 +133,8 @@ var pktUI = (function() {
var fxasignedin = (typeof userdata == 'object' && userdata !== null) ? '1' : '0'; var fxasignedin = (typeof userdata == 'object' && userdata !== null) ? '1' : '0';
var startheight = 490; var startheight = 490;
var inOverflowMenu = isInOverflowMenu(); var inOverflowMenu = isInOverflowMenu();
if (inOverflowMenu) if (inOverflowMenu)
{ {
startheight = overflowMenuHeight; startheight = overflowMenuHeight;
} }
@ -321,7 +162,7 @@ var pktUI = (function() {
{ {
variant = pktApi.getSignupAB(); variant = pktApi.getSignupAB();
} }
var panelId = showPanel("about:pocket-signup?pockethost=" + Services.prefs.getCharPref("browser.pocket.site") + "&fxasignedin=" + fxasignedin + "&variant=" + variant + '&inoverflowmenu=' + inOverflowMenu + "&locale=" + getUILocale(), { var panelId = showPanel("chrome://pocket/content/panels/signup.html?pockethost=" + Services.prefs.getCharPref("extensions.pocket.site") + "&fxasignedin=" + fxasignedin + "&variant=" + variant + '&inoverflowmenu=' + inOverflowMenu + "&locale=" + getUILocale(), {
onShow: function() { onShow: function() {
}, },
onHide: panelDidHide, onHide: panelDidHide,
@ -349,7 +190,7 @@ var pktUI = (function() {
startheight = overflowMenuHeight; startheight = overflowMenuHeight;
} }
var panelId = showPanel("about:pocket-saved?pockethost=" + Services.prefs.getCharPref("browser.pocket.site") + "&premiumStatus=" + (pktApi.isPremiumUser() ? '1' : '0') + '&inoverflowmenu='+inOverflowMenu + "&locale=" + getUILocale(), { var panelId = showPanel("chrome://pocket/content/panels/saved.html?pockethost=" + Services.prefs.getCharPref("extensions.pocket.site") + "&premiumStatus=" + (pktApi.isPremiumUser() ? '1' : '0') + '&inoverflowmenu='+inOverflowMenu + "&locale=" + getUILocale(), {
onShow: function() { onShow: function() {
var saveLinkMessageId = 'saveLink'; var saveLinkMessageId = 'saveLink';
@ -479,7 +320,7 @@ var pktUI = (function() {
* Called when the signup and saved panel was hidden * Called when the signup and saved panel was hidden
*/ */
function panelDidHide() { function panelDidHide() {
} }
/** /**
@ -615,7 +456,7 @@ var pktUI = (function() {
var _initL10NMessageId = "initL10N"; var _initL10NMessageId = "initL10N";
pktUIMessaging.addMessageListener(_initL10NMessageId, function(panelId, data) { pktUIMessaging.addMessageListener(_initL10NMessageId, function(panelId, data) {
var strings = {}; var strings = {};
var bundle = Services.strings.createBundle("chrome://browser/locale/browser-pocket.properties"); var bundle = Services.strings.createBundle("chrome://pocket/locale/pocket.properties");
var e = bundle.getSimpleEnumeration(); var e = bundle.getSimpleEnumeration();
while(e.hasMoreElements()) { while(e.hasMoreElements()) {
var str = e.getNext().QueryInterface(Components.interfaces.nsIPropertyElement); var str = e.getNext().QueryInterface(Components.interfaces.nsIPropertyElement);
@ -725,7 +566,7 @@ var pktUI = (function() {
callback(); callback();
}); });
} }
function getUILocale() { function getUILocale() {
var locale = Cc["@mozilla.org/chrome/chrome-registry;1"]. var locale = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry). getService(Ci.nsIXULChromeRegistry).
@ -733,112 +574,19 @@ var pktUI = (function() {
return locale; return locale;
} }
/**
* Toolbar animations
*/
function showPocketAnimation() {
// Borrowed from bookmark star animation:
// https://dxr.mozilla.org/mozilla-central/source/browser/base/content/browser-places.js#1568
// TODO : Clean-up : Probably don't need all of this since the css animation does most of the heavy lifting
// TODO : Do not show when saving from context menu -- or get really fancy and launch the icon from the link that was saved into the bookmark menu
function getCenteringTransformForRects(rectToPosition, referenceRect) {
let topDiff = referenceRect.top - rectToPosition.top;
let leftDiff = referenceRect.left - rectToPosition.left;
let heightDiff = referenceRect.height - rectToPosition.height;
let widthDiff = referenceRect.width - rectToPosition.width;
return [(leftDiff + .5 * widthDiff) + "px", (topDiff + .5 * heightDiff) + "px"];
}
if (_notificationTimeout) {
clearTimeout(this._notificationTimeout);
}
var button = document.getElementById('pocket-menu-button');
var bookmarksButton = document.getElementById('bookmarks-menu-button');
var notifier = document.getElementById("pocketed-notification-anchor");
var dropmarkerNotifier = document.getElementById("bookmarked-notification-dropmarker-anchor");
// If the Pocket button is not immediately after the bookmark button, then do not do the animation
// (because it's hard-coded for the positions right now)
// TODO - double check this in small and large toolbar button sizes
if (bookmarksButton.nextElementSibling != button)
return;
if (notifier.style.transform == '') {
// Get all the relevant nodes and computed style objects
let dropmarker = document.getAnonymousElementByAttribute(bookmarksButton, "anonid", "dropmarker");
let dropmarkerIcon = document.getAnonymousElementByAttribute(dropmarker, "class", "dropmarker-icon");
let dropmarkerStyle = getComputedStyle(dropmarkerIcon);
// Check for RTL and get bounds
let isRTL = getComputedStyle(button).direction == "rtl"; // need this?
let buttonRect = button.getBoundingClientRect();
let notifierRect = notifier.getBoundingClientRect();
let dropmarkerRect = dropmarkerIcon.getBoundingClientRect();
let dropmarkerNotifierRect = dropmarkerNotifier.getBoundingClientRect();
// Compute, but do not set, transform for pocket icon
let [translateX, translateY] = getCenteringTransformForRects(notifierRect, buttonRect);
let starIconTransform = "translate(" + (translateX) + ", " + translateY + ")";
if (isRTL) {
starIconTransform += " scaleX(-1)";
}
// Compute, but do not set, transform for dropmarker
[translateX, translateY] = getCenteringTransformForRects(dropmarkerNotifierRect, dropmarkerRect);
let dropmarkerTransform = "translate(" + translateX + ", " + translateY + ")";
// Do all layout invalidation in one go:
notifier.style.transform = starIconTransform;
dropmarkerNotifier.style.transform = dropmarkerTransform;
let dropmarkerAnimationNode = dropmarkerNotifier.firstChild;
dropmarkerAnimationNode.style.MozImageRegion = dropmarkerStyle.MozImageRegion;
dropmarkerAnimationNode.style.listStyleImage = dropmarkerStyle.listStyleImage;
}
let isInOverflowMenu = button.getAttribute("overflowedItem") == "true";
if (!isInOverflowMenu) {
notifier.setAttribute("notification", "finish");
button.setAttribute("notification", "finish");
dropmarkerNotifier.setAttribute("notification", "finish");
}
_notificationTimeout = setTimeout( () => {
notifier.removeAttribute("notification");
dropmarkerNotifier.removeAttribute("notification");
button.removeAttribute("notification");
dropmarkerNotifier.style.transform = '';
notifier.style.transform = '';
}, 1000);
}
/** /**
* Public functions * Public functions
*/ */
return { return {
onLoad: onLoad,
getPanelFrame: getPanelFrame, getPanelFrame: getPanelFrame,
openTabWithUrl: openTabWithUrl, openTabWithUrl: openTabWithUrl,
pocketButtonOnCommand: pocketButtonOnCommand,
pocketPanelDidShow: pocketPanelDidShow, pocketPanelDidShow: pocketPanelDidShow,
pocketPanelDidHide: pocketPanelDidHide, pocketPanelDidHide: pocketPanelDidHide,
pocketContextSaveLinkOnCommand, tryToSaveUrl: tryToSaveUrl,
pocketContextSavePageOnCommand, tryToSaveCurrentPage: tryToSaveCurrentPage
pocketBookmarkBarOpenPocketCommand,
tryToSaveUrl: tryToSaveUrl
}; };
}()); }());
@ -857,7 +605,7 @@ var pktUIMessaging = (function() {
* Register a listener and callback for a specific messageId * Register a listener and callback for a specific messageId
*/ */
function addMessageListener(messageId, callback) { function addMessageListener(messageId, callback) {
document.addEventListener(prefixedMessageId(messageId), function(e) { document.addEventListener(prefixedMessageId(messageId), function(e) {
// ignore to ensure we do not pick up other events in the browser // ignore to ensure we do not pick up other events in the browser
if (e.target.tagName !== 'PKTMESSAGEFROMPANELELEMENT') { if (e.target.tagName !== 'PKTMESSAGEFROMPANELELEMENT') {
return; return;

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 264 B

After

Width:  |  Height:  |  Size: 264 B

View File

Before

Width:  |  Height:  |  Size: 641 B

After

Width:  |  Height:  |  Size: 641 B

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 145 KiB

View File

Before

Width:  |  Height:  |  Size: 635 B

After

Width:  |  Height:  |  Size: 635 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 659 B

After

Width:  |  Height:  |  Size: 659 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 287 B

After

Width:  |  Height:  |  Size: 287 B

View File

Before

Width:  |  Height:  |  Size: 508 B

After

Width:  |  Height:  |  Size: 508 B

View File

Before

Width:  |  Height:  |  Size: 208 B

After

Width:  |  Height:  |  Size: 208 B

View File

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 354 B

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<base href="chrome://browser/content/pocket/panels/"> <base href="chrome://pocket/content/panels/">
<title>Pocket: Page Saved</title> <title>Pocket: Page Saved</title>
<link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/firasans.css"> <link rel="stylesheet" href="css/firasans.css">

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<base href="chrome://browser/content/pocket/panels/"> <base href="chrome://pocket/content/panels/">
<title>Pocket: Sign Up</title> <title>Pocket: Sign Up</title>
<link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/firasans.css"> <link rel="stylesheet" href="css/firasans.css">

View File

@ -42,6 +42,13 @@
* usedTags: All used tags from within the extension sorted by recency * usedTags: All used tags from within the extension sorted by recency
*/ */
const {classes: Cc, interfaces: Ci, utils: Cu, manager: Cm} = Components;
this.EXPORTED_SYMBOLS = ["pktApi"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
var pktApi = (function() { var pktApi = (function() {
/** /**
@ -49,20 +56,20 @@ var pktApi = (function() {
*/ */
// Base url for all api calls // Base url for all api calls
var pocketAPIhost = Services.prefs.getCharPref("browser.pocket.api"); // api.getpocket.com var pocketAPIhost = Services.prefs.getCharPref("extensions.pocket.api"); // api.getpocket.com
var pocketSiteHost = Services.prefs.getCharPref("browser.pocket.site"); // getpocket.com var pocketSiteHost = Services.prefs.getCharPref("extensions.pocket.site"); // getpocket.com
var baseAPIUrl = "https://" + pocketAPIhost + "/v3"; var baseAPIUrl = "https://" + pocketAPIhost + "/v3";
/** /**
* Auth keys for the API requests * Auth keys for the API requests
*/ */
var oAuthConsumerKey = Services.prefs.getCharPref("browser.pocket.oAuthConsumerKey"); var oAuthConsumerKey = Services.prefs.getCharPref("extensions.pocket.oAuthConsumerKey");
/** /**
* *
*/ */
var prefBranch = Services.prefs.getBranch("browser.pocket.settings."); var prefBranch = Services.prefs.getBranch("extensions.pocket.settings.");
/** /**
* Helper * Helper

View File

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
#filter substitution
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>firefox@getpocket.com</em:id>
<em:version>@FIREFOX_VERSION@</em:version>
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>
<!-- Target Application this theme can install into,
with minimum and maximum supported versions. -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>@FIREFOX_VERSION@</em:minVersion>
<em:maxVersion>@FIREFOX_VERSION@</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Pocket</em:name>
<em:description>When you find something you want to view later, put it in Pocket.</em:description>
</Description>
</RDF>

View File

@ -0,0 +1,12 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
[features/firefox@getpocket.com] chrome.jar:
% content pocket %content/ contentaccessible=yes
% skin pocket classic/1.0 %skin/linux/ os=Linux
% skin pocket classic/1.0 %skin/osx/ os=Darwin
% skin pocket classic/1.0 %skin/windows/ os=WINNT
% skin pocket-shared classic/1.0 %skin/shared/
content/ (content/*)
skin/ (skin/*)

View File

@ -29,3 +29,13 @@ tagssaved = Tags Added
signinfirefox = Sign in with Firefox signinfirefox = Sign in with Firefox
signupfirefox = Sign up with Firefox signupfirefox = Sign up with Firefox
viewlist = View List viewlist = View List
# LOCALIZATION NOTE(pocket-button.label, pocket-button.tooltiptext, saveToPocketCmd.label, saveLinkToPocketCmd.label, pocketMenuitem.label):
# "Pocket" is a brand name.
pocket-button.label = Pocket
pocket-button.tooltiptext = Save to Pocket
saveToPocketCmd.label = Save Page to Pocket
saveToPocketCmd.accesskey = k
saveLinkToPocketCmd.label = Save Link to Pocket
saveLinkToPocketCmd.accesskey = o
pocketMenuitem.label = View Pocket List

View File

@ -0,0 +1,8 @@
#filter substitution
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
[features/firefox@getpocket.com] @AB_CD@.jar:
% locale pocket @AB_CD@ %locale/@AB_CD@/
locale/@AB_CD@/ (%*)

View File

@ -1,7 +1,7 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
JAR_MANIFESTS += ['jar.mn'] JAR_MANIFESTS += ['jar.mn']
EXTRA_JS_MODULES += ['Pocket.jsm']

View File

@ -0,0 +1,17 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ['locales']
FINAL_TARGET_FILES.features['firefox@getpocket.com'] += [
'bootstrap.js'
]
FINAL_TARGET_PP_FILES.features['firefox@getpocket.com'] += [
'install.rdf.in'
]
JAR_MANIFESTS += ['jar.mn']

View File

@ -0,0 +1,38 @@
#pocket-button[cui-areatype="toolbar"][open] {
-moz-image-region: rect(36px, 774px, 54px, 756px);
}
@media (min-resolution: 1.1dppx) {
#pocket-button[cui-areatype="toolbar"] {
-moz-image-region: rect(0, 1548px, 36px, 1512px);
}
#pocket-button[cui-areatype="toolbar"][open] {
-moz-image-region: rect(72px, 1548px, 108px, 1512px);
}
}
@media (min-resolution: 2dppx) {
#panelMenu_pocket,
#menu_pocket,
#BMB_pocket {
list-style-image: url("chrome://pocket/content/panels/img/pocketmenuitem16@2x.png");
}
#panelMenu_pocket > .toolbarbutton-icon {
width: 16px;
}
}
@media not all and (min-resolution: 1.1dppx) {
#pocket-button:hover:active:not([disabled="true"]):not([cui-areatype="menu-panel"]) {
-moz-image-region: rect(18px, 774px, 36px, 756px);
}
}
@media (min-resolution: 1.1dppx) {
#pocket-button:hover:active:not([disabled="true"]):not([cui-areatype="menu-panel"]) {
-moz-image-region: rect(36px, 1548px, 72px, 1512px);
}
}

View File

@ -0,0 +1,68 @@
/* Bug 1164419 - increase Pocket panel size to accomidate wider Russian text. */
panelmultiview[mainViewId=PanelUI-pocketView] > .panel-viewcontainer > .panel-viewstack > .panel-mainview:not([panelid="PanelUI-popup"]) {
max-width: 33em; /* standaloneSubviewWidth + 3 */
}
.cui-widget-panel[viewId="PanelUI-pocketView"] > .panel-arrowcontainer > .panel-arrowcontent {
padding-top: 0;
padding-bottom: 0;
}
#PanelUI-pocketView > .panel-subview-body,
#PanelUI-pocketView {
overflow: visible;
}
#pocket-button {
list-style-image: url("chrome://browser/skin/Toolbar.png");
}
toolbar[brighttext] #pocket-button {
list-style-image: url(chrome://browser/skin/Toolbar-inverted.png);
}
@media not all and (min-resolution: 1.1dppx) {
#pocket-button[cui-areatype="menu-panel"],
toolbarpaletteitem[place="palette"] > #pocket-button {
list-style-image: var(--menupanel-list-style-image);
-moz-image-region: rect(0px, 992px, 32px, 960px);
}
#pocket-button[cui-areatype="menu-panel"][panel-multiview-anchor=true] {
-moz-image-region: rect(32px, 992px, 64px, 960px);
}
}
@media (min-resolution: 1.1dppx) {
#pocket-button {
list-style-image: url("chrome://browser/skin/Toolbar@2x.png");
}
toolbar[brighttext] #pocket-button {
list-style-image: url("chrome://browser/skin/Toolbar-inverted@2x.png");
}
#pocket-button[cui-areatype="menu-panel"],
toolbarpaletteitem[place="palette"] > #pocket-button {
list-style-image: var(--menupanel-list-style-image-2x);
-moz-image-region: rect(0px, 1984px, 64px, 1920px);
}
#pocket-button[cui-areatype="menu-panel"][panel-multiview-anchor=true] {
-moz-image-region: rect(64px, 1984px, 128px, 1920px);
}
}
#pocket-button[cui-areatype="toolbar"] {
-moz-image-region: rect(0, 774px, 18px, 756px);
}
#pocket-button[cui-areatype="toolbar"][open] {
-moz-image-region: rect(18px, 774px, 36px, 756px);
}
#panelMenu_pocket,
#menu_pocket,
#BMB_pocket {
list-style-image: url("chrome://pocket/content/panels/img/pocketmenuitem16.png");
}

View File

@ -0,0 +1,9 @@
@media (min-resolution: 1.1dppx) {
#pocket-button[cui-areatype="toolbar"] {
-moz-image-region: rect(0, 1548px, 36px, 1512px);
}
#pocket-button[cui-areatype="toolbar"][open] {
-moz-image-region: rect(36px, 1548px, 72px, 1512px);
}
}

View File

@ -133,6 +133,7 @@ ifdef MOZ_WEBAPP_RUNTIME
@$(MAKE) -C ../../webapprt/locales AB_CD=$* XPI_NAME=locale-$* @$(MAKE) -C ../../webapprt/locales AB_CD=$* XPI_NAME=locale-$*
endif endif
@$(MAKE) -C ../../extensions/spellcheck/locales AB_CD=$* XPI_NAME=locale-$* @$(MAKE) -C ../../extensions/spellcheck/locales AB_CD=$* XPI_NAME=locale-$*
@$(MAKE) -C ../extensions/pocket/locales AB_CD=$* XPI_NAME=locale-$*
@$(MAKE) -C ../../intl/locales AB_CD=$* XPI_NAME=locale-$* @$(MAKE) -C ../../intl/locales AB_CD=$* XPI_NAME=locale-$*
@$(MAKE) -C ../../devtools/client/locales AB_CD=$* XPI_NAME=locale-$* XPI_ROOT_APPID='$(XPI_ROOT_APPID)' @$(MAKE) -C ../../devtools/client/locales AB_CD=$* XPI_NAME=locale-$* XPI_ROOT_APPID='$(XPI_ROOT_APPID)'
@$(MAKE) -B searchplugins AB_CD=$* XPI_NAME=locale-$* @$(MAKE) -B searchplugins AB_CD=$* XPI_NAME=locale-$*

View File

@ -934,10 +934,3 @@ you can use these alternative items. Otherwise, their values should be empty. -
<!ENTITY emeNotificationsNotNow.accesskey "N"> <!ENTITY emeNotificationsNotNow.accesskey "N">
<!ENTITY emeNotificationsDontAskAgain.label "Don't ask me again"> <!ENTITY emeNotificationsDontAskAgain.label "Don't ask me again">
<!ENTITY emeNotificationsDontAskAgain.accesskey "D"> <!ENTITY emeNotificationsDontAskAgain.accesskey "D">
<!-- LOCALIZATION NOTE (saveToPocketCmd.label, saveLinkToPocketCmd.label, pocketMenuitem.label): Pocket is a brand name -->
<!ENTITY saveToPocketCmd.label "Save Page to Pocket">
<!ENTITY saveToPocketCmd.accesskey "k">
<!ENTITY saveLinkToPocketCmd.label "Save Link to Pocket">
<!ENTITY saveLinkToPocketCmd.accesskey "o">
<!ENTITY pocketMenuitem.label "View Pocket List">

View File

@ -124,10 +124,5 @@ web-apps-button.tooltiptext = Discover Apps
devtools-webide-button2.label = WebIDE devtools-webide-button2.label = WebIDE
devtools-webide-button2.tooltiptext = Open WebIDE (%S) devtools-webide-button2.tooltiptext = Open WebIDE (%S)
# LOCALIZATION NOTE(pocket-button.label, pocket-button.tooltiptext): "Pocket"
# is a brand name.
pocket-button.label = Pocket
pocket-button.tooltiptext = Save to Pocket
e10s-button.label = New Non-e10s Window e10s-button.label = New Non-e10s Window
e10s-button.tooltiptext = Open a new Non-e10s Window e10s-button.tooltiptext = Open a new Non-e10s Window

View File

@ -11,7 +11,8 @@ def test(mod, path, entity = None):
"extensions/reporter", "extensions/spellcheck", "extensions/reporter", "extensions/spellcheck",
"other-licenses/branding/firefox", "other-licenses/branding/firefox",
"browser/branding/official", "browser/branding/official",
"services/sync"): "services/sync",
"browser/extensions/pocket"):
return "ignore" return "ignore"
if mod not in ("browser", "extensions/spellcheck"): if mod not in ("browser", "extensions/spellcheck"):
# we only have exceptions for browser and extensions/spellcheck # we only have exceptions for browser and extensions/spellcheck

View File

@ -24,7 +24,6 @@
locale/browser/browser.dtd (%chrome/browser/browser.dtd) locale/browser/browser.dtd (%chrome/browser/browser.dtd)
locale/browser/baseMenuOverlay.dtd (%chrome/browser/baseMenuOverlay.dtd) locale/browser/baseMenuOverlay.dtd (%chrome/browser/baseMenuOverlay.dtd)
locale/browser/browser.properties (%chrome/browser/browser.properties) locale/browser/browser.properties (%chrome/browser/browser.properties)
locale/browser/browser-pocket.properties (%chrome/browser/browser-pocket.properties)
locale/browser/customizableui/customizableWidgets.properties (%chrome/browser/customizableui/customizableWidgets.properties) locale/browser/customizableui/customizableWidgets.properties (%chrome/browser/customizableui/customizableWidgets.properties)
locale/browser/lightweightThemes.properties (%chrome/browser/lightweightThemes.properties) locale/browser/lightweightThemes.properties (%chrome/browser/lightweightThemes.properties)
locale/browser/loop/loop.properties (%chrome/browser/loop/loop.properties) locale/browser/loop/loop.properties (%chrome/browser/loop/loop.properties)

View File

@ -12,6 +12,7 @@ dirs = browser
other-licenses/branding/firefox other-licenses/branding/firefox
browser/branding/official browser/branding/official
devtools/client devtools/client
browser/extensions/pocket
[includes] [includes]
# non-central apps might want to use %(topsrcdir)s here, or other vars # non-central apps might want to use %(topsrcdir)s here, or other vars

View File

@ -13,7 +13,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm"); Cu.import("resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI", "resource:///modules/CustomizableUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils","resource://gre/modules/PlacesUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils","resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode", "resource://gre/modules/ReaderMode.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode", "resource://gre/modules/ReaderMode.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "UITour", "resource:///modules/UITour.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "UITour", "resource:///modules/UITour.jsm");
@ -25,11 +24,9 @@ var ReaderParent = {
MESSAGES: [ MESSAGES: [
"Reader:AddToList", "Reader:AddToList",
"Reader:AddToPocket",
"Reader:ArticleGet", "Reader:ArticleGet",
"Reader:FaviconRequest", "Reader:FaviconRequest",
"Reader:ListStatusRequest", "Reader:ListStatusRequest",
"Reader:PocketEnabledGet",
"Reader:RemoveFromList", "Reader:RemoveFromList",
"Reader:Share", "Reader:Share",
"Reader:SystemUIVisibility", "Reader:SystemUIVisibility",
@ -47,24 +44,6 @@ var ReaderParent = {
receiveMessage: function(message) { receiveMessage: function(message) {
switch (message.name) { switch (message.name) {
case "Reader:AddToPocket": {
let doc = message.target.ownerDocument;
let pocketWidget = doc.getElementById("pocket-button");
let placement = CustomizableUI.getPlacementOfWidget("pocket-button");
if (placement) {
if (placement.area == CustomizableUI.AREA_PANEL) {
doc.defaultView.PanelUI.show().then(function() {
// The DOM node might not exist yet if the panel wasn't opened before.
pocketWidget = doc.getElementById("pocket-button");
pocketWidget.doCommand();
});
} else {
pocketWidget.doCommand();
}
}
break;
}
case "Reader:ArticleGet": case "Reader:ArticleGet":
this._getArticle(message.data.url, message.target).then((article) => { this._getArticle(message.data.url, message.target).then((article) => {
// Make sure the target browser is still alive before trying to send data back. // Make sure the target browser is still alive before trying to send data back.
@ -78,13 +57,6 @@ var ReaderParent = {
}); });
break; break;
case "Reader:PocketEnabledGet": {
let pocketPlacement = CustomizableUI.getPlacementOfWidget("pocket-button");
let isPocketEnabled = pocketPlacement && pocketPlacement.area;
message.target.messageManager.sendAsyncMessage("Reader:PocketEnabledData", { enabled: !!isPocketEnabled});
break;
}
case "Reader:FaviconRequest": { case "Reader:FaviconRequest": {
if (message.target.messageManager) { if (message.target.messageManager) {
let faviconUrl = PlacesUtils.promiseFaviconLinkUrl(message.data.url); let faviconUrl = PlacesUtils.promiseFaviconLinkUrl(message.data.url);

View File

@ -524,12 +524,6 @@ menuitem:not([type]):not(.menuitem-tooltip):not(.menuitem-iconic-tooltip) {
list-style-image: url("chrome://browser/skin/places/unsortedBookmarks.png"); list-style-image: url("chrome://browser/skin/places/unsortedBookmarks.png");
} }
#panelMenu_pocket,
#menu_pocket,
#BMB_pocket {
list-style-image: url("chrome://browser/content/pocket/panels/img/pocketmenuitem16.png");
}
#menu_openDownloads { #menu_openDownloads {
list-style-image: url("chrome://browser/skin/Toolbar-small.png"); list-style-image: url("chrome://browser/skin/Toolbar-small.png");
-moz-image-region: rect(0px 16px 16px 0px); -moz-image-region: rect(0px 16px 16px 0px);

View File

@ -593,24 +593,6 @@ toolbarpaletteitem[place="palette"] > #personal-bookmarks > #bookmarks-toolbar-p
} }
} }
#panelMenu_pocket,
#menu_pocket,
#BMB_pocket {
list-style-image: url("chrome://browser/content/pocket/panels/img/pocketmenuitem16.png");
}
@media (min-resolution: 2dppx) {
#panelMenu_pocket,
#menu_pocket,
#BMB_pocket {
list-style-image: url("chrome://browser/content/pocket/panels/img/pocketmenuitem16@2x.png");
}
#panelMenu_pocket > .toolbarbutton-icon {
width: 16px;
}
}
/* ----- PRIMARY TOOLBAR BUTTONS ----- */ /* ----- PRIMARY TOOLBAR BUTTONS ----- */
:-moz-any(toolbar, .widget-overflow-list) .toolbarbutton-1 > .toolbarbutton-icon, :-moz-any(toolbar, .widget-overflow-list) .toolbarbutton-1 > .toolbarbutton-icon,
@ -839,10 +821,6 @@ toolbar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker > .dropmarker-ic
-moz-image-region: rect(18px, 738px, 36px, 720px); -moz-image-region: rect(18px, 738px, 36px, 720px);
} }
#pocket-button@toolbarButtonPressed@ {
-moz-image-region: rect(18px, 774px, 36px, 756px);
}
#new-tab-button@toolbarButtonPressed@ { #new-tab-button@toolbarButtonPressed@ {
-moz-image-region: rect(18px, 360px, 36px, 342px); -moz-image-region: rect(18px, 360px, 36px, 342px);
} }
@ -1006,10 +984,6 @@ toolbar .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker > .dropmarker-ic
-moz-image-region: rect(36px, 1476px, 72px, 1440px); -moz-image-region: rect(36px, 1476px, 72px, 1440px);
} }
#pocket-button@toolbarButtonPressed@ {
-moz-image-region: rect(36px, 1548px, 72px, 1512px);
}
#new-tab-button@toolbarButtonPressed@ { #new-tab-button@toolbarButtonPressed@ {
-moz-image-region: rect(36px, 720px, 72px, 684px); -moz-image-region: rect(36px, 720px, 72px, 684px);
} }

View File

@ -2,7 +2,7 @@
% Note that zoom-reset-button is a bit different since it doesn't use an image and thus has the image with display: none. % Note that zoom-reset-button is a bit different since it doesn't use an image and thus has the image with display: none.
%define nestedButtons #zoom-out-button, #zoom-reset-button, #zoom-in-button, #cut-button, #copy-button, #paste-button %define nestedButtons #zoom-out-button, #zoom-reset-button, #zoom-in-button, #cut-button, #copy-button, #paste-button
%define primaryToolbarButtons #back-button, #forward-button, #home-button, #print-button, #downloads-button, #bookmarks-menu-button, #new-tab-button, #new-window-button, #fullscreen-button, #sync-button, #feed-button, #social-share-button, #open-file-button, #find-button, #developer-button, #preferences-button, #privatebrowsing-button, #save-page-button, #add-ons-button, #history-panelmenu, #nav-bar-overflow-button, #PanelUI-menu-button, #characterencoding-button, #email-link-button, #sidebar-button, @nestedButtons@, #e10s-button, #panic-button, #web-apps-button, #webide-button, #pocket-button %define primaryToolbarButtons #back-button, #forward-button, #home-button, #print-button, #downloads-button, #bookmarks-menu-button, #new-tab-button, #new-window-button, #fullscreen-button, #sync-button, #feed-button, #social-share-button, #open-file-button, #find-button, #developer-button, #preferences-button, #privatebrowsing-button, #save-page-button, #add-ons-button, #history-panelmenu, #nav-bar-overflow-button, #PanelUI-menu-button, #characterencoding-button, #email-link-button, #sidebar-button, @nestedButtons@, #e10s-button, #panic-button, #web-apps-button, #webide-button
%ifdef XP_MACOSX %ifdef XP_MACOSX
% Prior to 10.7 there wasn't a native fullscreen button so we use #restore-button to exit fullscreen % Prior to 10.7 there wasn't a native fullscreen button so we use #restore-button to exit fullscreen

View File

@ -250,11 +250,6 @@ panelmultiview[nosubviews=true] > .panel-viewcontainer > .panel-viewstack > .pan
max-width: @standaloneSubviewWidth@; max-width: @standaloneSubviewWidth@;
} }
/* Bug 1164419 - increase Pocket panel size to accomidate wider Russian text. */
panelmultiview[mainViewId=PanelUI-pocketView] > .panel-viewcontainer > .panel-viewstack > .panel-mainview:not([panelid="PanelUI-popup"]) {
max-width: 33em; /* standaloneSubviewWidth + 3 */
}
panelview:not([mainview]) .toolbarbutton-text, panelview:not([mainview]) .toolbarbutton-text,
.cui-widget-panel toolbarbutton > .toolbarbutton-text { .cui-widget-panel toolbarbutton > .toolbarbutton-text {
text-align: start; text-align: start;
@ -265,11 +260,6 @@ panelview:not([mainview]) .toolbarbutton-text,
padding: 4px 0; padding: 4px 0;
} }
.cui-widget-panel[viewId="PanelUI-pocketView"] > .panel-arrowcontainer > .panel-arrowcontent {
padding-top: 0;
padding-bottom: 0;
}
.cui-widget-panel.cui-widget-panelWithFooter > .panel-arrowcontainer > .panel-arrowcontent { .cui-widget-panel.cui-widget-panelWithFooter > .panel-arrowcontainer > .panel-arrowcontent {
padding-bottom: 0; padding-bottom: 0;
} }
@ -1405,9 +1395,7 @@ menuitem[checked="true"].subviewbutton > .menu-iconic-left {
#customizationui-widget-multiview > .panel-viewcontainer, #customizationui-widget-multiview > .panel-viewcontainer,
#customizationui-widget-multiview > .panel-viewcontainer > .panel-viewstack, #customizationui-widget-multiview > .panel-viewcontainer > .panel-viewstack,
#PanelUI-panicView > .panel-subview-body, #PanelUI-panicView > .panel-subview-body,
#PanelUI-panicView, #PanelUI-panicView {
#PanelUI-pocketView > .panel-subview-body,
#PanelUI-pocketView {
overflow: visible; overflow: visible;
} }

View File

@ -168,15 +168,6 @@
-moz-image-region: rect(0px, 960px, 32px, 928px); -moz-image-region: rect(0px, 960px, 32px, 928px);
} }
#pocket-button[cui-areatype="menu-panel"],
toolbarpaletteitem[place="palette"] > #pocket-button {
-moz-image-region: rect(0px, 992px, 32px, 960px);
}
#pocket-button[cui-areatype="menu-panel"][panel-multiview-anchor=true] {
-moz-image-region: rect(32px, 992px, 64px, 960px);
}
toolbaritem[sdkstylewidget="true"] > toolbarbutton { toolbaritem[sdkstylewidget="true"] > toolbarbutton {
-moz-image-region: rect(0, 832px, 32px, 800px); -moz-image-region: rect(0, 832px, 32px, 800px);
} }
@ -315,15 +306,6 @@
-moz-image-region: rect(0px, 1920px, 64px, 1856px); -moz-image-region: rect(0px, 1920px, 64px, 1856px);
} }
#pocket-button[cui-areatype="menu-panel"],
toolbarpaletteitem[place="palette"] > #pocket-button {
-moz-image-region: rect(0px, 1984px, 64px, 1920px);
}
#pocket-button[cui-areatype="menu-panel"][panel-multiview-anchor=true] {
-moz-image-region: rect(64px, 1984px, 128px, 1920px);
}
#new-tab-button[cui-areatype="menu-panel"], #new-tab-button[cui-areatype="menu-panel"],
toolbarpaletteitem[place="palette"] > #new-tab-button { toolbarpaletteitem[place="palette"] > #new-tab-button {
-moz-image-region: rect(0px, 1088px, 64px, 1024px); -moz-image-region: rect(0px, 1088px, 64px, 1024px);

View File

@ -175,18 +175,6 @@ toolbar[brighttext] #bookmarks-menu-button > .toolbarbutton-menubutton-dropmarke
-moz-image-region: rect(0, 738px, 18px, 720px); -moz-image-region: rect(0, 738px, 18px, 720px);
} }
#pocket-button[cui-areatype="toolbar"] {
-moz-image-region: rect(0, 774px, 18px, 756px);
}
#pocket-button[cui-areatype="toolbar"][open] {
%ifdef XP_MACOSX
-moz-image-region: rect(36px, 774px, 54px, 756px);
%else
-moz-image-region: rect(18px, 774px, 36px, 756px);
%endif
}
%if defined(XP_WIN) || defined(XP_MACOSX) %if defined(XP_WIN) || defined(XP_MACOSX)
@media (min-resolution: 1.1dppx) { @media (min-resolution: 1.1dppx) {
:-moz-any(@primaryToolbarButtons@), :-moz-any(@primaryToolbarButtons@),
@ -357,17 +345,5 @@ toolbar[brighttext] #bookmarks-menu-button > .toolbarbutton-menubutton-dropmarke
#webide-button[cui-areatype="toolbar"] { #webide-button[cui-areatype="toolbar"] {
-moz-image-region: rect(0, 1476px, 36px, 1440px); -moz-image-region: rect(0, 1476px, 36px, 1440px);
} }
#pocket-button[cui-areatype="toolbar"] {
-moz-image-region: rect(0, 1548px, 36px, 1512px);
}
#pocket-button[cui-areatype="toolbar"][open] {
%ifdef XP_MACOSX
-moz-image-region: rect(72px, 1548px, 108px, 1512px);
%else
-moz-image-region: rect(36px, 1548px, 72px, 1512px);
%endif
}
} }
%endif %endif

View File

@ -2304,12 +2304,6 @@ notification[value="translation"] {
-moz-image-region: auto; -moz-image-region: auto;
} }
#panelMenu_pocket,
#menu_pocket,
#BMB_pocket {
list-style-image: url("chrome://browser/content/pocket/panels/img/pocketmenuitem16.png");
}
/* ::::: Keyboard UI Panel ::::: */ /* ::::: Keyboard UI Panel ::::: */
.KUI-panel { .KUI-panel {

Some files were not shown because too many files have changed in this diff Show More