Bug 1473073 - Remove PlacesCommandHook.bookmarkPage's browser argument. r=mak

MozReview-Commit-ID: BH5r7Tn8KV1

--HG--
extra : rebase_source : 845e8ec126d91f682ed09939aa89c07bd2c1078e
This commit is contained in:
Dão Gottwald 2018-07-03 22:46:46 +02:00
Родитель 3c75e1e85c
Коммит 96a00916f7
5 изменённых файлов: 15 добавлений и 17 удалений

Просмотреть файл

@ -387,21 +387,20 @@ var StarUI = {
var PlacesCommandHook = {
/**
* Adds a bookmark to the page loaded in the given browser.
* Adds a bookmark to the page loaded in the current browser.
*
* @param aBrowser
* a <browser> element.
* @param [optional] aUrl
* Option to provide a URL to bookmark rather than the current page
* @param [optional] aTitle
* Option to provide a title for a bookmark to use rather than the
* getting the current page's title
*/
async bookmarkPage(aBrowser, aUrl = null, aTitle = null) {
async bookmarkPage(aUrl = null, aTitle = null) {
let browser = gBrowser.selectedBrowser;
// If aUrl is provided, we want to bookmark that url rather than the
// the current page
let isCurrentBrowser = !aUrl;
let url = aUrl ? new URL(aUrl) : new URL(aBrowser.currentURI.spec);
let url = aUrl ? new URL(aUrl) : new URL(browser.currentURI.spec);
let info = await PlacesUtils.bookmarks.fetch({ url });
let isNewBookmark = !info;
let showEditUI = !isNewBookmark || StarUI.showForNewBookmarks;
@ -412,21 +411,21 @@ var PlacesCommandHook = {
let charset = null;
let isErrorPage = false;
if (!aUrl && aBrowser.documentURI) {
isErrorPage = /^about:(neterror|certerror|blocked)/.test(aBrowser.documentURI.spec);
if (!aUrl && browser.documentURI) {
isErrorPage = /^about:(neterror|certerror|blocked)/.test(browser.documentURI.spec);
}
try {
if (isErrorPage) {
let entry = await PlacesUtils.history.fetch(aBrowser.currentURI);
let entry = await PlacesUtils.history.fetch(browser.currentURI);
if (entry) {
info.title = entry.title;
}
} else {
info.title = aTitle || aBrowser.contentTitle;
info.title = aTitle || browser.contentTitle;
}
info.title = info.title || url.href;
charset = aUrl ? null : aBrowser.characterSet;
charset = aUrl ? null : browser.characterSet;
} catch (e) {
Cu.reportError(e);
}
@ -441,7 +440,7 @@ var PlacesCommandHook = {
info.guid = await PlacesTransactions.NewBookmark(info).transact();
// Set the character-set
if (charset && !PrivateBrowsingUtils.isBrowserPrivate(aBrowser))
if (charset && !PrivateBrowsingUtils.isBrowserPrivate(browser))
PlacesUtils.setCharsetForURI(makeURI(url.href), charset);
}
@ -1601,7 +1600,7 @@ var BookmarkingUI = {
}, { once: true });
this.star.setAttribute("animate", "true");
}
PlacesCommandHook.bookmarkPage(gBrowser.selectedBrowser);
PlacesCommandHook.bookmarkPage();
}
},

Просмотреть файл

@ -57,7 +57,7 @@
#endif
<!-- work-around bug 392512 -->
<command id="Browser:AddBookmarkAs"
oncommand="PlacesCommandHook.bookmarkPage(gBrowser.selectedBrowser);"/>
oncommand="PlacesCommandHook.bookmarkPage();"/>
<!-- The command disabled state must be manually updated through
PlacesCommandHook.updateBookmarkAllTabsCommand() -->
<command id="Browser:BookmarkAllTabs"

Просмотреть файл

@ -1420,7 +1420,7 @@ nsContextMenu.prototype = {
bookmarkThisPage: function CM_bookmarkThisPage() {
window.top.PlacesCommandHook
.bookmarkPage(this.browser)
.bookmarkPage()
.catch(Cu.reportError);
},

Просмотреть файл

@ -98,7 +98,7 @@ async function checkBookmarkedPageTitle(url, default_title, overridden_title) {
// Here we test that if we provide a url and a title to bookmark, it will use the
// title provided rather than the one provided by the current page
PlacesCommandHook.bookmarkPage(gBrowser.selectedBrowser, url, overridden_title);
PlacesCommandHook.bookmarkPage(url, overridden_title);
await promiseBookmark;
let bookmark = await PlacesUtils.bookmarks.fetch({url});
@ -121,7 +121,7 @@ async function checkBookmark(url, expected_title) {
let promiseBookmark = PlacesTestUtils.waitForNotification("onItemAdded",
(id, parentId, index, type, itemUrl) => itemUrl.equals(gBrowser.selectedBrowser.currentURI));
PlacesCommandHook.bookmarkPage(gBrowser.selectedBrowser);
PlacesCommandHook.bookmarkPage();
await promiseBookmark;
let bookmark = await PlacesUtils.bookmarks.fetch({url});

Просмотреть файл

@ -1297,7 +1297,6 @@ var ActivityStreamLinks = {
addBookmark(aData, aBrowser) {
const {url, title} = aData;
return aBrowser.ownerGlobal.PlacesCommandHook.bookmarkPage(
aBrowser,
url,
title);
},