зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1363567 - 1. Remove addPluginView/removePluginView methods; r=rbarker
Remove the addPluginView and removePluginView methods from GeckoInterface. Instead, move the JNI calls directly to GeckoApp itself. GeckoApp then uses GeckoActivityMonitor to find the current activity, instead of using GeckoAppShell.getGeckoInterface(). MozReview-Commit-ID: 7ym8kuElADV
This commit is contained in:
Родитель
3f65d0de71
Коммит
d0aff50e27
|
@ -91,6 +91,7 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
|||
#include "ANPBase.h"
|
||||
#include "AndroidBridge.h"
|
||||
#include "ClientLayerManager.h"
|
||||
#include "FennecJNIWrappers.h"
|
||||
#include "nsWindow.h"
|
||||
|
||||
static nsPluginInstanceOwner* sFullScreenInstance = nullptr;
|
||||
|
@ -1547,8 +1548,8 @@ bool nsPluginInstanceOwner::AddPluginView(const LayoutDeviceRect& aRect /* = Lay
|
|||
mJavaView = (void*)jni::GetGeckoThreadEnv()->NewGlobalRef((jobject)mJavaView);
|
||||
}
|
||||
|
||||
if (mFullScreen) {
|
||||
java::GeckoAppShell::AddFullScreenPluginView(jni::Object::Ref::From(jobject(mJavaView)));
|
||||
if (mFullScreen && jni::IsFennec()) {
|
||||
java::GeckoApp::AddPluginView(jni::Object::Ref::From(jobject(mJavaView)));
|
||||
sFullScreenInstance = this;
|
||||
}
|
||||
|
||||
|
@ -1560,8 +1561,8 @@ void nsPluginInstanceOwner::RemovePluginView()
|
|||
if (!mInstance || !mJavaView)
|
||||
return;
|
||||
|
||||
if (mFullScreen) {
|
||||
java::GeckoAppShell::RemoveFullScreenPluginView(jni::Object::Ref::From(jobject(mJavaView)));
|
||||
if (mFullScreen && jni::IsFennec()) {
|
||||
java::GeckoApp::RemovePluginView(jni::Object::Ref::From(jobject(mJavaView)));
|
||||
}
|
||||
jni::GetGeckoThreadEnv()->DeleteGlobalRef((jobject)mJavaView);
|
||||
mJavaView = nullptr;
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.mozilla.gecko;
|
|||
import org.mozilla.gecko.AppConstants.Versions;
|
||||
import org.mozilla.gecko.GeckoProfileDirectories.NoMozillaDirectoryException;
|
||||
import org.mozilla.gecko.annotation.RobocopTarget;
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.db.UrlAnnotations;
|
||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||
|
@ -1015,16 +1016,21 @@ public abstract class GeckoApp extends GeckoActivity
|
|||
mFullScreenPluginView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPluginView(final View view) {
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
private static void addPluginView(final View view) {
|
||||
final Activity activity = GeckoActivityMonitor.getInstance().getCurrentActivity();
|
||||
if (!(activity instanceof GeckoApp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final GeckoApp geckoApp = (GeckoApp) activity;
|
||||
if (ThreadUtils.isOnUiThread()) {
|
||||
addFullScreenPluginView(view);
|
||||
geckoApp.addFullScreenPluginView(view);
|
||||
} else {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
addFullScreenPluginView(view);
|
||||
geckoApp.addFullScreenPluginView(view);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1061,15 +1067,21 @@ public abstract class GeckoApp extends GeckoActivity
|
|||
setFullScreen(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePluginView(final View view) {
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
private static void removePluginView(final View view) {
|
||||
final Activity activity = GeckoActivityMonitor.getInstance().getCurrentActivity();
|
||||
if (!(activity instanceof GeckoApp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final GeckoApp geckoApp = (GeckoApp) activity;
|
||||
if (ThreadUtils.isOnUiThread()) {
|
||||
removePluginView(view);
|
||||
geckoApp.removeFullScreenPluginView(view);
|
||||
} else {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
removeFullScreenPluginView(view);
|
||||
geckoApp.removeFullScreenPluginView(view);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -27,14 +27,6 @@ public class BaseGeckoInterface implements GeckoAppShell.GeckoInterface {
|
|||
return eventDispatcher;
|
||||
}
|
||||
|
||||
// Bug 908779: Implement this
|
||||
@Override
|
||||
public void addPluginView(final View view) {}
|
||||
|
||||
// Bug 908781: Implement this
|
||||
@Override
|
||||
public void removePluginView(final View view) {}
|
||||
|
||||
@Override
|
||||
public void enableOrientationListener() {}
|
||||
|
||||
|
|
|
@ -1387,18 +1387,6 @@ public class GeckoAppShell
|
|||
@WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
|
||||
public static native void onFullScreenPluginHidden(View view);
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
private static void addFullScreenPluginView(View view) {
|
||||
if (getGeckoInterface() != null)
|
||||
getGeckoInterface().addPluginView(view);
|
||||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
private static void removeFullScreenPluginView(View view) {
|
||||
if (getGeckoInterface() != null)
|
||||
getGeckoInterface().removePluginView(view);
|
||||
}
|
||||
|
||||
/**
|
||||
* A plugin that wish to be loaded in the WebView must provide this permission
|
||||
* in their AndroidManifest.xml.
|
||||
|
@ -1662,8 +1650,6 @@ public class GeckoAppShell
|
|||
public interface GeckoInterface {
|
||||
public @NonNull EventDispatcher getAppEventDispatcher();
|
||||
|
||||
public void addPluginView(View view);
|
||||
public void removePluginView(final View view);
|
||||
public void enableOrientationListener();
|
||||
public void disableOrientationListener();
|
||||
public void addAppStateListener(AppStateListener listener);
|
||||
|
|
|
@ -105,14 +105,6 @@ constexpr char EventDispatcher::NativeCallbackDelegate::SendSuccess_t::signature
|
|||
const char GeckoAppShell::name[] =
|
||||
"org/mozilla/gecko/GeckoAppShell";
|
||||
|
||||
constexpr char GeckoAppShell::AddFullScreenPluginView_t::name[];
|
||||
constexpr char GeckoAppShell::AddFullScreenPluginView_t::signature[];
|
||||
|
||||
auto GeckoAppShell::AddFullScreenPluginView(mozilla::jni::Object::Param a0) -> void
|
||||
{
|
||||
return mozilla::jni::Method<AddFullScreenPluginView_t>::Call(GeckoAppShell::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::CancelVibrate_t::name[];
|
||||
constexpr char GeckoAppShell::CancelVibrate_t::signature[];
|
||||
|
||||
|
@ -579,14 +571,6 @@ auto GeckoAppShell::PerformHapticFeedback(bool a0) -> void
|
|||
return mozilla::jni::Method<PerformHapticFeedback_t>::Call(GeckoAppShell::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::RemoveFullScreenPluginView_t::name[];
|
||||
constexpr char GeckoAppShell::RemoveFullScreenPluginView_t::signature[];
|
||||
|
||||
auto GeckoAppShell::RemoveFullScreenPluginView(mozilla::jni::Object::Param a0) -> void
|
||||
{
|
||||
return mozilla::jni::Method<RemoveFullScreenPluginView_t>::Call(GeckoAppShell::Context(), nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::ReportJavaCrash_t::name[];
|
||||
constexpr char GeckoAppShell::ReportJavaCrash_t::signature[];
|
||||
|
||||
|
|
|
@ -375,26 +375,6 @@ public:
|
|||
|
||||
class CameraCallback;
|
||||
|
||||
struct AddFullScreenPluginView_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "addFullScreenPluginView";
|
||||
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::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto AddFullScreenPluginView(mozilla::jni::Object::Param) -> void;
|
||||
|
||||
struct CancelVibrate_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef void ReturnType;
|
||||
|
@ -1624,26 +1604,6 @@ public:
|
|||
|
||||
static auto PerformHapticFeedback(bool) -> void;
|
||||
|
||||
struct RemoveFullScreenPluginView_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "removeFullScreenPluginView";
|
||||
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::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto RemoveFullScreenPluginView(mozilla::jni::Object::Param) -> void;
|
||||
|
||||
struct ReportJavaCrash_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef void ReturnType;
|
||||
|
|
|
@ -41,6 +41,25 @@ auto DownloadsIntegration::ScanMedia(mozilla::jni::String::Param a0, mozilla::jn
|
|||
return mozilla::jni::Method<ScanMedia_t>::Call(DownloadsIntegration::Context(), nullptr, a0, a1);
|
||||
}
|
||||
|
||||
const char GeckoApp::name[] =
|
||||
"org/mozilla/gecko/GeckoApp";
|
||||
|
||||
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::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);
|
||||
}
|
||||
|
||||
const char GeckoJavaSampler::name[] =
|
||||
"org/mozilla/gecko/GeckoJavaSampler";
|
||||
|
||||
|
|
|
@ -129,6 +129,59 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class GeckoApp : public mozilla::jni::ObjectBase<GeckoApp>
|
||||
{
|
||||
public:
|
||||
static const char name[];
|
||||
|
||||
explicit GeckoApp(const Context& ctx) : ObjectBase<GeckoApp>(ctx) {}
|
||||
|
||||
struct AddPluginView_t {
|
||||
typedef GeckoApp Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::Object::Param> Args;
|
||||
static constexpr char name[] = "addPluginView";
|
||||
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::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto AddPluginView(mozilla::jni::Object::Param) -> void;
|
||||
|
||||
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[] =
|
||||
"(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::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto RemovePluginView(mozilla::jni::Object::Param) -> void;
|
||||
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::ANY;
|
||||
|
||||
template<class Impl> class Natives;
|
||||
};
|
||||
|
||||
class GeckoJavaSampler : public mozilla::jni::ObjectBase<GeckoJavaSampler>
|
||||
{
|
||||
public:
|
||||
|
|
Загрузка…
Ссылка в новой задаче