Bug 1565410 - Don't expose BundleEventListener in the API. r=esawin
authorAgi Sferro <agi@sferro.dev>
Wed, 17 Jul 2019 15:48:58 +0000
changeset 483134 a2180268af1d0d8943eb32535b8d3503756eef75
parent 483133 f7ca971deb77848a0543a853d73b44b15d61d9b8
child 483135 799bd24598d335c82a15badb5367d0c1f18401f2
push id113708
push useraciure@mozilla.com
push dateThu, 18 Jul 2019 03:50:35 +0000
treeherdermozilla-inbound@558706e92f7d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1565410
milestone70.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 1565410 - Don't expose BundleEventListener in the API. r=esawin This also updates apilint to 0.2.2 to ensure that future instances of this problem will be caught automatically. Differential Revision: https://phabricator.services.mozilla.com/D37812
build.gradle
mobile/android/geckoview/api.txt
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebExtensionController.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
--- a/build.gradle
+++ b/build.gradle
@@ -78,17 +78,17 @@ buildscript {
 
     if (gradle.mozconfig.substs.MOZ_ANDROID_GOOGLE_PLAY_SERVICES) {
         ext.google_play_services_version = '15.0.1'
         ext.google_play_services_cast_version = '16.0.0'
         ext.google_play_services_fido_version = '17.0.0'
     }
 
     dependencies {
-        classpath 'org.mozilla.apilint:apilint:0.2.1'
+        classpath 'org.mozilla.apilint:apilint:0.2.2'
         classpath 'com.android.tools.build:gradle:3.1.4'
         classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
         classpath 'org.apache.commons:commons-exec:1.3'
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
     }
 }
 
 // A stream that processes bytes line by line, prepending a tag before sending
--- a/mobile/android/geckoview/api.txt
+++ b/mobile/android/geckoview/api.txt
@@ -51,19 +51,16 @@ import java.lang.String;
 import java.lang.Throwable;
 import java.lang.Void;
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.util.AbstractSequentialList;
 import java.util.List;
 import java.util.Map;
 import org.json.JSONObject;
-import org.mozilla.gecko.util.BundleEventListener;
-import org.mozilla.gecko.util.EventCallback;
-import org.mozilla.gecko.util.GeckoBundle;
 import org.mozilla.geckoview.AllowOrDeny;
 import org.mozilla.geckoview.CompositorController;
 import org.mozilla.geckoview.ContentBlocking;
 import org.mozilla.geckoview.DynamicToolbarAnimator;
 import org.mozilla.geckoview.GeckoDisplay;
 import org.mozilla.geckoview.GeckoResponse;
 import org.mozilla.geckoview.GeckoResult;
 import org.mozilla.geckoview.GeckoRuntime;
@@ -1103,17 +1100,17 @@ package org.mozilla.geckoview {
     field @NonNull public final WebExtension.MessageSender sender;
   }
 
   @UiThread public static interface WebExtension.PortDelegate {
     method @NonNull default public void onDisconnect(@NonNull WebExtension.Port);
     method default public void onPortMessage(@NonNull Object, @NonNull WebExtension.Port);
   }
 
-  public class WebExtensionController implements BundleEventListener {
+  public class WebExtensionController {
     ctor protected WebExtensionController(GeckoRuntime, WebExtensionEventDispatcher);
     method @UiThread @Nullable public WebExtensionController.TabDelegate getTabDelegate();
     method @UiThread public void setTabDelegate(@Nullable WebExtensionController.TabDelegate);
   }
 
   public static interface WebExtensionController.TabDelegate {
     method @UiThread @Nullable default public GeckoResult<GeckoSession> onNewTab(@Nullable WebExtension, @Nullable String);
   }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebExtensionController.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebExtensionController.java
@@ -3,17 +3,17 @@ package org.mozilla.geckoview;
 import android.support.annotation.Nullable;
 import android.support.annotation.UiThread;
 
 import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.util.BundleEventListener;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoBundle;
 
-public class WebExtensionController implements BundleEventListener {
+public class WebExtensionController {
     public interface TabDelegate {
         /**
          * Called when tabs.create is invoked, this method returns a *newly-created* session
          * that GeckoView will use to load the requested page on. If the returned value
          * is null the page will not be opened.
          *
          * @param source An instance of {@link WebExtension} or null if extension was not registered
          *               with GeckoRuntime.registerWebextension
@@ -23,35 +23,48 @@ public class WebExtensionController impl
         default GeckoResult<GeckoSession> onNewTab(@Nullable WebExtension source, @Nullable String uri) {
             return null;
         }
     }
 
     private GeckoRuntime mRuntime;
     private WebExtensionEventDispatcher mDispatcher;
     private TabDelegate mTabDelegate;
+    private final EventListener mEventListener;
 
     protected WebExtensionController(final GeckoRuntime runtime, final WebExtensionEventDispatcher dispatcher) {
         mRuntime = runtime;
         mDispatcher = dispatcher;
+        mEventListener = new EventListener();
+    }
+
+    private class EventListener implements BundleEventListener {
+        @Override
+        public void handleMessage(final String event, final GeckoBundle message,
+                                  final EventCallback callback) {
+            if ("GeckoView:WebExtension:NewTab".equals(event)) {
+                newTab(message, callback);
+                return;
+            }
+        }
     }
 
     @UiThread
     public void setTabDelegate(final @Nullable TabDelegate delegate) {
         if (delegate == null) {
             if (mTabDelegate != null) {
                 EventDispatcher.getInstance().unregisterUiThreadListener(
-                        this,
+                        mEventListener,
                         "GeckoView:WebExtension:NewTab"
                 );
             }
         } else {
             if (mTabDelegate == null) {
                 EventDispatcher.getInstance().registerUiThreadListener(
-                        this,
+                        mEventListener,
                         "GeckoView:WebExtension:NewTab"
                 );
             }
         }
         mTabDelegate = delegate;
     }
 
     @UiThread
@@ -84,18 +97,9 @@ public class WebExtensionController impl
                 throw new IllegalArgumentException("Must use an unopened GeckoSession instance");
             }
 
             session.open(mRuntime);
 
             callback.sendSuccess(session.getId());
         });
     }
-
-    @Override
-    public void handleMessage(final String event, final GeckoBundle message,
-                              final EventCallback callback) {
-        if ("GeckoView:WebExtension:NewTab".equals(event)) {
-            newTab(message, callback);
-            return;
-        }
-    }
 }
--- 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
@@ -342,9 +342,9 @@ exclude: true
 [65.23]: ../GeckoSession.FinderResult.html
 
 - Update [`CrashReporter#sendCrashReport`][65.24] to return the crash ID as a
   [`GeckoResult<String>`][65.25].
 
 [65.24]: ../CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
 [65.25]: ../GeckoResult.html
 
-[api-version]: 3d726407275d906a54c1fc86eb92f2c3bfaaa3d0
+[api-version]: 29a6f7c954300f7faaf3073add8a23afbe50197d