Bug 1597793 - Use setTabActive in GVE. r=snorp
☠☠ backed out by b1f2823f65c2 ☠ ☠
authorAgi Sferro <agi@sferro.dev>
Sat, 25 Jan 2020 02:17:08 +0000
changeset 511777 d8132aa16234043252741d8c356665460cddf591
parent 511776 79aaf28b5ceaf5375c6dfc429e1002a6b582394c
child 511778 b1f2823f65c21e556230346eea1cf24c47f224da
push id106022
push userasferro@mozilla.com
push dateSat, 25 Jan 2020 04:15:17 +0000
treeherderautoland@d8132aa16234 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1597793
milestone74.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 1597793 - Use setTabActive in GVE. r=snorp Differential Revision: https://phabricator.services.mozilla.com/D60943
mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
--- a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
+++ b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
@@ -489,16 +489,17 @@ public class GeckoViewActivity
 
                 mTabSessionManager.addSession(session);
                 setGeckoViewSession(session);
             } else {
                 session = createSession();
                 session.open(sGeckoRuntime);
                 mTabSessionManager.setCurrentSession(session);
                 mGeckoView.setSession(session);
+                sGeckoRuntime.getWebExtensionController().setTabActive(session, true);
             }
             loadFromIntent(getIntent());
         }
 
         mToolbarView.getLocationView().setCommitListener(mCommitListener);
         mToolbarView.updateTabCount();
     }
 
@@ -644,26 +645,28 @@ public class GeckoViewActivity
         if (session != null) {
             mTabSessionManager.closeSession(session);
         }
 
         session = createSession();
         session.open(sGeckoRuntime);
         mTabSessionManager.setCurrentSession(session);
         mGeckoView.setSession(session);
+        sGeckoRuntime.getWebExtensionController().setTabActive(session, true);
         if (mCurrentUri != null) {
             session.loadUri(mCurrentUri);
         }
     }
 
     @Override
     public void onRestoreInstanceState(Bundle savedInstanceState) {
         super.onRestoreInstanceState(savedInstanceState);
         if(savedInstanceState != null) {
-            mTabSessionManager.setCurrentSession((TabSession)mGeckoView.getSession());
+            mTabSessionManager.setCurrentSession((TabSession) mGeckoView.getSession());
+            sGeckoRuntime.getWebExtensionController().setTabActive(mGeckoView.getSession(), true);
         } else {
             recreateSession();
         }
     }
 
     private void updateDesktopMode(GeckoSession session) {
         session.getSettings().setViewportMode(mDesktopMode
                 ? GeckoSessionSettings.VIEWPORT_MODE_DESKTOP
@@ -833,21 +836,26 @@ public class GeckoViewActivity
         if(nextSession != currentSession) {
             setGeckoViewSession(nextSession);
             mCurrentUri = nextSession.getUri();
             mToolbarView.getLocationView().setText(mCurrentUri);
         }
     }
 
     private void setGeckoViewSession(TabSession session) {
-        mGeckoView.releaseSession();
-        if(!session.isOpen()) {
+        final WebExtensionController controller = sGeckoRuntime.getWebExtensionController();
+        final GeckoSession previousSession = mGeckoView.releaseSession();
+        if (previousSession != null) {
+            controller.setTabActive(previousSession, false);
+        }
+        if (!session.isOpen()) {
             session.open(sGeckoRuntime);
         }
         mGeckoView.setSession(session);
+        controller.setTabActive(session, true);
         mTabSessionManager.setCurrentSession(session);
     }
 
     @Override
     public void onDestroy() {
         if (mKillProcessOnDestroy) {
             android.os.Process.killProcess(android.os.Process.myPid());
         }