blob: 269405c4ffa34318e14f55ecf7e1d01d50214f4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/* 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/. */
export class LinkHandlerParent extends JSWindowActorParent {
receiveMessage(msg) {
let browser = this.browsingContext.top.embedderElement;
if (!browser) {
return;
}
switch (msg.name) {
case "Link:SetIcon":
this.setIconFromLink(browser, msg.data.iconURL, msg.data.canUseForTab);
break;
}
}
setIconFromLink(browser, iconURL, canUseForTab) {
let tabmail = browser.ownerDocument.getElementById("tabmail");
if (!tabmail) {
return;
}
let tab = tabmail.getTabForBrowser(browser);
if (tab?.mode?.type != "contentTab") {
return;
}
let iconURI;
try {
iconURI = Services.io.newURI(iconURL);
} catch (ex) {
console.error(ex);
return;
}
if (iconURI.scheme != "data") {
try {
Services.scriptSecurityManager.checkLoadURIWithPrincipal(
browser.contentPrincipal,
iconURI,
Services.scriptSecurityManager.ALLOW_CHROME
);
} catch (ex) {
return;
}
}
if (canUseForTab) {
tabmail.setTabFavIcon(
tab,
iconURL,
"chrome://messenger/skin/icons/new/compact/draft.svg"
);
}
}
}
|