Bug 1363567 - 2. Move onFullScreenPluginHidden to GeckoApp; r=rbarker
authorJim Chen <nchen@mozilla.com>
Mon, 15 May 2017 23:11:18 -0400
changeset 406672 8f9d8749eb5ef4d9d156426435c5f17a20b75601
parent 406671 06142f9787e7643cae17dced089d4ebd37ec1bbc
child 406673 49c90446a20fa279a46e6023b550b61383c19bad
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrbarker
bugs1363567
milestone55.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 1363567 - 2. Move onFullScreenPluginHidden to GeckoApp; r=rbarker Move the native call onFullScreenPluginHidden from GeckoAppShell to GeckoApp itself. MozReview-Commit-ID: APhGRBTNl0X
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
widget/android/GeneratedJNINatives.h
widget/android/GeneratedJNIWrappers.cpp
widget/android/GeneratedJNIWrappers.h
widget/android/fennec/FennecJNINatives.h
widget/android/fennec/FennecJNIWrappers.cpp
widget/android/fennec/FennecJNIWrappers.h
widget/android/fennec/GeckoApp.h
widget/android/nsAppShell.cpp
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1082,16 +1082,19 @@ public abstract class GeckoApp extends G
                 @Override
                 public void run() {
                     geckoApp.removeFullScreenPluginView(view);
                 }
             });
         }
     }
 
+    @WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
+    private static native void onFullScreenPluginHidden(View view);
+
     private void showSetImageResult(final boolean success, final int message, final String path) {
         ThreadUtils.postToUiThread(new Runnable() {
             @Override
             public void run() {
                 if (!success) {
                     SnackbarBuilder.builder(GeckoApp.this)
                             .message(message)
                             .duration(Snackbar.LENGTH_LONG)
@@ -2799,17 +2802,17 @@ public abstract class GeckoApp extends G
         }
 
         if (mDoorHangerPopup != null && mDoorHangerPopup.isShowing()) {
             mDoorHangerPopup.dismiss();
             return;
         }
 
         if (mFullScreenPluginView != null) {
-            GeckoAppShell.onFullScreenPluginHidden(mFullScreenPluginView);
+            onFullScreenPluginHidden(mFullScreenPluginView);
             removeFullScreenPluginView(mFullScreenPluginView);
             return;
         }
 
         if (mLayerView != null && mLayerView.isFullScreen()) {
             EventDispatcher.getInstance().dispatch("FullScreen:Exit", null);
             return;
         }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
@@ -1379,19 +1379,16 @@ public class GeckoAppShell
                                        Settings.System.TEXT_SHOW_PASSWORD, 1);
             return (showPassword > 0);
         }
         catch (Exception e) {
             return true;
         }
     }
 
-    @WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
-    public static native void onFullScreenPluginHidden(View view);
-
     /**
      * A plugin that wish to be loaded in the WebView must provide this permission
      * in their AndroidManifest.xml.
      */
     public static final String PLUGIN_ACTION = "android.webkit.PLUGIN";
     public static final String PLUGIN_PERMISSION = "android.webkit.permission.PLUGIN";
 
     private static final String PLUGIN_SYSTEM_LIB = "/system/lib/plugins/";
--- a/widget/android/GeneratedJNINatives.h
+++ b/widget/android/GeneratedJNINatives.h
@@ -81,17 +81,17 @@ const JNINativeMethod EventDispatcher::N
             mozilla::jni::NativeStub<EventDispatcher::NativeCallbackDelegate::SendSuccess_t, Impl>
             ::template Wrap<&Impl::SendSuccess>)
 };
 
 template<class Impl>
 class GeckoAppShell::Natives : public mozilla::jni::NativeImpl<GeckoAppShell, Impl>
 {
 public:
-    static const JNINativeMethod methods[7];
+    static const JNINativeMethod methods[6];
 };
 
 template<class Impl>
 const JNINativeMethod GeckoAppShell::Natives<Impl>::methods[] = {
 
     mozilla::jni::MakeNativeMethod<GeckoAppShell::NotifyObservers_t>(
             mozilla::jni::NativeStub<GeckoAppShell::NotifyObservers_t, Impl>
             ::template Wrap<&Impl::NotifyObservers>),
@@ -99,20 +99,16 @@ const JNINativeMethod GeckoAppShell::Nat
     mozilla::jni::MakeNativeMethod<GeckoAppShell::NotifyAlertListener_t>(
             mozilla::jni::NativeStub<GeckoAppShell::NotifyAlertListener_t, Impl>
             ::template Wrap<&Impl::NotifyAlertListener>),
 
     mozilla::jni::MakeNativeMethod<GeckoAppShell::NotifyUriVisited_t>(
             mozilla::jni::NativeStub<GeckoAppShell::NotifyUriVisited_t, Impl>
             ::template Wrap<&Impl::NotifyUriVisited>),
 
-    mozilla::jni::MakeNativeMethod<GeckoAppShell::OnFullScreenPluginHidden_t>(
-            mozilla::jni::NativeStub<GeckoAppShell::OnFullScreenPluginHidden_t, Impl>
-            ::template Wrap<&Impl::OnFullScreenPluginHidden>),
-
     mozilla::jni::MakeNativeMethod<GeckoAppShell::OnLocationChanged_t>(
             mozilla::jni::NativeStub<GeckoAppShell::OnLocationChanged_t, Impl>
             ::template Wrap<&Impl::OnLocationChanged>),
 
     mozilla::jni::MakeNativeMethod<GeckoAppShell::OnSensorChanged_t>(
             mozilla::jni::NativeStub<GeckoAppShell::OnSensorChanged_t, Impl>
             ::template Wrap<&Impl::OnSensorChanged>),
 
--- a/widget/android/GeneratedJNIWrappers.cpp
+++ b/widget/android/GeneratedJNIWrappers.cpp
@@ -541,19 +541,16 @@ constexpr char GeckoAppShell::NotifyUriV
 constexpr char GeckoAppShell::NotifyWakeLockChanged_t::name[];
 constexpr char GeckoAppShell::NotifyWakeLockChanged_t::signature[];
 
 auto GeckoAppShell::NotifyWakeLockChanged(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> void
 {
     return mozilla::jni::Method<NotifyWakeLockChanged_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1);
 }
 
-constexpr char GeckoAppShell::OnFullScreenPluginHidden_t::name[];
-constexpr char GeckoAppShell::OnFullScreenPluginHidden_t::signature[];
-
 constexpr char GeckoAppShell::OnLocationChanged_t::name[];
 constexpr char GeckoAppShell::OnLocationChanged_t::signature[];
 
 constexpr char GeckoAppShell::OnSensorChanged_t::name[];
 constexpr char GeckoAppShell::OnSensorChanged_t::signature[];
 
 constexpr char GeckoAppShell::OpenUriExternal_t::name[];
 constexpr char GeckoAppShell::OpenUriExternal_t::signature[];
--- a/widget/android/GeneratedJNIWrappers.h
+++ b/widget/android/GeneratedJNIWrappers.h
@@ -1488,34 +1488,16 @@ public:
         static const mozilla::jni::CallingThread callingThread =
                 mozilla::jni::CallingThread::GECKO;
         static const mozilla::jni::DispatchTarget dispatchTarget =
                 mozilla::jni::DispatchTarget::CURRENT;
     };
 
     static auto NotifyWakeLockChanged(mozilla::jni::String::Param, mozilla::jni::String::Param) -> void;
 
-    struct OnFullScreenPluginHidden_t {
-        typedef GeckoAppShell Owner;
-        typedef void ReturnType;
-        typedef void SetterType;
-        typedef mozilla::jni::Args<
-                mozilla::jni::Object::Param> Args;
-        static constexpr char name[] = "onFullScreenPluginHidden";
-        static constexpr char signature[] =
-                "(Landroid/view/View;)V";
-        static const bool isStatic = true;
-        static const mozilla::jni::ExceptionMode exceptionMode =
-                mozilla::jni::ExceptionMode::ABORT;
-        static const mozilla::jni::CallingThread callingThread =
-                mozilla::jni::CallingThread::UI;
-        static const mozilla::jni::DispatchTarget dispatchTarget =
-                mozilla::jni::DispatchTarget::GECKO;
-    };
-
     struct OnLocationChanged_t {
         typedef GeckoAppShell Owner;
         typedef void ReturnType;
         typedef void SetterType;
         typedef mozilla::jni::Args<
                 double,
                 double,
                 double,
--- a/widget/android/fennec/FennecJNINatives.h
+++ b/widget/android/fennec/FennecJNINatives.h
@@ -32,16 +32,31 @@ const JNINativeMethod ANRReporter::Nativ
             ::template Wrap<&Impl::ReleaseNativeStack>),
 
     mozilla::jni::MakeNativeMethod<ANRReporter::RequestNativeStack_t>(
             mozilla::jni::NativeStub<ANRReporter::RequestNativeStack_t, Impl>
             ::template Wrap<&Impl::RequestNativeStack>)
 };
 
 template<class Impl>
+class GeckoApp::Natives : public mozilla::jni::NativeImpl<GeckoApp, Impl>
+{
+public:
+    static const JNINativeMethod methods[1];
+};
+
+template<class Impl>
+const JNINativeMethod GeckoApp::Natives<Impl>::methods[] = {
+
+    mozilla::jni::MakeNativeMethod<GeckoApp::OnFullScreenPluginHidden_t>(
+            mozilla::jni::NativeStub<GeckoApp::OnFullScreenPluginHidden_t, Impl>
+            ::template Wrap<&Impl::OnFullScreenPluginHidden>)
+};
+
+template<class Impl>
 class GeckoJavaSampler::Natives : public mozilla::jni::NativeImpl<GeckoJavaSampler, Impl>
 {
 public:
     static const JNINativeMethod methods[1];
 };
 
 template<class Impl>
 const JNINativeMethod GeckoJavaSampler::Natives<Impl>::methods[] = {
--- a/widget/android/fennec/FennecJNIWrappers.cpp
+++ b/widget/android/fennec/FennecJNIWrappers.cpp
@@ -47,16 +47,19 @@ const char GeckoApp::name[] =
 constexpr char GeckoApp::AddPluginView_t::name[];
 constexpr char GeckoApp::AddPluginView_t::signature[];
 
 auto GeckoApp::AddPluginView(mozilla::jni::Object::Param a0) -> void
 {
     return mozilla::jni::Method<AddPluginView_t>::Call(GeckoApp::Context(), nullptr, a0);
 }
 
+constexpr char GeckoApp::OnFullScreenPluginHidden_t::name[];
+constexpr char GeckoApp::OnFullScreenPluginHidden_t::signature[];
+
 constexpr char GeckoApp::RemovePluginView_t::name[];
 constexpr char GeckoApp::RemovePluginView_t::signature[];
 
 auto GeckoApp::RemovePluginView(mozilla::jni::Object::Param a0) -> void
 {
     return mozilla::jni::Method<RemovePluginView_t>::Call(GeckoApp::Context(), nullptr, a0);
 }
 
--- a/widget/android/fennec/FennecJNIWrappers.h
+++ b/widget/android/fennec/FennecJNIWrappers.h
@@ -151,16 +151,34 @@ public:
         static const mozilla::jni::CallingThread callingThread =
                 mozilla::jni::CallingThread::GECKO;
         static const mozilla::jni::DispatchTarget dispatchTarget =
                 mozilla::jni::DispatchTarget::CURRENT;
     };
 
     static auto AddPluginView(mozilla::jni::Object::Param) -> void;
 
+    struct OnFullScreenPluginHidden_t {
+        typedef GeckoApp Owner;
+        typedef void ReturnType;
+        typedef void SetterType;
+        typedef mozilla::jni::Args<
+                mozilla::jni::Object::Param> Args;
+        static constexpr char name[] = "onFullScreenPluginHidden";
+        static constexpr char signature[] =
+                "(Landroid/view/View;)V";
+        static const bool isStatic = true;
+        static const mozilla::jni::ExceptionMode exceptionMode =
+                mozilla::jni::ExceptionMode::ABORT;
+        static const mozilla::jni::CallingThread callingThread =
+                mozilla::jni::CallingThread::UI;
+        static const mozilla::jni::DispatchTarget dispatchTarget =
+                mozilla::jni::DispatchTarget::GECKO;
+    };
+
     struct RemovePluginView_t {
         typedef GeckoApp Owner;
         typedef void ReturnType;
         typedef void SetterType;
         typedef mozilla::jni::Args<
                 mozilla::jni::Object::Param> Args;
         static constexpr char name[] = "removePluginView";
         static constexpr char signature[] =
new file mode 100644
--- /dev/null
+++ b/widget/android/fennec/GeckoApp.h
@@ -0,0 +1,28 @@
+/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_GeckoApp_h__
+#define mozilla_GeckoApp_h__
+
+#include "FennecJNINatives.h"
+#include "nsPluginInstanceOwner.h"
+
+namespace mozilla {
+
+class GeckoApp final
+    : public java::GeckoApp::Natives<GeckoApp>
+{
+    GeckoApp() = delete;
+
+public:
+    static void OnFullScreenPluginHidden(jni::Object::Param aView)
+    {
+        nsPluginInstanceOwner::ExitFullScreen(aView.Get());
+    }
+};
+
+} // namespace mozilla
+
+#endif // mozilla_GeckoApp_h__
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -65,16 +65,17 @@
 #include "AndroidAlerts.h"
 #include "AndroidUiThread.h"
 #include "ANRReporter.h"
 #include "GeckoBatteryManager.h"
 #include "GeckoNetworkManager.h"
 #include "GeckoProcessManager.h"
 #include "GeckoScreenOrientation.h"
 #include "PrefsHelper.h"
+#include "fennec/GeckoApp.h"
 #include "fennec/MemoryMonitor.h"
 #include "fennec/Telemetry.h"
 #include "fennec/ThumbnailHelper.h"
 
 #ifdef DEBUG_ANDROID_EVENTS
 #define EVLOG(args...)  ALOG(args)
 #else
 #define EVLOG(args...) do { } while (0)
@@ -359,21 +360,16 @@ public:
         if (!aName || !aTopic || !aCookie) {
             return;
         }
 
         AndroidAlerts::NotifyListener(
                 aName->ToString(), aTopic->ToCString().get(),
                 aCookie->ToString().get());
     }
-
-    static void OnFullScreenPluginHidden(jni::Object::Param aView)
-    {
-        nsPluginInstanceOwner::ExitFullScreen(aView.Get());
-    }
 };
 
 nsAppShell::nsAppShell()
     : mSyncRunFinished(*(sAppShellLock = new Mutex("nsAppShell")),
                        "nsAppShell.SyncRun")
     , mSyncRunQuit(false)
 {
     {
@@ -398,16 +394,17 @@ nsAppShell::nsAppShell()
         mozilla::GeckoNetworkManager::Init();
         mozilla::GeckoProcessManager::Init();
         mozilla::GeckoScreenOrientation::Init();
         mozilla::PrefsHelper::Init();
         nsWindow::InitNatives();
 
         if (jni::IsFennec()) {
             mozilla::ANRReporter::Init();
+            mozilla::GeckoApp::Init();
             mozilla::MemoryMonitor::Init();
             mozilla::widget::Telemetry::Init();
             mozilla::ThumbnailHelper::Init();
         }
 
         java::GeckoThread::SetState(java::GeckoThread::State::JNI_READY());
 
         CreateAndroidUiThread();