no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / browser / actors / BrowserTabChild.sys.mjs
blob04c6e2f17a7cd99620094158bbe116afc12ccad4
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/. */
6 const lazy = {};
8 ChromeUtils.defineESModuleGetters(lazy, {
9   E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
10 });
12 export class BrowserTabChild extends JSWindowActorChild {
13   constructor() {
14     super();
15   }
17   receiveMessage(message) {
18     let context = this.manager.browsingContext;
19     let docShell = context.docShell;
21     switch (message.name) {
22       // XXX(nika): Should we try to call this in the parent process instead?
23       case "Browser:Reload":
24         /* First, we'll try to use the session history object to reload so
25          * that framesets are handled properly. If we're in a special
26          * window (such as view-source) that has no session history, fall
27          * back on using the web navigation's reload method.
28          */
29         let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
30         try {
31           if (webNav.sessionHistory) {
32             webNav = webNav.sessionHistory;
33           }
34         } catch (e) {}
36         let reloadFlags = message.data.flags;
37         if (message.data.handlingUserInput) {
38           reloadFlags |= Ci.nsIWebNavigation.LOAD_FLAGS_USER_ACTIVATION;
39         }
41         try {
42           lazy.E10SUtils.wrapHandlingUserInput(
43             this.document.defaultView,
44             message.data.handlingUserInput,
45             () => webNav.reload(reloadFlags)
46           );
47         } catch (e) {}
48         break;
50       case "ForceEncodingDetection":
51         docShell.forceEncodingDetection();
52         break;
53     }
54   }