mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 1144680 - The Reading List URLbar button should handle about:reader urls and filter out other non-http(s) urls, r=markh.
This commit is contained in:
parent
14ff6d0c06
commit
4ba58a55ed
@ -232,12 +232,22 @@ let ReadingListUI = {
|
||||
// nothing to do if we have no button.
|
||||
return;
|
||||
}
|
||||
if (!this.enabled || state == "invalid") {
|
||||
|
||||
let uri;
|
||||
if (this.enabled && state == "valid") {
|
||||
uri = gBrowser.currentURI;
|
||||
if (uri.schemeIs("about"))
|
||||
uri = ReaderParent.parseReaderUrl(uri.spec);
|
||||
else if (!uri.schemeIs("http") && !uri.schemeIs("https"))
|
||||
uri = null;
|
||||
}
|
||||
|
||||
if (!uri) {
|
||||
this.toolbarButton.setAttribute("hidden", true);
|
||||
return;
|
||||
}
|
||||
|
||||
let isInList = yield ReadingList.containsURL(gBrowser.currentURI);
|
||||
let isInList = yield ReadingList.containsURL(uri);
|
||||
this.setToolbarButtonState(isInList);
|
||||
}),
|
||||
|
||||
@ -268,11 +278,17 @@ let ReadingListUI = {
|
||||
* @returns {Promise} Promise resolved when operation has completed.
|
||||
*/
|
||||
togglePageByBrowser: Task.async(function* (browser) {
|
||||
let item = yield ReadingList.getItemForURL(browser.currentURI);
|
||||
let uri = browser.currentURI;
|
||||
if (uri.spec.startsWith("about:reader?"))
|
||||
uri = ReaderParent.parseReaderUrl(uri.spec);
|
||||
if (!uri)
|
||||
return;
|
||||
|
||||
let item = yield ReadingList.getItemForURL(uri);
|
||||
if (item) {
|
||||
yield item.delete();
|
||||
} else {
|
||||
yield ReadingList.addItemFromBrowser(browser);
|
||||
yield ReadingList.addItemFromBrowser(browser, uri);
|
||||
}
|
||||
}),
|
||||
|
||||
@ -284,6 +300,9 @@ let ReadingListUI = {
|
||||
*/
|
||||
isItemForCurrentBrowser(item) {
|
||||
let currentURL = gBrowser.currentURI.spec;
|
||||
if (currentURL.startsWith("about:reader?"))
|
||||
currentURL = ReaderParent.parseReaderUrl(currentURL);
|
||||
|
||||
if (item.url == currentURL || item.resolvedURL == currentURL) {
|
||||
return true;
|
||||
}
|
||||
|
@ -289,13 +289,15 @@ ReadingListImpl.prototype = {
|
||||
/**
|
||||
* Add to the ReadingList the page that is loaded in a given browser.
|
||||
*
|
||||
* @param {<xul:browser>} browser - Browser element for the document.
|
||||
* @param {<xul:browser>} browser - Browser element for the document,
|
||||
* used to get metadata about the article.
|
||||
* @param {nsIURI/string} url - url to add to the reading list.
|
||||
* @return {Promise} Promise that is fullfilled with the added item.
|
||||
*/
|
||||
addItemFromBrowser: Task.async(function* (browser) {
|
||||
addItemFromBrowser: Task.async(function* (browser, url) {
|
||||
let metadata = yield getMetadataFromBrowser(browser);
|
||||
let itemData = {
|
||||
url: browser.currentURI,
|
||||
url: url,
|
||||
title: metadata.title,
|
||||
resolvedURL: metadata.url,
|
||||
excerpt: metadata.description,
|
||||
|
Loading…
Reference in New Issue
Block a user