mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-26 02:17:34 +09:00
Revert "Issue #756 - Remove contextual identity from BackgroundPageThumbs.jsm"
This reverts commit fbd9f1fcd4.
This commit is contained in:
parent
a10f2e94ad
commit
f097325b98
1 changed files with 39 additions and 1 deletions
|
|
@ -15,6 +15,8 @@ const TELEMETRY_HISTOGRAM_ID_PREFIX = "FX_THUMBNAILS_BG_";
|
||||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
||||||
|
|
||||||
|
const ABOUT_NEWTAB_SEGREGATION_PREF = "privacy.usercontext.about_newtab_segregation.enabled";
|
||||||
|
|
||||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
||||||
|
|
@ -35,6 +37,8 @@ XPCOMUtils.defineConstant(this, "TEL_CAPTURE_DONE_TIMEOUT", TEL_CAPTURE_DONE_TIM
|
||||||
XPCOMUtils.defineConstant(this, "TEL_CAPTURE_DONE_CRASHED", TEL_CAPTURE_DONE_CRASHED);
|
XPCOMUtils.defineConstant(this, "TEL_CAPTURE_DONE_CRASHED", TEL_CAPTURE_DONE_CRASHED);
|
||||||
XPCOMUtils.defineConstant(this, "TEL_CAPTURE_DONE_BAD_URI", TEL_CAPTURE_DONE_BAD_URI);
|
XPCOMUtils.defineConstant(this, "TEL_CAPTURE_DONE_BAD_URI", TEL_CAPTURE_DONE_BAD_URI);
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
|
||||||
|
"resource://gre/modules/ContextualIdentityService.jsm");
|
||||||
const global = this;
|
const global = this;
|
||||||
|
|
||||||
// contains base64 version of a placeholder thumbnail
|
// contains base64 version of a placeholder thumbnail
|
||||||
|
|
@ -134,6 +138,14 @@ const BackgroundPageThumbs = {
|
||||||
return url;
|
return url;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the service that the thumbnail browser should be recreated at next
|
||||||
|
* call of _ensureBrowser().
|
||||||
|
*/
|
||||||
|
renewThumbnailBrowser: function() {
|
||||||
|
this._renewThumbBrowser = true;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that initialization of the thumbnail browser's parent window has
|
* Ensures that initialization of the thumbnail browser's parent window has
|
||||||
* begun.
|
* begun.
|
||||||
|
|
@ -189,9 +201,12 @@ const BackgroundPageThumbs = {
|
||||||
* Creates the thumbnail browser if it doesn't already exist.
|
* Creates the thumbnail browser if it doesn't already exist.
|
||||||
*/
|
*/
|
||||||
_ensureBrowser: function () {
|
_ensureBrowser: function () {
|
||||||
if (this._thumbBrowser)
|
if (this._thumbBrowser && !this._renewThumbBrowser)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
this._destroyBrowser();
|
||||||
|
this._renewThumbBrowser = false;
|
||||||
|
|
||||||
let browser = this._parentWin.document.createElementNS(XUL_NS, "browser");
|
let browser = this._parentWin.document.createElementNS(XUL_NS, "browser");
|
||||||
browser.setAttribute("type", "content");
|
browser.setAttribute("type", "content");
|
||||||
browser.setAttribute("disableglobalhistory", "true");
|
browser.setAttribute("disableglobalhistory", "true");
|
||||||
|
|
@ -201,6 +216,13 @@ const BackgroundPageThumbs = {
|
||||||
browser.setAttribute("remote", "true");
|
browser.setAttribute("remote", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Services.prefs.getBoolPref(ABOUT_NEWTAB_SEGREGATION_PREF)) {
|
||||||
|
// Use the private container for thumbnails.
|
||||||
|
let privateIdentity =
|
||||||
|
ContextualIdentityService.getPrivateIdentity("userContextIdInternal.thumbnail");
|
||||||
|
browser.setAttribute("usercontextid", privateIdentity.userContextId);
|
||||||
|
}
|
||||||
|
|
||||||
// Size the browser. Make its aspect ratio the same as the canvases' that
|
// Size the browser. Make its aspect ratio the same as the canvases' that
|
||||||
// the thumbnails are drawn into; the canvases' aspect ratio is the same as
|
// the thumbnails are drawn into; the canvases' aspect ratio is the same as
|
||||||
// the screen's, so use that. Aim for a size in the ballpark of 1024x768.
|
// the screen's, so use that. Aim for a size in the ballpark of 1024x768.
|
||||||
|
|
@ -303,6 +325,14 @@ const BackgroundPageThumbs = {
|
||||||
_destroyBrowserTimeout: DESTROY_BROWSER_TIMEOUT,
|
_destroyBrowserTimeout: DESTROY_BROWSER_TIMEOUT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Services.prefs.addObserver(ABOUT_NEWTAB_SEGREGATION_PREF,
|
||||||
|
function(aSubject, aTopic, aData) {
|
||||||
|
if (aTopic == "nsPref:changed" && aData == ABOUT_NEWTAB_SEGREGATION_PREF) {
|
||||||
|
BackgroundPageThumbs.renewThumbnailBrowser();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
false);
|
||||||
|
|
||||||
Object.defineProperty(this, "BackgroundPageThumbs", {
|
Object.defineProperty(this, "BackgroundPageThumbs", {
|
||||||
value: BackgroundPageThumbs,
|
value: BackgroundPageThumbs,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
|
|
@ -437,6 +467,14 @@ Capture.prototype = {
|
||||||
Cu.reportError(err);
|
Cu.reportError(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Services.prefs.getBoolPref(ABOUT_NEWTAB_SEGREGATION_PREF)) {
|
||||||
|
// Clear the data in the private container for thumbnails.
|
||||||
|
let privateIdentity =
|
||||||
|
ContextualIdentityService.getPrivateIdentity("userContextIdInternal.thumbnail");
|
||||||
|
Services.obs.notifyObservers(null, "clear-origin-attributes-data",
|
||||||
|
JSON.stringify({ userContextId: privateIdentity.userContextId }));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue