-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #328 from thundernest/v12.0.0
V12.0.0
- Loading branch information
Showing
40 changed files
with
4,092 additions
and
4,972 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Usage description can be found in the [wiki](https://github.com/thundernest/addon-developer-support/wiki/Using-the-WindowListener-API-to-convert-a-Legacy-Overlay-WebExtension-into-a-MailExtension-for-Thunderbird-78). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* This file is provided by the addon-developer-support repository at | ||
* https://github.com/thundernest/addon-developer-support | ||
* | ||
* Version: 1.56 | ||
* Version: 1.57 | ||
* | ||
* Author: John Bieling ([email protected]) | ||
* | ||
|
@@ -200,7 +200,7 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI { | |
// returns the outer browser, not the nested browser of the add-on manager | ||
// events must be attached to the outer browser | ||
getAddonManagerFromTab(tab) { | ||
if (tab.browser) { | ||
if (tab.browser && tab.mode.name == "contentTab") { | ||
let win = tab.browser.contentWindow; | ||
if (win && win.location.href == "about:addons") { | ||
return win; | ||
|
@@ -211,9 +211,28 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI { | |
getAddonManagerFromWindow(window) { | ||
let tabMail = this.getTabMail(window); | ||
for (let tab of tabMail.tabInfo) { | ||
let win = this.getAddonManagerFromTab(tab); | ||
if (win) { | ||
return win; | ||
let managerWindow = this.getAddonManagerFromTab(tab); | ||
if (managerWindow) { | ||
return managerWindow; | ||
} | ||
} | ||
} | ||
|
||
async getAddonManagerFromWindowWaitForLoad(window) { | ||
let { setTimeout } = Services.wm.getMostRecentWindow("mail:3pane"); | ||
|
||
let tabMail = this.getTabMail(window); | ||
for (let tab of tabMail.tabInfo) { | ||
if (tab.browser && tab.mode.name == "contentTab") { | ||
// Instead of registering a load observer, wait until its loaded. Not nice, | ||
// but gets aroud a lot of edge cases. | ||
while(!tab.pageLoaded) { | ||
await new Promise(r => setTimeout(r, 150)); | ||
} | ||
let managerWindow = this.getAddonManagerFromTab(tab); | ||
if (managerWindow) { | ||
return managerWindow; | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -329,41 +348,20 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI { | |
|
||
// TabMonitor to detect opening of tabs, to setup the options button in the add-on manager. | ||
this.tabMonitor = { | ||
onTabTitleChanged(aTab) { }, | ||
onTabClosing(aTab) { }, | ||
onTabPersist(aTab) { }, | ||
onTabRestored(aTab) { }, | ||
onTabSwitched(aNewTab, aOldTab) { | ||
//self.setupAddonManager(self.getAddonManagerFromTab(aNewTab)); | ||
}, | ||
async onTabOpened(aTab) { | ||
if (aTab.browser) { | ||
if (!aTab.pageLoaded) { | ||
// await a location change if browser is not loaded yet | ||
await new Promise((resolve) => { | ||
let reporterListener = { | ||
QueryInterface: ChromeUtils.generateQI([ | ||
"nsIWebProgressListener", | ||
"nsISupportsWeakReference", | ||
]), | ||
onStateChange() { }, | ||
onProgressChange() { }, | ||
onLocationChange( | ||
/* in nsIWebProgress*/ aWebProgress, | ||
/* in nsIRequest*/ aRequest, | ||
/* in nsIURI*/ aLocation | ||
) { | ||
aTab.browser.removeProgressListener(reporterListener); | ||
resolve(); | ||
}, | ||
onStatusChange() { }, | ||
onSecurityChange() { }, | ||
onContentBlockingEvent() { }, | ||
}; | ||
aTab.browser.addProgressListener(reporterListener); | ||
}); | ||
onTabTitleChanged(tab) { }, | ||
onTabClosing(tab) { }, | ||
onTabPersist(tab) { }, | ||
onTabRestored(tab) { }, | ||
onTabSwitched(aNewTab, aOldTab) { }, | ||
async onTabOpened(tab) { | ||
if (tab.browser && tab.mode.name == "contentTab") { | ||
let { setTimeout } = Services.wm.getMostRecentWindow("mail:3pane"); | ||
// Instead of registering a load observer, wait until its loaded. Not nice, | ||
// but gets aroud a lot of edge cases. | ||
while(!tab.pageLoaded) { | ||
await new Promise(r => setTimeout(r, 150)); | ||
} | ||
self.setupAddonManager(self.getAddonManagerFromTab(aTab)); | ||
self.setupAddonManager(self.getAddonManagerFromTab(tab)); | ||
} | ||
}, | ||
}; | ||
|
@@ -594,16 +592,14 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI { | |
self | ||
); | ||
} else { | ||
// Setup the options button/menu in the add-on manager, if it is already open. | ||
self.setupAddonManager( | ||
self.getAddonManagerFromWindow(window), | ||
true | ||
); | ||
// Add a tabmonitor, to be able to setup the options button/menu in the add-on manager. | ||
self | ||
.getTabMail(window) | ||
.registerTabMonitor(self.tabMonitor); | ||
window[self.uniqueRandomID].hasTabMonitor = true; | ||
// Setup the options button/menu in the add-on manager, if it is already open. | ||
let managerWindow = await self.getAddonManagerFromWindowWaitForLoad(window); | ||
self.setupAddonManager(managerWindow, true); | ||
} | ||
} | ||
} | ||
|
@@ -1183,4 +1179,4 @@ var WindowListener = class extends ExtensionCommon.ExtensionAPI { | |
this.chromeHandle = null; | ||
} | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.