Bug 1624410 - Add WebExtension.MetaData.temporary. r=esawin,snorp
☠☠ backed out by e73fdac64254 ☠ ☠
authorAgi Sferro <agi@sferro.dev>
Wed, 23 Sep 2020 17:40:16 +0000
changeset 550046 48126ab6653f9d4ca78ab2be1c8fcba298abce09
parent 550045 a1c555ecb161ec94bf03fe257af849a9f7c55617
child 550047 f949e70af6e7cb0928d9295b472c928b7b7909e3
push id127050
push userasferro@mozilla.com
push dateWed, 23 Sep 2020 17:42:42 +0000
treeherderautoland@48126ab6653f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin, snorp
bugs1624410
milestone83.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1624410 - Add WebExtension.MetaData.temporary. r=esawin,snorp This allows embedders to know when an extension is installed temporarily so that they can allow it even if they would normally do it (e.g. for extensions installed with web-ext). Differential Revision: https://phabricator.services.mozilla.com/D91071
mobile/android/geckoview/api.txt
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebExtension.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
mobile/android/modules/geckoview/GeckoViewWebExtension.jsm
--- a/mobile/android/geckoview/api.txt
+++ b/mobile/android/geckoview/api.txt
@@ -1678,16 +1678,17 @@ package org.mozilla.geckoview {
     field @NonNull public final Image icon;
     field public final boolean isRecommended;
     field @Nullable public final String name;
     field public final boolean openOptionsPageInTab;
     field @Nullable public final String optionsPageUrl;
     field @NonNull public final String[] origins;
     field @NonNull public final String[] permissions;
     field public final int signedState;
+    field public final boolean temporary;
     field @NonNull public final String version;
   }
 
   @UiThread public static class WebExtension.Port {
     ctor protected Port();
     method public void disconnect();
     method public void postMessage(@NonNull JSONObject);
     method public void setDelegate(@Nullable WebExtension.PortDelegate);
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebExtension.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebExtension.java
@@ -1653,16 +1653,22 @@ public class WebExtension {
          */
         public final boolean allowedInPrivateBrowsing;
 
         /**
          * Whether this extension is enabled or not.
          */
         public final boolean enabled;
 
+        /**
+         * Whether this extension is temporary or not. Temporary extensions are not retained
+         * and will be uninstalled when the browser exits.
+         */
+        public final boolean temporary;
+
         /** Override for testing. */
         protected MetaData() {
             icon = null;
             permissions = null;
             origins = null;
             name = null;
             description = null;
             version = null;
@@ -1671,16 +1677,17 @@ public class WebExtension {
             homepageUrl = null;
             optionsPageUrl = null;
             openOptionsPageInTab = false;
             isRecommended = false;
             blocklistState = BlocklistStateFlags.NOT_BLOCKED;
             signedState = SignedStateFlags.UNKNOWN;
             disabledFlags = 0;
             enabled = true;
+            temporary = false;
             baseUrl = null;
             allowedInPrivateBrowsing = false;
         }
 
         /* package */ MetaData(final GeckoBundle bundle) {
             // We only expose permissions that the embedder should prompt for
             permissions = bundle.getStringArray("promptPermissions");
             origins = bundle.getStringArray("origins");
@@ -1690,16 +1697,17 @@ public class WebExtension {
             creatorUrl = bundle.getString("creatorURL");
             homepageUrl = bundle.getString("homepageURL");
             name = bundle.getString("name");
             optionsPageUrl = bundle.getString("optionsPageURL");
             openOptionsPageInTab = bundle.getBoolean("openOptionsPageInTab");
             isRecommended = bundle.getBoolean("isRecommended");
             blocklistState = bundle.getInt("blocklistState", BlocklistStateFlags.NOT_BLOCKED);
             enabled = bundle.getBoolean("enabled", false);
+            temporary = bundle.getBoolean("temporary", false);
             baseUrl = bundle.getString("baseURL");
             allowedInPrivateBrowsing = bundle.getBoolean("privateBrowsingAllowed", false);
 
             int signedState = bundle.getInt("signedState", SignedStateFlags.UNKNOWN);
             if (signedState <= SignedStateFlags.LAST) {
                 this.signedState = signedState;
             } else {
                 Log.e(LOGTAG, "Unrecognized signed state: " + signedState);
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
@@ -13,18 +13,22 @@ exclude: true
 
 ⚠️  breaking change and deprecation notices
 
 ## v83
 - ⚠️  Removing unsupported `MediaSession.Delegate.onPictureInPicture` for now.
   Also, [`MediaSession.Delegate.onMetadata`][83.1] is no longer dispatched for
   plain media elements.
   ([bug 1658937]({{bugzilla}}1658937))
+- Added [`WebExtension.MetaData.temporary`][83.2] which exposes whether an extension
+  has been installed temporarily, e.g. when using web-ext.
+  ([bug 1624410]({{bugzilla}}1624410))
 
 [83.1]: {{javadoc_uri}}/MediaSession.Delegate.html#onMetadata-org.mozilla.geckoview.GeckoSession-org.mozilla.geckoview.MediaSession-org.mozilla.geckoview.MediaSession.Metadata-
+[83.2]: {{javadoc_uri}}/WebExtension.MetaData.html#temporary
 
 ## v82
 - ⚠️  [`WebNotification.source`][79.2] is now `@Nullable` to account for
   WebExtension notifications which don't have a `source` field.
 - ⚠️ Deprecated [`ContentDelegate#onExternalResponse(GeckoSession, WebResponseInfo)`][82.1] with the intention of removing
   them in GeckoView v85. 
   ([bug 1530022]({{bugzilla}}1530022))
 - Added [`ContentDelegate#onExternalResponse(GeckoSession, WebResponse)`][82.2] to eliminate the need
@@ -804,9 +808,9 @@ to allow adding gecko profiler markers.
 [65.19]: {{javadoc_uri}}/GeckoSession.NavigationDelegate.LoadRequest.html#isRedirect
 [65.20]: {{javadoc_uri}}/GeckoSession.html#LOAD_FLAGS_BYPASS_CLASSIFIER
 [65.21]: {{javadoc_uri}}/GeckoSession.ContentDelegate.ContextElement.html
 [65.22]: {{javadoc_uri}}/GeckoSession.ContentDelegate.html#onContextMenu-org.mozilla.geckoview.GeckoSession-int-int-org.mozilla.geckoview.GeckoSession.ContentDelegate.ContextElement-
 [65.23]: {{javadoc_uri}}/GeckoSession.FinderResult.html
 [65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
 [65.25]: {{javadoc_uri}}/GeckoResult.html
 
-[api-version]: 8cbbe3b03d78c33888562ea18a4554cff90f531d
+[api-version]: 01fdaf45cfe4dc5974de314cbdb79584781eb282
--- a/mobile/android/modules/geckoview/GeckoViewWebExtension.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewWebExtension.jsm
@@ -277,16 +277,17 @@ async function exportExtension(aAddon, a
     icons,
     version,
     optionsURL,
     optionsType,
     isRecommended,
     blocklistState,
     userDisabled,
     embedderDisabled,
+    temporarilyInstalled,
     isActive,
     isBuiltin,
     id,
   } = aAddon;
   let creatorName = null;
   let creatorURL = null;
   if (creator) {
     const { name, url } = creator;
@@ -314,16 +315,17 @@ async function exportExtension(aAddon, a
     locationURI: aSourceURI != null ? aSourceURI.spec : "",
     isBuiltIn: isBuiltin,
     webExtensionFlags: exportFlags(policy),
     metaData: {
       origins: aPermissions ? aPermissions.origins : [],
       promptPermissions,
       description,
       enabled: isActive,
+      temporary: temporarilyInstalled,
       disabledFlags,
       version,
       creatorName,
       creatorURL,
       homepageURL,
       name,
       optionsPageURL: optionsURL,
       openOptionsPageInTab,