Bug 1705982 - Add a minimal about:address book and a preference for opening it. r=mkmelin
Differential Revision: https://phabricator.services.mozilla.com/D112492 --HG-- extra : rebase_source : f3153aaa3f69de53684666052c7810c494292b01 extra : amend_source : d5c91be35eaa387d38fe09a95bc7375905255f2f
This commit is contained in:
Родитель
5639ea70da
Коммит
ed09a085f3
|
@ -1309,3 +1309,8 @@ pref("mail.activity.loglevel", "Warn");
|
|||
|
||||
// The number of public recipients before we offer BCC addressing.
|
||||
pref("mail.compose.warn_public_recipients.threshold", 15);
|
||||
|
||||
// Temporary pref while both Address Book UIs exist.
|
||||
// Set to false for addressbook.xhtml in a window, or true for
|
||||
// about:addressbook in a tab.
|
||||
pref("mail.addr_book.useNewAddressBook", false);
|
||||
|
|
|
@ -96,16 +96,5 @@ function writeNewMessageDock() {
|
|||
* Open the address book window
|
||||
*/
|
||||
function openAddressBookDock() {
|
||||
let win = Services.wm.getMostRecentWindow("mail:addressbook");
|
||||
if (win) {
|
||||
win.focus();
|
||||
} else {
|
||||
Services.ww.openWindow(
|
||||
null,
|
||||
"chrome://messenger/content/addressbook/addressbook.xhtml",
|
||||
null,
|
||||
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar",
|
||||
null
|
||||
);
|
||||
}
|
||||
toAddressBook();
|
||||
}
|
||||
|
|
|
@ -483,17 +483,17 @@ function toOpenWindowByType(inType, uri) {
|
|||
var topWindow = Services.wm.getMostRecentWindow(inType);
|
||||
if (topWindow) {
|
||||
topWindow.focus();
|
||||
} else {
|
||||
window.open(
|
||||
uri,
|
||||
"_blank",
|
||||
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"
|
||||
);
|
||||
return topWindow;
|
||||
}
|
||||
return window.open(
|
||||
uri,
|
||||
"_blank",
|
||||
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"
|
||||
);
|
||||
}
|
||||
|
||||
function toMessengerWindow() {
|
||||
toOpenWindowByType(
|
||||
return toOpenWindowByType(
|
||||
"mail:3pane",
|
||||
"chrome://messenger/content/messenger.xhtml"
|
||||
);
|
||||
|
@ -518,8 +518,29 @@ function focusOnMail(tabNo, event) {
|
|||
}
|
||||
}
|
||||
|
||||
function toAddressBook() {
|
||||
toOpenWindowByType(
|
||||
async function toAddressBook() {
|
||||
if (Services.prefs.getBoolPref("mail.addr_book.useNewAddressBook")) {
|
||||
let messengerWindow = toMessengerWindow();
|
||||
if (messengerWindow.document.readyState != "complete") {
|
||||
await new Promise(resolve =>
|
||||
messengerWindow.addEventListener("load", resolve, { once: true })
|
||||
);
|
||||
}
|
||||
|
||||
let tab = messengerWindow.openContentTab("about:addressbook");
|
||||
if (!tab.browser.docShell.hasLoadedNonBlankURI) {
|
||||
await new Promise(resolve =>
|
||||
tab.browser.addEventListener("load", resolve, {
|
||||
capture: true,
|
||||
once: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return tab.browser.contentWindow;
|
||||
}
|
||||
|
||||
return toOpenWindowByType(
|
||||
"mail:addressbook",
|
||||
"chrome://messenger/content/addressbook/addressbook.xhtml"
|
||||
);
|
||||
|
|
|
@ -1072,7 +1072,7 @@
|
|||
label="&addressBookCmd.label;"
|
||||
accesskey="&addressBookCmd.accesskey;"
|
||||
key="key_addressbook"
|
||||
oncommand="toOpenWindowByType('mail:addressbook', 'chrome://messenger/content/addressbook/addressbook.xhtml');"
|
||||
oncommand="toAddressBook();"
|
||||
class="menuitem-iconic"/>
|
||||
<menuseparator id="devToolsSeparator"/>
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,10 @@ var gSpellChecker = new InlineSpellChecker();
|
|||
|
||||
/** Called by ContextMenuParent.jsm */
|
||||
function openContextMenu({ data }, browser, actor) {
|
||||
if (!browser.hasAttribute("context")) {
|
||||
return;
|
||||
}
|
||||
|
||||
let spellInfo = data.spellInfo;
|
||||
let frameReferrerInfo = data.frameReferrerInfo;
|
||||
let linkReferrerInfo = data.linkReferrerInfo;
|
||||
|
|
|
@ -342,6 +342,7 @@ var contentTabBaseType = {
|
|||
// Note that about:preferences is loaded via a different mechanism.
|
||||
inContentWhitelist: [
|
||||
"about:addons",
|
||||
"about:addressbook",
|
||||
"about:blank",
|
||||
"about:profiles",
|
||||
"about:*",
|
||||
|
@ -359,6 +360,11 @@ var contentTabBaseType = {
|
|||
);
|
||||
},
|
||||
|
||||
// about:addressbook provides its own context menu.
|
||||
function(aDocument, aTab) {
|
||||
aTab.browser.removeAttribute("context");
|
||||
},
|
||||
|
||||
// Let's not mess with about:blank.
|
||||
null,
|
||||
|
||||
|
|
|
@ -52,6 +52,10 @@ AboutRedirector.prototype = {
|
|||
url: "chrome://messenger/content/accountcreation/accountSetup.xhtml",
|
||||
flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
|
||||
},
|
||||
addressbook: {
|
||||
url: "chrome://messenger/content/addressbook/aboutAddressBook.xhtml",
|
||||
flags: Ci.nsIAboutModule.ALLOW_SCRIPT,
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
/* 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/. */
|
|
@ -0,0 +1,14 @@
|
|||
<?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/. -->
|
||||
<html xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -18,3 +18,6 @@ messenger.jar:
|
|||
content/messenger/addressbook/abSearchDialog.js (content/abSearchDialog.js)
|
||||
content/messenger/addressbook/abTrees.js (content/abTrees.js)
|
||||
content/messenger/addressbook/menulist-addrbooks.js (content/menulist-addrbooks.js)
|
||||
|
||||
content/messenger/addressbook/aboutAddressBook.js (content/aboutAddressBook.js)
|
||||
content/messenger/addressbook/aboutAddressBook.xhtml (content/aboutAddressBook.xhtml)
|
||||
|
|
|
@ -15,7 +15,8 @@ Classes = [
|
|||
'@mozilla.org/network/protocol/about;1?what=policies',
|
||||
'@mozilla.org/network/protocol/about;1?what=newinstall',
|
||||
'@mozilla.org/network/protocol/about;1?what=accountsettings',
|
||||
'@mozilla.org/network/protocol/about;1?what=accountsetup'
|
||||
'@mozilla.org/network/protocol/about;1?what=accountsetup',
|
||||
'@mozilla.org/network/protocol/about;1?what=addressbook',
|
||||
],
|
||||
'jsm': 'resource://gre/modules/AboutRedirector.jsm',
|
||||
'constructor': 'AboutRedirector',
|
||||
|
|
|
@ -1654,7 +1654,7 @@
|
|||
class="subviewbutton subviewbutton-iconic"
|
||||
label="&addressBookCmd.label;"
|
||||
key="key_addressbook"
|
||||
oncommand="toOpenWindowByType('mail:addressbook', 'chrome://messenger/content/addressbook/addressbook.xhtml');"/>
|
||||
oncommand="toAddressBook();"/>
|
||||
<toolbarseparator id="devToolsSeparator"/>
|
||||
<toolbarbutton id="appmenu_filtersCmd"
|
||||
class="subviewbutton subviewbutton-iconic"
|
||||
|
|
|
@ -445,24 +445,26 @@ this.addressBook = class extends ExtensionAPI {
|
|||
return {
|
||||
addressBooks: {
|
||||
async openUI() {
|
||||
let topWindow = Services.wm.getMostRecentWindow(AB_WINDOW_TYPE);
|
||||
if (!topWindow) {
|
||||
topWindow = Services.ww.openWindow(
|
||||
null,
|
||||
AB_WINDOW_URI,
|
||||
"_blank",
|
||||
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar",
|
||||
null
|
||||
let messengerWindow = windowTracker.topNormalWindow;
|
||||
let abWindow = await messengerWindow.toAddressBook();
|
||||
|
||||
if (abWindow.document.readyState != "complete") {
|
||||
await new Promise(resolve =>
|
||||
abWindow.addEventListener("load", resolve, { once: true })
|
||||
);
|
||||
}
|
||||
if (topWindow.document.readyState != "complete") {
|
||||
await new Promise(resolve => {
|
||||
topWindow.addEventListener("load", resolve, { once: true });
|
||||
});
|
||||
}
|
||||
topWindow.focus();
|
||||
|
||||
return new Promise(resolve => abWindow.setTimeout(resolve));
|
||||
},
|
||||
async closeUI() {
|
||||
for (let win of Services.wm.getEnumerator("mail:3pane")) {
|
||||
let tabmail = win.document.getElementById("tabmail");
|
||||
for (let tab of tabmail.tabInfo.slice()) {
|
||||
if (tab.browser?.currentURI.spec == "about:addressbook") {
|
||||
tabmail.closeTab(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let win of Services.wm.getEnumerator(AB_WINDOW_TYPE)) {
|
||||
win.close();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
add_task(async () => {
|
||||
async function subTest(checkCallback) {
|
||||
async function background() {
|
||||
await window.sendMessage("checkNumberOfAddressBookWindows", 0);
|
||||
|
||||
|
@ -28,16 +28,39 @@ add_task(async () => {
|
|||
},
|
||||
});
|
||||
|
||||
extension.onMessage("checkNumberOfAddressBookWindows", count => {
|
||||
is(
|
||||
extension.onMessage("checkNumberOfAddressBookWindows", count =>
|
||||
checkCallback(extension, count)
|
||||
);
|
||||
|
||||
await extension.startup();
|
||||
await extension.awaitFinish("addressBooks");
|
||||
await extension.unload();
|
||||
}
|
||||
|
||||
add_task(async function testWithOldUI() {
|
||||
Services.prefs.setBoolPref("mail.addr_book.useNewAddressBook", false);
|
||||
await subTest((extension, count) => {
|
||||
Assert.equal(
|
||||
[...Services.wm.getEnumerator("mail:addressbook")].length,
|
||||
count,
|
||||
"Right number of address books open"
|
||||
);
|
||||
extension.sendMessage();
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
await extension.awaitFinish("addressBooks");
|
||||
await extension.unload();
|
||||
});
|
||||
|
||||
add_task(async function testWithNewUI() {
|
||||
Services.prefs.setBoolPref("mail.addr_book.useNewAddressBook", true);
|
||||
await subTest((extension, count) => {
|
||||
let tabmail = document.getElementById("tabmail");
|
||||
let tabs = tabmail.tabInfo.filter(
|
||||
tab => tab.browser?.currentURI.spec == "about:addressbook"
|
||||
);
|
||||
Assert.equal(tabs.length, count, "Right number of address books open");
|
||||
extension.sendMessage();
|
||||
});
|
||||
});
|
||||
|
||||
registerCleanupFunction(() =>
|
||||
Services.prefs.clearUserPref("mail.addr_book.useNewAddressBook")
|
||||
);
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
# End Proton icon overrides
|
||||
|
||||
skin/classic/messenger/aboutNetError.css (../shared/mail/aboutNetError.css)
|
||||
skin/classic/messenger/aboutAddressBook.css (../shared/mail/aboutAddressBook.css)
|
||||
skin/classic/messenger/aboutSupport.css (../shared/mail/aboutSupport.css)
|
||||
skin/classic/messenger/folderProps.css (../shared/mail/folderProps.css)
|
||||
skin/classic/messenger/messageQuotes.css (../shared/mail/messageQuotes.css)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
/* 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/. */
|
Загрузка…
Ссылка в новой задаче