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/. */
7 var EXPORTED_SYMBOLS = ["ThumbnailsChild"];
11 ChromeUtils.defineModuleGetter(
14 "resource://gre/modules/PageThumbUtils.jsm"
17 class ThumbnailsChild extends JSWindowActorChild {
18 receiveMessage(message) {
19 switch (message.name) {
20 case "Browser:Thumbnail:ContentInfo": {
21 let [width, height] = lazy.PageThumbUtils.getContentSize(
24 return { width, height };
26 case "Browser:Thumbnail:CheckState": {
28 * Remote isSafeForCapture request handler for PageThumbs.
30 return new Promise(resolve =>
31 Services.tm.idleDispatchToMainThread(() => {
33 // If we have no manager, our actor has been destroyed, which
34 // means we can't respond, and trying to touch
35 // `this.contentWindow` or `this.browsingContext` will throw.
36 // The `sendQuery` call in the parent will already have been
37 // rejected when the actor was destroyed, so there's no need to
38 // reject our promise or log an additional error.
42 let result = lazy.PageThumbUtils.shouldStoreContentThumbnail(
44 this.browsingContext.docShell
50 case "Browser:Thumbnail:GetOriginalURL": {
52 * Remote GetOriginalURL request handler for PageThumbs.
54 let channel = this.browsingContext.docShell.currentDocumentChannel;
55 let channelError = lazy.PageThumbUtils.isChannelErrorResponse(channel);
58 originalURL = channel.originalURI.spec;
60 return { channelError, originalURL };