2018-07-30 08:25:48 +03:00
|
|
|
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
2022-06-07 07:29:48 +03:00
|
|
|
const lazy = {};
|
|
|
|
|
2023-05-10 23:00:58 +03:00
|
|
|
ChromeUtils.defineESModuleGetters(lazy, {
|
|
|
|
PageThumbUtils: "resource://gre/modules/PageThumbUtils.sys.mjs",
|
|
|
|
});
|
2018-07-30 08:25:48 +03:00
|
|
|
|
2023-03-16 15:50:27 +03:00
|
|
|
export class ThumbnailsChild extends JSWindowActorChild {
|
2018-07-30 08:25:48 +03:00
|
|
|
receiveMessage(message) {
|
2019-11-07 02:32:35 +03:00
|
|
|
switch (message.name) {
|
2020-07-28 15:52:25 +03:00
|
|
|
case "Browser:Thumbnail:ContentInfo": {
|
2022-06-07 07:29:48 +03:00
|
|
|
let [width, height] = lazy.PageThumbUtils.getContentSize(
|
|
|
|
this.contentWindow
|
|
|
|
);
|
2020-07-28 15:52:25 +03:00
|
|
|
return { width, height };
|
2018-07-30 08:25:48 +03:00
|
|
|
}
|
2019-11-07 02:32:35 +03:00
|
|
|
case "Browser:Thumbnail:CheckState": {
|
|
|
|
/**
|
|
|
|
* Remote isSafeForCapture request handler for PageThumbs.
|
|
|
|
*/
|
|
|
|
return new Promise(resolve =>
|
|
|
|
Services.tm.idleDispatchToMainThread(() => {
|
2020-10-16 22:57:36 +03:00
|
|
|
if (!this.manager) {
|
|
|
|
// If we have no manager, our actor has been destroyed, which
|
|
|
|
// means we can't respond, and trying to touch
|
|
|
|
// `this.contentWindow` or `this.browsingContext` will throw.
|
|
|
|
// The `sendQuery` call in the parent will already have been
|
|
|
|
// rejected when the actor was destroyed, so there's no need to
|
|
|
|
// reject our promise or log an additional error.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-06-07 07:29:48 +03:00
|
|
|
let result = lazy.PageThumbUtils.shouldStoreContentThumbnail(
|
2019-11-07 02:32:35 +03:00
|
|
|
this.contentWindow,
|
|
|
|
this.browsingContext.docShell
|
|
|
|
);
|
|
|
|
resolve(result);
|
|
|
|
})
|
2018-07-30 08:25:48 +03:00
|
|
|
);
|
2019-11-07 02:32:35 +03:00
|
|
|
}
|
|
|
|
case "Browser:Thumbnail:GetOriginalURL": {
|
|
|
|
/**
|
|
|
|
* Remote GetOriginalURL request handler for PageThumbs.
|
|
|
|
*/
|
|
|
|
let channel = this.browsingContext.docShell.currentDocumentChannel;
|
2022-06-07 07:29:48 +03:00
|
|
|
let channelError = lazy.PageThumbUtils.isChannelErrorResponse(channel);
|
2019-11-07 02:32:35 +03:00
|
|
|
let originalURL;
|
|
|
|
try {
|
|
|
|
originalURL = channel.originalURI.spec;
|
|
|
|
} catch (ex) {}
|
|
|
|
return { channelError, originalURL };
|
|
|
|
}
|
2018-07-30 08:25:48 +03:00
|
|
|
}
|
2019-11-07 02:32:35 +03:00
|
|
|
return undefined;
|
2018-07-30 08:25:48 +03:00
|
|
|
}
|
|
|
|
}
|