-
Notifications
You must be signed in to change notification settings - Fork 128
Support extensions.%NAME%.userdisabled
#2333
Comments
I'm not sure about preferences UI for embedded webextensions. This also depends on whether we want users to see page shot in about:addons or not (I don't recall what the decision was there). @andymckay, if we want to allow users to disable page shot (embedded webextension system addon), should we implement that UI using the webextension approach or the bootstrapped addon approach? |
Let's try to avoid writing more XUL and focus on the webExtension approach please. Note that chrome_style for the settings page is landing in 55, sadly a release too late. |
@andymckay sounds good to me! thanks :-) |
If we want to disable the WebExtension entirely when the pref is off (by not calling |
TL;DR: yes, you can shutdown and restart embedded webextensions, but I'm not sure it's safe to do so It turns out that embedded webextensions have an undocumented shutdown method. Here's how you shut down the webextension without shutting down the outer extension (we could do this in a pref listener): const { EmbeddedExtensionManager } = Cu.import("resource://gre/modules/LegacyExtensionsUtils.jsm");
const webext = EmbeddedExtensionManager.getEmbeddedExtensionFor({id: 'pageshot@mozilla.org'});
webext.shutdown(); One problem here is that there's a bit of state that tracks whether the webextension has ever been started. To disable, then re-enable the webextension, we have to manually unset that state. This might be okay, if the addons team thinks these APIs are stable: // re-enabling a shutdown embedded webextension:
// manually unset the 'started' state :-\
webext.started = false;
// retrigger startup
webext.startup(); I've tried toggling the webextension off and back on using these code snippets, and the toolbar button does appear and disappear, and the re-enabled webextension seems to take shots just fine. So, it seems ok in 54 today (currently dev edition). The big question is whether we can trust this code to work in the future. I'll follow up with the addons team to figure this out. |
According to kmaglione, we should create a new instance, rather than restart a webextension that's been shutdown. This is the snippet that should work, but I need to make sure the /* how to safely shutdown the webext */
const { EmbeddedExtensionManager } = Cu.import("resource://gre/modules/LegacyExtensionsUtils.jsm");
const webext = EmbeddedExtensionManager.getEmbeddedExtensionFor({id: 'pageshot@mozilla.org'});
webext.shutdown();
// unlink the old webextension
EmbeddedExtensionManager.untrackEmbeddedExtension(webext);
/* how to safely lazily create a new webextension */
let pageshotAddon;
AddonManager.getAddonById('pageshot@mozilla.org', addon => { pageshotAddon = addon; });
// I dunno about this line, jarfile stuff is outside my comfort zone
const funkyURI = 'jar:' + pageshotAddon.getResourceURI().asciiSpec + '!/';
const resourceURI = Services.io.newURI(funkyURI);
// because the old one was unlinked, this get call spawns a new one,
// but fails if the resourceURI isn't passed in
const newWebext = EmbeddedExtensionManager.getEmbeddedExtensionFor({
id: 'pageshot@mozilla.org',
resourceURI: resourceURI
});
newWebext.startup(); // works |
My approach to building the jar URI seems to be correct, or at least, that same approach is used in some Firefox tests. |
I think |
Hitting some super weird errors. It's surprisingly quite difficult to get the embedding bootstrapped extension to load properly; I've tried doing Anyhow, the code as written seems correct, but there are two recurring, intermittent bugs:
When these two bugs occur, the profile seems to be in an odd state: I can't find bootstrap.js in the debugger (hence, can't debug the error). I don't know if this points to caching problems in the debugger, or some other weirdness. |
@6a68 Pref should go at the bottom of about:preferences#content |
%NAME% is simply whatever we decide to name this thing. Right now it's "pageshot".
#2332 is our high-level disable flag. No one should be messing with that flag (random power-user aside) -- it's entirely there to enable us to roll this out slowly with Shield.
This issue is about implementing the code that allows the user to disable Page Shot. Some details:
extensions.pageshot.userdisabled
but pick a different one if you likeextensions.%NAME%.disabled
#2332)The text was updated successfully, but these errors were encountered: