Source code

Revision control

Other Tools

1
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
"use strict";
6
7
var EXPORTED_SYMBOLS = ["BrowserTabChild"];
8
9
ChromeUtils.defineModuleGetter(
10
this,
11
"E10SUtils",
13
);
14
15
class BrowserTabChild extends JSWindowActorChild {
16
constructor() {
17
super();
18
this.handledWindowCreated = false;
19
this.handledFirstPaint = false;
20
}
21
22
handleEvent(event) {
23
switch (event.type) {
24
case "DOMWindowCreated": {
25
if (this.handledWindowCreated) {
26
return;
27
}
28
this.handledWindowCreated = true;
29
30
let context = this.manager.browsingContext;
31
let loadContext = context.docShell.QueryInterface(Ci.nsILoadContext);
32
let userContextId = loadContext.originAttributes.userContextId;
33
34
this.sendAsyncMessage("Browser:WindowCreated", { userContextId });
35
break;
36
}
37
38
case "MozAfterPaint":
39
if (this.handledFirstPaint) {
40
return;
41
}
42
this.handledFirstPaint = true;
43
this.sendAsyncMessage("Browser:FirstPaint", {});
44
break;
45
46
case "MozDOMPointerLock:Entered":
47
this.sendAsyncMessage("PointerLock:Entered", {
48
originNoSuffix: event.target.nodePrincipal.originNoSuffix,
49
});
50
break;
51
52
case "MozDOMPointerLock:Exited":
53
this.sendAsyncMessage("PointerLock:Exited");
54
break;
55
}
56
}
57
58
receiveMessage(message) {
59
let context = this.manager.browsingContext;
60
let docShell = context.docShell;
61
62
switch (message.name) {
63
case "Browser:AppTab":
64
if (docShell) {
65
docShell.isAppTab = message.data.isAppTab;
66
}
67
break;
68
69
case "Browser:HasSiblings":
70
try {
71
let browserChild = docShell
72
.QueryInterface(Ci.nsIInterfaceRequestor)
73
.getInterface(Ci.nsIBrowserChild);
74
let hasSiblings = message.data;
75
browserChild.hasSiblings = hasSiblings;
76
} catch (e) {}
77
break;
78
79
// XXX(nika): Should we try to call this in the parent process instead?
80
case "Browser:Reload":
81
/* First, we'll try to use the session history object to reload so
82
* that framesets are handled properly. If we're in a special
83
* window (such as view-source) that has no session history, fall
84
* back on using the web navigation's reload method.
85
*/
86
let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
87
try {
88
if (webNav.sessionHistory) {
89
webNav = webNav.sessionHistory;
90
}
91
} catch (e) {}
92
93
let reloadFlags = message.data.flags;
94
try {
95
E10SUtils.wrapHandlingUserInput(
96
this.document.defaultView,
97
message.data.handlingUserInput,
98
() => webNav.reload(reloadFlags)
99
);
100
} catch (e) {}
101
break;
102
103
case "MixedContent:ReenableProtection":
104
docShell.mixedContentChannel = null;
105
break;
106
107
case "UpdateCharacterSet":
108
docShell.charset = message.data.value;
109
docShell.gatherCharsetMenuTelemetry();
110
break;
111
}
112
}
113
}