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/. */
8 ChromeUtils.defineESModuleGetters(lazy, {
9 PageThumbUtils: "resource://gre/modules/PageThumbUtils.sys.mjs",
12 export class ThumbnailsChild extends JSWindowActorChild {
13 receiveMessage(message) {
14 switch (message.name) {
15 case "Browser:Thumbnail:ContentInfo": {
16 let [width, height] = lazy.PageThumbUtils.getContentSize(
19 return { width, height };
21 case "Browser:Thumbnail:CheckState": {
23 * Remote isSafeForCapture request handler for PageThumbs.
25 return new Promise(resolve =>
26 Services.tm.idleDispatchToMainThread(() => {
28 // If we have no manager, our actor has been destroyed, which
29 // means we can't respond, and trying to touch
30 // `this.contentWindow` or `this.browsingContext` will throw.
31 // The `sendQuery` call in the parent will already have been
32 // rejected when the actor was destroyed, so there's no need to
33 // reject our promise or log an additional error.
37 let result = lazy.PageThumbUtils.shouldStoreContentThumbnail(
39 this.browsingContext.docShell
45 case "Browser:Thumbnail:GetOriginalURL": {
47 * Remote GetOriginalURL request handler for PageThumbs.
49 let channel = this.browsingContext.docShell.currentDocumentChannel;
50 let channelError = lazy.PageThumbUtils.isChannelErrorResponse(channel);
53 originalURL = channel.originalURI.spec;
55 return { channelError, originalURL };