From 04fb9eaa6a3657910e06ed79894521d21b1fd411 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 20 Feb 2020 12:44:29 -0500 Subject: Issue #1053 - Remove android support from NPAPI --- dom/plugins/base/PluginPRLibrary.cpp | 35 +- dom/plugins/base/android/ANPAudio.cpp | 390 ---------- dom/plugins/base/android/ANPBase.h | 36 - dom/plugins/base/android/ANPEvent.cpp | 31 - dom/plugins/base/android/ANPKeyCodes.h | 152 ---- dom/plugins/base/android/ANPLog.cpp | 26 - dom/plugins/base/android/ANPNativeWindow.cpp | 39 - dom/plugins/base/android/ANPSurface.cpp | 266 ------- dom/plugins/base/android/ANPSystem.cpp | 88 --- dom/plugins/base/android/ANPVideo.cpp | 55 -- dom/plugins/base/android/ANPWindow.cpp | 152 ---- dom/plugins/base/android/android_npapi.h | 1027 -------------------------- dom/plugins/base/android/moz.build | 35 - dom/plugins/base/moz.build | 11 - dom/plugins/base/npfunctions.h | 9 - dom/plugins/base/nsNPAPIPlugin.cpp | 184 +---- dom/plugins/base/nsNPAPIPluginInstance.cpp | 357 +-------- dom/plugins/base/nsNPAPIPluginInstance.h | 127 +--- dom/plugins/base/nsPluginHost.cpp | 70 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 453 +----------- dom/plugins/base/nsPluginInstanceOwner.h | 30 +- dom/plugins/base/nsPluginTags.cpp | 5 - dom/plugins/base/nsPluginsDirUnix.cpp | 10 - dom/plugins/ipc/NPEventAndroid.h | 55 -- dom/plugins/ipc/PluginInstanceChild.cpp | 2 - dom/plugins/ipc/PluginInstanceParent.cpp | 3 - dom/plugins/ipc/PluginMessageUtils.h | 4 +- dom/plugins/ipc/moz.build | 1 - 28 files changed, 14 insertions(+), 3639 deletions(-) delete mode 100644 dom/plugins/base/android/ANPAudio.cpp delete mode 100644 dom/plugins/base/android/ANPBase.h delete mode 100644 dom/plugins/base/android/ANPEvent.cpp delete mode 100644 dom/plugins/base/android/ANPKeyCodes.h delete mode 100644 dom/plugins/base/android/ANPLog.cpp delete mode 100644 dom/plugins/base/android/ANPNativeWindow.cpp delete mode 100644 dom/plugins/base/android/ANPSurface.cpp delete mode 100644 dom/plugins/base/android/ANPSystem.cpp delete mode 100644 dom/plugins/base/android/ANPVideo.cpp delete mode 100644 dom/plugins/base/android/ANPWindow.cpp delete mode 100644 dom/plugins/base/android/android_npapi.h delete mode 100644 dom/plugins/base/android/moz.build delete mode 100644 dom/plugins/ipc/NPEventAndroid.h diff --git a/dom/plugins/base/PluginPRLibrary.cpp b/dom/plugins/base/PluginPRLibrary.cpp index ecc55d455..57c6c57ab 100644 --- a/dom/plugins/base/PluginPRLibrary.cpp +++ b/dom/plugins/base/PluginPRLibrary.cpp @@ -21,43 +21,10 @@ static int gNotOptimized; #define CALLING_CONVENTION_HACK #endif -#ifdef MOZ_WIDGET_ANDROID -#include "AndroidBridge.h" -#include "android_npapi.h" -#include -#undef ALOG -#define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoJavaEnv", ## args) -#endif - using namespace mozilla::layers; namespace mozilla { -#ifdef MOZ_WIDGET_ANDROID -nsresult -PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs, - NPPluginFuncs* pFuncs, NPError* error) -{ - JNIEnv* env = jni::GetEnvForThread(); - - mozilla::AutoLocalJNIFrame jniFrame(env); - - if (mNP_Initialize) { - *error = mNP_Initialize(bFuncs, pFuncs, env); - } else { - NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc) - PR_FindFunctionSymbol(mLibrary, "NP_Initialize"); - if (!pfNP_Initialize) - return NS_ERROR_FAILURE; - *error = pfNP_Initialize(bFuncs, pFuncs, env); - } - - // Save pointers to functions that get called through PluginLibrary itself. - mNPP_New = pFuncs->newp; - mNPP_ClearSiteData = pFuncs->clearsitedata; - mNPP_GetSitesWithData = pFuncs->getsiteswithdata; - return NS_OK; -} -#elif defined(XP_UNIX) && !defined(XP_MACOSX) +#if defined(XP_UNIX) && !defined(XP_MACOSX) nsresult PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) diff --git a/dom/plugins/base/android/ANPAudio.cpp b/dom/plugins/base/android/ANPAudio.cpp deleted file mode 100644 index bc47e8999..000000000 --- a/dom/plugins/base/android/ANPAudio.cpp +++ /dev/null @@ -1,390 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 2; 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/. */ - -#include "base/basictypes.h" -#include "AndroidBridge.h" - -#include -#include -#include - -#include "assert.h" -#include "ANPBase.h" -#include "nsIThread.h" -#include "nsThreadUtils.h" -#include "mozilla/Mutex.h" - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPluginsAudio" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_audio_##name - -/* android.media.AudioTrack */ -struct AudioTrack { - jclass at_class; - jmethodID constructor; - jmethodID flush; - jmethodID pause; - jmethodID play; - jmethodID setvol; - jmethodID stop; - jmethodID write; - jmethodID getpos; - jmethodID getstate; - jmethodID release; -}; - -enum AudioTrackMode { - MODE_STATIC = 0, - MODE_STREAM = 1 -}; - -/* android.media.AudioManager */ -enum AudioManagerStream { - STREAM_VOICE_CALL = 0, - STREAM_SYSTEM = 1, - STREAM_RING = 2, - STREAM_MUSIC = 3, - STREAM_ALARM = 4, - STREAM_NOTIFICATION = 5, - STREAM_DTMF = 8 -}; - -/* android.media.AudioFormat */ -enum AudioFormatChannel { - CHANNEL_OUT_MONO = 4, - CHANNEL_OUT_STEREO = 12 -}; - -enum AudioFormatEncoding { - ENCODING_PCM_16BIT = 2, - ENCODING_PCM_8BIT = 3 -}; - -enum AudioFormatState { - STATE_UNINITIALIZED = 0, - STATE_INITIALIZED = 1, - STATE_NO_STATIC_DATA = 2 -}; - -static struct AudioTrack at; - -static jclass -init_jni_bindings(JNIEnv *jenv) { - jclass jc = - (jclass)jenv->NewGlobalRef(jenv->FindClass("android/media/AudioTrack")); - - at.constructor = jenv->GetMethodID(jc, "", "(IIIIII)V"); - at.flush = jenv->GetMethodID(jc, "flush", "()V"); - at.pause = jenv->GetMethodID(jc, "pause", "()V"); - at.play = jenv->GetMethodID(jc, "play", "()V"); - at.setvol = jenv->GetMethodID(jc, "setStereoVolume", "(FF)I"); - at.stop = jenv->GetMethodID(jc, "stop", "()V"); - at.write = jenv->GetMethodID(jc, "write", "([BII)I"); - at.getpos = jenv->GetMethodID(jc, "getPlaybackHeadPosition", "()I"); - at.getstate = jenv->GetMethodID(jc, "getState", "()I"); - at.release = jenv->GetMethodID(jc, "release", "()V"); - - return jc; -} - -struct ANPAudioTrack { - jobject output_unit; - jclass at_class; - - unsigned int rate; - unsigned int channels; - unsigned int bufferSize; - unsigned int isStopped; - unsigned int keepGoing; - - mozilla::Mutex lock; - - void* user; - ANPAudioCallbackProc proc; - ANPSampleFormat format; - - ANPAudioTrack() : lock("ANPAudioTrack") { } -}; - -class AudioRunnable : public mozilla::Runnable -{ -public: - NS_DECL_NSIRUNNABLE - - AudioRunnable(ANPAudioTrack* aAudioTrack) { - mTrack = aAudioTrack; - } - - ANPAudioTrack* mTrack; -}; - -NS_IMETHODIMP -AudioRunnable::Run() -{ - PR_SetCurrentThreadName("Android Audio"); - - JNIEnv* const jenv = mozilla::jni::GetEnvForThread(); - - mozilla::AutoLocalJNIFrame autoFrame(jenv, 2); - - jbyteArray bytearray = jenv->NewByteArray(mTrack->bufferSize); - if (!bytearray) { - LOG("AudioRunnable:: Run. Could not create bytearray"); - return NS_ERROR_FAILURE; - } - - jbyte *byte = jenv->GetByteArrayElements(bytearray, nullptr); - if (!byte) { - LOG("AudioRunnable:: Run. Could not create bytearray"); - return NS_ERROR_FAILURE; - } - - ANPAudioBuffer buffer; - buffer.channelCount = mTrack->channels; - buffer.format = mTrack->format; - buffer.bufferData = (void*) byte; - - while (true) - { - // reset the buffer size - buffer.size = mTrack->bufferSize; - - { - mozilla::MutexAutoLock lock(mTrack->lock); - - if (!mTrack->keepGoing) - break; - - // Get data from the plugin - mTrack->proc(kMoreData_ANPAudioEvent, mTrack->user, &buffer); - } - - if (buffer.size == 0) { - LOG("%p - kMoreData_ANPAudioEvent", mTrack); - continue; - } - - size_t wroteSoFar = 0; - jint retval; - do { - retval = jenv->CallIntMethod(mTrack->output_unit, - at.write, - bytearray, - wroteSoFar, - buffer.size - wroteSoFar); - if (retval < 0) { - LOG("%p - Write failed %d", mTrack, retval); - break; - } - - wroteSoFar += retval; - - } while(wroteSoFar < buffer.size); - } - - jenv->CallVoidMethod(mTrack->output_unit, at.release); - - jenv->DeleteGlobalRef(mTrack->output_unit); - jenv->DeleteGlobalRef(mTrack->at_class); - - delete mTrack; - - jenv->ReleaseByteArrayElements(bytearray, byte, 0); - - return NS_OK; -} - -ANPAudioTrack* -anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz - ANPSampleFormat format, - int channelCount, // MONO=1, STEREO=2 - ANPAudioCallbackProc proc, - void* user) -{ - ANPAudioTrack *s = new ANPAudioTrack(); - if (s == nullptr) { - return nullptr; - } - - JNIEnv* const jenv = mozilla::jni::GetEnvForThread(); - - s->at_class = init_jni_bindings(jenv); - s->rate = sampleRate; - s->channels = channelCount; - s->bufferSize = s->rate * s->channels; - s->isStopped = true; - s->keepGoing = false; - s->user = user; - s->proc = proc; - s->format = format; - - int jformat; - switch (format) { - case kPCM16Bit_ANPSampleFormat: - jformat = ENCODING_PCM_16BIT; - break; - case kPCM8Bit_ANPSampleFormat: - jformat = ENCODING_PCM_8BIT; - break; - default: - LOG("Unknown audio format. defaulting to 16bit."); - jformat = ENCODING_PCM_16BIT; - break; - } - - int jChannels; - switch (channelCount) { - case 1: - jChannels = CHANNEL_OUT_MONO; - break; - case 2: - jChannels = CHANNEL_OUT_STEREO; - break; - default: - LOG("Unknown channel count. defaulting to mono."); - jChannels = CHANNEL_OUT_MONO; - break; - } - - mozilla::AutoLocalJNIFrame autoFrame(jenv); - - jobject obj = jenv->NewObject(s->at_class, - at.constructor, - STREAM_MUSIC, - s->rate, - jChannels, - jformat, - s->bufferSize, - MODE_STREAM); - - if (autoFrame.CheckForException() || obj == nullptr) { - jenv->DeleteGlobalRef(s->at_class); - delete s; - return nullptr; - } - - jint state = jenv->CallIntMethod(obj, at.getstate); - - if (autoFrame.CheckForException() || state == STATE_UNINITIALIZED) { - jenv->DeleteGlobalRef(s->at_class); - delete s; - return nullptr; - } - - s->output_unit = jenv->NewGlobalRef(obj); - return s; -} - -void -anp_audio_deleteTrack(ANPAudioTrack* s) -{ - if (s == nullptr) { - return; - } - - mozilla::MutexAutoLock lock(s->lock); - s->keepGoing = false; - - // deallocation happens in the AudioThread. There is a - // potential leak if anp_audio_start is never called, but - // we do not see that from flash. -} - -void -anp_audio_start(ANPAudioTrack* s) -{ - if (s == nullptr || s->output_unit == nullptr) { - return; - } - - if (s->keepGoing) { - // we are already playing. Ignore. - return; - } - - JNIEnv* const jenv = mozilla::jni::GetEnvForThread(); - - mozilla::AutoLocalJNIFrame autoFrame(jenv, 0); - jenv->CallVoidMethod(s->output_unit, at.play); - - if (autoFrame.CheckForException()) { - jenv->DeleteGlobalRef(s->at_class); - delete s; - return; - } - - s->isStopped = false; - s->keepGoing = true; - - // AudioRunnable now owns the ANPAudioTrack - RefPtr runnable = new AudioRunnable(s); - - nsCOMPtr thread; - NS_NewThread(getter_AddRefs(thread), runnable); -} - -void -anp_audio_pause(ANPAudioTrack* s) -{ - if (s == nullptr || s->output_unit == nullptr) { - return; - } - - JNIEnv* const jenv = mozilla::jni::GetEnvForThread(); - - mozilla::AutoLocalJNIFrame autoFrame(jenv, 0); - jenv->CallVoidMethod(s->output_unit, at.pause); -} - -void -anp_audio_stop(ANPAudioTrack* s) -{ - if (s == nullptr || s->output_unit == nullptr) { - return; - } - - s->isStopped = true; - JNIEnv* const jenv = mozilla::jni::GetEnvForThread(); - - mozilla::AutoLocalJNIFrame autoFrame(jenv, 0); - jenv->CallVoidMethod(s->output_unit, at.stop); -} - -bool -anp_audio_isStopped(ANPAudioTrack* s) -{ - return s->isStopped; -} - -uint32_t -anp_audio_trackLatency(ANPAudioTrack* s) { - // Hardcode an estimate of the system's audio latency. Flash hardcodes - // similar latency estimates for pre-Honeycomb devices that do not support - // ANPAudioTrackInterfaceV1's trackLatency(). The Android stock browser - // calls android::AudioTrack::latency(), an internal Android API that is - // not available in the public NDK: - // https://github.com/android/platform_external_webkit/commit/49bf866973cb3b2a6c74c0eab864e9562e4cbab1 - return 100; // milliseconds -} - -void InitAudioTrackInterfaceV0(ANPAudioTrackInterfaceV0 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, newTrack); - ASSIGN(i, deleteTrack); - ASSIGN(i, start); - ASSIGN(i, pause); - ASSIGN(i, stop); - ASSIGN(i, isStopped); -} - -void InitAudioTrackInterfaceV1(ANPAudioTrackInterfaceV1 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, newTrack); - ASSIGN(i, deleteTrack); - ASSIGN(i, start); - ASSIGN(i, pause); - ASSIGN(i, stop); - ASSIGN(i, isStopped); - ASSIGN(i, trackLatency); -} diff --git a/dom/plugins/base/android/ANPBase.h b/dom/plugins/base/android/ANPBase.h deleted file mode 100644 index f9712dc79..000000000 --- a/dom/plugins/base/android/ANPBase.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#include -#include "android_npapi.h" -#include "nsISupportsImpl.h" - -#define NOT_IMPLEMENTED_FATAL() do { \ - __android_log_print(ANDROID_LOG_ERROR, "GeckoPlugins", \ - "%s not implemented %s, %d", \ - __PRETTY_FUNCTION__, __FILE__, __LINE__); \ - abort(); \ - } while(0) - -#define NOT_IMPLEMENTED() \ - __android_log_print(ANDROID_LOG_ERROR, "GeckoPlugins", \ - "!!!!!!!!!!!!!! %s not implemented %s, %d", \ - __PRETTY_FUNCTION__, __FILE__, __LINE__); \ - -void InitAudioTrackInterfaceV0(ANPAudioTrackInterfaceV0 *i); -void InitAudioTrackInterfaceV1(ANPAudioTrackInterfaceV1* i); -void InitCanvasInterface(ANPCanvasInterfaceV0 *i); -void InitEventInterface(ANPEventInterfaceV0 *i); -void InitLogInterface(ANPLogInterfaceV0 *i); -void InitPaintInterface(ANPPaintInterfaceV0 *i); -void InitSurfaceInterface(ANPSurfaceInterfaceV0 *i); -void InitSystemInterfaceV1(ANPSystemInterfaceV1 *i); -void InitSystemInterfaceV2(ANPSystemInterfaceV2 *i); -void InitTypeFaceInterface(ANPTypefaceInterfaceV0 *i); -void InitWindowInterface(ANPWindowInterfaceV0 *i); -void InitWindowInterfaceV2(ANPWindowInterfaceV2 *i); -void InitVideoInterfaceV1(ANPVideoInterfaceV1 *i); -void InitOpenGLInterface(ANPOpenGLInterfaceV0 *i); -void InitNativeWindowInterface(ANPNativeWindowInterfaceV0 *i); diff --git a/dom/plugins/base/android/ANPEvent.cpp b/dom/plugins/base/android/ANPEvent.cpp deleted file mode 100644 index cac8c94f0..000000000 --- a/dom/plugins/base/android/ANPEvent.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#include "assert.h" -#include "ANPBase.h" -#include -#include "nsThreadUtils.h" -#include "nsNPAPIPluginInstance.h" -#include "nsNPAPIPlugin.h" - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_event_##name - -void -anp_event_postEvent(NPP instance, const ANPEvent* event) -{ - LOG("%s", __PRETTY_FUNCTION__); - - nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); - pinst->PostEvent((void*) event); - - LOG("returning from %s", __PRETTY_FUNCTION__); -} - - -void InitEventInterface(ANPEventInterfaceV0 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, postEvent); -} diff --git a/dom/plugins/base/android/ANPKeyCodes.h b/dom/plugins/base/android/ANPKeyCodes.h deleted file mode 100644 index edfe2b95c..000000000 --- a/dom/plugins/base/android/ANPKeyCodes.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ANPKeyCodes_DEFINED -#define ANPKeyCodes_DEFINED - -/* List the key codes that are set to a plugin in the ANPKeyEvent. - - These exactly match the values in android/view/KeyEvent.java and the - corresponding .h file android/keycodes.h. -*/ -enum ANPKeyCodes { - kUnknown_ANPKeyCode = 0, - - kSoftLeft_ANPKeyCode = 1, - kSoftRight_ANPKeyCode = 2, - kHome_ANPKeyCode = 3, - kBack_ANPKeyCode = 4, - kCall_ANPKeyCode = 5, - kEndCall_ANPKeyCode = 6, - k0_ANPKeyCode = 7, - k1_ANPKeyCode = 8, - k2_ANPKeyCode = 9, - k3_ANPKeyCode = 10, - k4_ANPKeyCode = 11, - k5_ANPKeyCode = 12, - k6_ANPKeyCode = 13, - k7_ANPKeyCode = 14, - k8_ANPKeyCode = 15, - k9_ANPKeyCode = 16, - kStar_ANPKeyCode = 17, - kPound_ANPKeyCode = 18, - kDpadUp_ANPKeyCode = 19, - kDpadDown_ANPKeyCode = 20, - kDpadLeft_ANPKeyCode = 21, - kDpadRight_ANPKeyCode = 22, - kDpadCenter_ANPKeyCode = 23, - kVolumeUp_ANPKeyCode = 24, - kVolumeDown_ANPKeyCode = 25, - kPower_ANPKeyCode = 26, - kCamera_ANPKeyCode = 27, - kClear_ANPKeyCode = 28, - kA_ANPKeyCode = 29, - kB_ANPKeyCode = 30, - kC_ANPKeyCode = 31, - kD_ANPKeyCode = 32, - kE_ANPKeyCode = 33, - kF_ANPKeyCode = 34, - kG_ANPKeyCode = 35, - kH_ANPKeyCode = 36, - kI_ANPKeyCode = 37, - kJ_ANPKeyCode = 38, - kK_ANPKeyCode = 39, - kL_ANPKeyCode = 40, - kM_ANPKeyCode = 41, - kN_ANPKeyCode = 42, - kO_ANPKeyCode = 43, - kP_ANPKeyCode = 44, - kQ_ANPKeyCode = 45, - kR_ANPKeyCode = 46, - kS_ANPKeyCode = 47, - kT_ANPKeyCode = 48, - kU_ANPKeyCode = 49, - kV_ANPKeyCode = 50, - kW_ANPKeyCode = 51, - kX_ANPKeyCode = 52, - kY_ANPKeyCode = 53, - kZ_ANPKeyCode = 54, - kComma_ANPKeyCode = 55, - kPeriod_ANPKeyCode = 56, - kAltLeft_ANPKeyCode = 57, - kAltRight_ANPKeyCode = 58, - kShiftLeft_ANPKeyCode = 59, - kShiftRight_ANPKeyCode = 60, - kTab_ANPKeyCode = 61, - kSpace_ANPKeyCode = 62, - kSym_ANPKeyCode = 63, - kExplorer_ANPKeyCode = 64, - kEnvelope_ANPKeyCode = 65, - kNewline_ANPKeyCode = 66, - kDel_ANPKeyCode = 67, - kGrave_ANPKeyCode = 68, - kMinus_ANPKeyCode = 69, - kEquals_ANPKeyCode = 70, - kLeftBracket_ANPKeyCode = 71, - kRightBracket_ANPKeyCode = 72, - kBackslash_ANPKeyCode = 73, - kSemicolon_ANPKeyCode = 74, - kApostrophe_ANPKeyCode = 75, - kSlash_ANPKeyCode = 76, - kAt_ANPKeyCode = 77, - kNum_ANPKeyCode = 78, - kHeadSetHook_ANPKeyCode = 79, - kFocus_ANPKeyCode = 80, - kPlus_ANPKeyCode = 81, - kMenu_ANPKeyCode = 82, - kNotification_ANPKeyCode = 83, - kSearch_ANPKeyCode = 84, - kMediaPlayPause_ANPKeyCode = 85, - kMediaStop_ANPKeyCode = 86, - kMediaNext_ANPKeyCode = 87, - kMediaPrevious_ANPKeyCode = 88, - kMediaRewind_ANPKeyCode = 89, - kMediaFastForward_ANPKeyCode = 90, - kMute_ANPKeyCode = 91, - kPageUp_ANPKeyCode = 92, - kPageDown_ANPKeyCode = 93, - kPictsymbols_ANPKeyCode = 94, - kSwitchCharset_ANPKeyCode = 95, - kButtonA_ANPKeyCode = 96, - kButtonB_ANPKeyCode = 97, - kButtonC_ANPKeyCode = 98, - kButtonX_ANPKeyCode = 99, - kButtonY_ANPKeyCode = 100, - kButtonZ_ANPKeyCode = 101, - kButtonL1_ANPKeyCode = 102, - kButtonR1_ANPKeyCode = 103, - kButtonL2_ANPKeyCode = 104, - kButtonR2_ANPKeyCode = 105, - kButtonThumbL_ANPKeyCode = 106, - kButtonThumbR_ANPKeyCode = 107, - kButtonStart_ANPKeyCode = 108, - kButtonSelect_ANPKeyCode = 109, - kButtonMode_ANPKeyCode = 110, - - // NOTE: If you add a new keycode here you must also add it to several other files. - // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. -}; - -#endif diff --git a/dom/plugins/base/android/ANPLog.cpp b/dom/plugins/base/android/ANPLog.cpp deleted file mode 100644 index 7ce13107b..000000000 --- a/dom/plugins/base/android/ANPLog.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#include "assert.h" -#include "ANPBase.h" -#include - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_log_##name - -void -anp_log_log(ANPLogType type, const char format[], ...) { - - va_list argp; - va_start(argp,format); - __android_log_vprint(type == kError_ANPLogType ? ANDROID_LOG_ERROR : type == kWarning_ANPLogType ? - ANDROID_LOG_WARN : ANDROID_LOG_INFO, "GeckoPluginLog", format, argp); - va_end(argp); -} - -void InitLogInterface(ANPLogInterfaceV0 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, log); -} diff --git a/dom/plugins/base/android/ANPNativeWindow.cpp b/dom/plugins/base/android/ANPNativeWindow.cpp deleted file mode 100644 index 88b43bd4a..000000000 --- a/dom/plugins/base/android/ANPNativeWindow.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -// must include config.h first for webkit to fiddle with new/delete -#include -#include "ANPBase.h" -#include "nsIPluginInstanceOwner.h" -#include "nsPluginInstanceOwner.h" -#include "nsNPAPIPluginInstance.h" -#include "gfxRect.h" - -using namespace mozilla; - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_native_window_##name - -static ANPNativeWindow anp_native_window_acquireNativeWindow(NPP instance) { - nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); - return pinst->AcquireContentWindow(); -} - -static void anp_native_window_invertPluginContent(NPP instance, bool isContentInverted) { - // NativeWindow is TopLeft if uninverted. - gl::OriginPos newOriginPos = gl::OriginPos::TopLeft; - if (isContentInverted) - newOriginPos = gl::OriginPos::BottomLeft; - - nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); - pinst->SetOriginPos(newOriginPos); - pinst->RedrawPlugin(); -} - - -void InitNativeWindowInterface(ANPNativeWindowInterfaceV0* i) { - ASSIGN(i, acquireNativeWindow); - ASSIGN(i, invertPluginContent); -} diff --git a/dom/plugins/base/android/ANPSurface.cpp b/dom/plugins/base/android/ANPSurface.cpp deleted file mode 100644 index b6a699f28..000000000 --- a/dom/plugins/base/android/ANPSurface.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#include -#include -#include "ANPBase.h" - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_surface_##name - -#define CLEAR_EXCEPTION(env) if (env->ExceptionOccurred()) env->ExceptionClear(); - -#define ANDROID_REGION_SIZE 512 - -enum { - PIXEL_FORMAT_RGBA_8888 = 1, - PIXEL_FORMAT_RGB_565 = 4, -}; - -struct SurfaceInfo { - uint32_t w; - uint32_t h; - uint32_t s; - uint32_t usage; - uint32_t format; - unsigned char* bits; - uint32_t reserved[2]; -}; - -typedef struct ARect { - int32_t left; - int32_t top; - int32_t right; - int32_t bottom; -} ARect; - - -// used to cache JNI method and field IDs for Surface Objects -static struct ANPSurfaceInterfaceJavaGlue { - bool initialized; - jmethodID getSurfaceHolder; - jmethodID getSurface; - jfieldID surfacePointer; -} gSurfaceJavaGlue; - -static struct ANPSurfaceFunctions { - bool initialized; - - int (* lock)(void*, SurfaceInfo*, void*); - int (* unlockAndPost)(void*); - - void* (* regionConstructor)(void*); - void (* setRegion)(void*, ARect const&); -} gSurfaceFunctions; - - -static inline void* getSurface(JNIEnv* env, jobject view) { - if (!env || !view) { - return nullptr; - } - - if (!gSurfaceJavaGlue.initialized) { - - jclass surfaceViewClass = env->FindClass("android/view/SurfaceView"); - gSurfaceJavaGlue.getSurfaceHolder = env->GetMethodID(surfaceViewClass, "getHolder", "()Landroid/view/SurfaceHolder;"); - - jclass surfaceHolderClass = env->FindClass("android/view/SurfaceHolder"); - gSurfaceJavaGlue.getSurface = env->GetMethodID(surfaceHolderClass, "getSurface", "()Landroid/view/Surface;"); - - jclass surfaceClass = env->FindClass("android/view/Surface"); - gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass, - "mSurfacePointer", "I"); - - if (!gSurfaceJavaGlue.surfacePointer) { - CLEAR_EXCEPTION(env); - - // It was something else in 2.2. - gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass, - "mSurface", "I"); - - if (!gSurfaceJavaGlue.surfacePointer) { - CLEAR_EXCEPTION(env); - - // And something else in 2.3+ - gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass, - "mNativeSurface", "I"); - - CLEAR_EXCEPTION(env); - } - } - - if (!gSurfaceJavaGlue.surfacePointer) { - LOG("Failed to acquire surface pointer"); - return nullptr; - } - - env->DeleteLocalRef(surfaceClass); - env->DeleteLocalRef(surfaceViewClass); - env->DeleteLocalRef(surfaceHolderClass); - - gSurfaceJavaGlue.initialized = (gSurfaceJavaGlue.surfacePointer != nullptr); - } - - jobject holder = env->CallObjectMethod(view, gSurfaceJavaGlue.getSurfaceHolder); - jobject surface = env->CallObjectMethod(holder, gSurfaceJavaGlue.getSurface); - jint surfacePointer = env->GetIntField(surface, gSurfaceJavaGlue.surfacePointer); - - env->DeleteLocalRef(holder); - env->DeleteLocalRef(surface); - - return (void*)surfacePointer; -} - -static ANPBitmapFormat convertPixelFormat(int32_t format) { - switch (format) { - case PIXEL_FORMAT_RGBA_8888: return kRGBA_8888_ANPBitmapFormat; - case PIXEL_FORMAT_RGB_565: return kRGB_565_ANPBitmapFormat; - default: return kUnknown_ANPBitmapFormat; - } -} - -static int bytesPerPixel(int32_t format) { - switch (format) { - case PIXEL_FORMAT_RGBA_8888: return 4; - case PIXEL_FORMAT_RGB_565: return 2; - default: return -1; - } -} - -static bool init() { - if (gSurfaceFunctions.initialized) - return true; - - void* handle = dlopen("libsurfaceflinger_client.so", RTLD_LAZY); - - if (!handle) { - LOG("Failed to open libsurfaceflinger_client.so"); - return false; - } - - gSurfaceFunctions.lock = (int (*)(void*, SurfaceInfo*, void*))dlsym(handle, "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEPNS_6RegionEb"); - gSurfaceFunctions.unlockAndPost = (int (*)(void*))dlsym(handle, "_ZN7android7Surface13unlockAndPostEv"); - - - if (!gSurfaceFunctions.lock) { - // Stuff changed in 3.0/4.0 - handle = dlopen("libgui.so", RTLD_LAZY); - gSurfaceFunctions.lock = (int (*)(void*, SurfaceInfo*, void*))dlsym(handle, "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEPNS_6RegionE"); - gSurfaceFunctions.unlockAndPost = (int (*)(void*))dlsym(handle, "_ZN7android7Surface13unlockAndPostEv"); - } - - handle = dlopen("libui.so", RTLD_LAZY); - if (!handle) { - LOG("Failed to open libui.so"); - return false; - } - - gSurfaceFunctions.regionConstructor = (void* (*)(void*))dlsym(handle, "_ZN7android6RegionC1Ev"); - gSurfaceFunctions.setRegion = (void (*)(void*, ARect const&))dlsym(handle, "_ZN7android6Region3setERKNS_4RectE"); - - gSurfaceFunctions.initialized = (gSurfaceFunctions.lock && gSurfaceFunctions.unlockAndPost && - gSurfaceFunctions.regionConstructor && gSurfaceFunctions.setRegion); - LOG("Initialized? %d\n", gSurfaceFunctions.initialized); - return gSurfaceFunctions.initialized; -} - -// FIXME: All of this should be changed to use the equivalent things in AndroidBridge, bug 758612 -static bool anp_surface_lock(JNIEnv* env, jobject surfaceView, ANPBitmap* bitmap, ANPRectI* dirtyRect) { - if (!bitmap || !surfaceView) { - return false; - } - - void* surface = getSurface(env, surfaceView); - - if (!bitmap || !surface) { - return false; - } - - if (!init()) { - return false; - } - - void* region = nullptr; - if (dirtyRect) { - region = malloc(ANDROID_REGION_SIZE); - gSurfaceFunctions.regionConstructor(region); - - ARect rect; - rect.left = dirtyRect->left; - rect.top = dirtyRect->top; - rect.right = dirtyRect->right; - rect.bottom = dirtyRect->bottom; - - gSurfaceFunctions.setRegion(region, rect); - } - - SurfaceInfo info; - int err = gSurfaceFunctions.lock(surface, &info, region); - if (err < 0) { - LOG("Failed to lock surface"); - return false; - } - - // the surface may have expanded the dirty region so we must to pass that - // information back to the plugin. - if (dirtyRect) { - ARect* dirtyBounds = (ARect*)region; // The bounds are the first member, so this should work! - - dirtyRect->left = dirtyBounds->left; - dirtyRect->right = dirtyBounds->right; - dirtyRect->top = dirtyBounds->top; - dirtyRect->bottom = dirtyBounds->bottom; - } - - if (region) - free(region); - - int bpr = info.s * bytesPerPixel(info.format); - - bitmap->format = convertPixelFormat(info.format); - bitmap->width = info.w; - bitmap->height = info.h; - bitmap->rowBytes = bpr; - - if (info.w > 0 && info.h > 0) { - bitmap->baseAddr = info.bits; - } else { - bitmap->baseAddr = nullptr; - return false; - } - - return true; -} - -static void anp_surface_unlock(JNIEnv* env, jobject surfaceView) { - if (!surfaceView) { - return; - } - - if (!init()) { - return; - } - - void* surface = getSurface(env, surfaceView); - - if (!surface) { - return; - } - - gSurfaceFunctions.unlockAndPost(surface); -} - -/////////////////////////////////////////////////////////////////////////////// - -void InitSurfaceInterface(ANPSurfaceInterfaceV0* i) { - ASSIGN(i, lock); - ASSIGN(i, unlock); - - // setup the java glue struct - gSurfaceJavaGlue.initialized = false; - - // setup the function struct - gSurfaceFunctions.initialized = false; -} diff --git a/dom/plugins/base/android/ANPSystem.cpp b/dom/plugins/base/android/ANPSystem.cpp deleted file mode 100644 index d5b2a7710..000000000 --- a/dom/plugins/base/android/ANPSystem.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#include "base/basictypes.h" - -#include "ANPBase.h" -#include "GeneratedJNIWrappers.h" -#include "PluginPRLibrary.h" -#include "assert.h" -#include "nsNPAPIPluginInstance.h" -#include "nsNPAPIPlugin.h" - -#include - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_system_##name - -const char* -anp_system_getApplicationDataDirectory(NPP instance) -{ - static const char *dir = nullptr; - static const char *privateDir = nullptr; - - bool isPrivate = false; - - if (!dir) { - dir = getenv("ANDROID_PLUGIN_DATADIR"); - } - - if (!privateDir) { - privateDir = getenv("ANDROID_PLUGIN_DATADIR_PRIVATE"); - } - - if (!instance) { - return dir; - } - - nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); - if (pinst && NS_SUCCEEDED(pinst->IsPrivateBrowsing(&isPrivate)) && isPrivate) { - return privateDir; - } - - return dir; -} - -const char* -anp_system_getApplicationDataDirectory() -{ - return anp_system_getApplicationDataDirectory(nullptr); -} - -jclass anp_system_loadJavaClass(NPP instance, const char* className) -{ - LOG("%s", __PRETTY_FUNCTION__); - - nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); - mozilla::PluginPRLibrary* lib = static_cast(pinst->GetPlugin()->GetLibrary()); - - nsCString libName; - lib->GetLibraryPath(libName); - - return mozilla::java::GeckoAppShell::LoadPluginClass(className, libName).Forget(); -} - -void anp_system_setPowerState(NPP instance, ANPPowerState powerState) -{ - nsNPAPIPluginInstance* pinst = nsNPAPIPluginInstance::GetFromNPP(instance); - - if (pinst) { - pinst->SetWakeLock(powerState == kScreenOn_ANPPowerState); - } -} - -void InitSystemInterfaceV1(ANPSystemInterfaceV1 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, getApplicationDataDirectory); - ASSIGN(i, loadJavaClass); - ASSIGN(i, setPowerState); -} - -void InitSystemInterfaceV2(ANPSystemInterfaceV2 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, getApplicationDataDirectory); - ASSIGN(i, loadJavaClass); - ASSIGN(i, setPowerState); -} diff --git a/dom/plugins/base/android/ANPVideo.cpp b/dom/plugins/base/android/ANPVideo.cpp deleted file mode 100644 index 185ab1194..000000000 --- a/dom/plugins/base/android/ANPVideo.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* 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/. */ - -#include -#include "ANPBase.h" -#include "nsIPluginInstanceOwner.h" -#include "nsPluginInstanceOwner.h" -#include "nsNPAPIPluginInstance.h" -#include "gfxRect.h" - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_video_##name - -using namespace mozilla; - -typedef nsNPAPIPluginInstance::VideoInfo VideoInfo; - -static ANPNativeWindow anp_video_acquireNativeWindow(NPP instance) { - nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); - - return pinst->AcquireVideoWindow(); -} - -static void anp_video_setWindowDimensions(NPP instance, const ANPNativeWindow window, - const ANPRectF* dimensions) { - nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); - - gfxRect rect(dimensions->left, dimensions->top, - dimensions->right - dimensions->left, - dimensions->bottom - dimensions->top); - - pinst->SetVideoDimensions(window, rect); - pinst->RedrawPlugin(); -} - -static void anp_video_releaseNativeWindow(NPP instance, ANPNativeWindow window) { - nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); - pinst->ReleaseVideoWindow(window); - pinst->RedrawPlugin(); -} - -static void anp_video_setFramerateCallback(NPP instance, const ANPNativeWindow window, ANPVideoFrameCallbackProc callback) { - // Bug 722682 - NOT_IMPLEMENTED(); -} - -/////////////////////////////////////////////////////////////////////////////// - -void InitVideoInterfaceV1(ANPVideoInterfaceV1* i) { - ASSIGN(i, acquireNativeWindow); - ASSIGN(i, setWindowDimensions); - ASSIGN(i, releaseNativeWindow); - ASSIGN(i, setFramerateCallback); -} diff --git a/dom/plugins/base/android/ANPWindow.cpp b/dom/plugins/base/android/ANPWindow.cpp deleted file mode 100644 index e9003aff5..000000000 --- a/dom/plugins/base/android/ANPWindow.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#include "base/basictypes.h" -#include "assert.h" -#include "ANPBase.h" -#include -#include "nsNPAPIPluginInstance.h" -#include "nsPluginInstanceOwner.h" -#include "nsWindow.h" -#include "mozilla/dom/ScreenOrientation.h" - -#undef LOG -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#define ASSIGN(obj, name) (obj)->name = anp_window_##name - -using namespace mozilla; -using namespace mozilla::widget; -using namespace mozilla::dom; - -void -anp_window_setVisibleRects(NPP instance, const ANPRectI rects[], int32_t count) -{ - NOT_IMPLEMENTED(); -} - -void -anp_window_clearVisibleRects(NPP instance) -{ - NOT_IMPLEMENTED(); -} - -void -anp_window_showKeyboard(NPP instance, bool value) -{ - InputContext context; - context.mIMEState.mEnabled = value ? IMEState::PLUGIN : IMEState::DISABLED; - context.mIMEState.mOpen = value ? IMEState::OPEN : IMEState::CLOSED; - context.mActionHint.Assign(EmptyString()); - - InputContextAction action; - action.mCause = InputContextAction::CAUSE_UNKNOWN; - action.mFocusChange = InputContextAction::FOCUS_NOT_CHANGED; - - nsWindow* window = nsWindow::TopWindow(); - if (!window) { - LOG("Couldn't get top window?"); - return; - } - - window->SetInputContext(context, action); -} - -void -anp_window_requestFullScreen(NPP instance) -{ - nsNPAPIPluginInstance* inst = static_cast(instance->ndata); - - RefPtr owner = inst->GetOwner(); - if (!owner) { - return; - } - - owner->RequestFullScreen(); -} - -void -anp_window_exitFullScreen(NPP instance) -{ - nsNPAPIPluginInstance* inst = static_cast(instance->ndata); - - RefPtr owner = inst->GetOwner(); - if (!owner) { - return; - } - - owner->ExitFullScreen(); -} - -void -anp_window_requestCenterFitZoom(NPP instance) -{ - NOT_IMPLEMENTED(); -} - -ANPRectI -anp_window_visibleRect(NPP instance) -{ - ANPRectI rect = { 0, 0, 0, 0 }; - - nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); - - nsIntSize currentSize = pinst->CurrentSize(); - rect.left = rect.top = 0; - rect.right = currentSize.width; - rect.bottom = currentSize.height; - - return rect; -} - -void anp_window_requestFullScreenOrientation(NPP instance, ANPScreenOrientation orientation) -{ - short newOrientation; - - // Convert to the ActivityInfo equivalent - switch (orientation) { - case kFixedLandscape_ANPScreenOrientation: - newOrientation = eScreenOrientation_LandscapePrimary; - break; - case kFixedPortrait_ANPScreenOrientation: - newOrientation = eScreenOrientation_PortraitPrimary; - break; - case kLandscape_ANPScreenOrientation: - newOrientation = eScreenOrientation_LandscapePrimary | - eScreenOrientation_LandscapeSecondary; - break; - case kPortrait_ANPScreenOrientation: - newOrientation = eScreenOrientation_PortraitPrimary | - eScreenOrientation_PortraitSecondary; - break; - default: - newOrientation = eScreenOrientation_None; - break; - } - - nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); - pinst->SetFullScreenOrientation(newOrientation); -} - -void InitWindowInterface(ANPWindowInterfaceV0 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, setVisibleRects); - ASSIGN(i, clearVisibleRects); - ASSIGN(i, showKeyboard); - ASSIGN(i, requestFullScreen); - ASSIGN(i, exitFullScreen); - ASSIGN(i, requestCenterFitZoom); -} - -void InitWindowInterfaceV2(ANPWindowInterfaceV2 *i) { - _assert(i->inSize == sizeof(*i)); - ASSIGN(i, setVisibleRects); - ASSIGN(i, clearVisibleRects); - ASSIGN(i, showKeyboard); - ASSIGN(i, requestFullScreen); - ASSIGN(i, exitFullScreen); - ASSIGN(i, requestCenterFitZoom); - ASSIGN(i, visibleRect); - ASSIGN(i, requestFullScreenOrientation); -} diff --git a/dom/plugins/base/android/android_npapi.h b/dom/plugins/base/android/android_npapi.h deleted file mode 100644 index 16463d799..000000000 --- a/dom/plugins/base/android/android_npapi.h +++ /dev/null @@ -1,1027 +0,0 @@ -/* - * Copyright 2009, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* Defines the android-specific types and functions as part of npapi - - In particular, defines the window and event types that are passed to - NPN_GetValue, NPP_SetWindow and NPP_HandleEvent. - - To minimize what native libraries the plugin links against, some - functionality is provided via function-ptrs (e.g. time, sound) - */ - -#ifndef android_npapi_H -#define android_npapi_H - -#include -#include -#include "npapi.h" -#include "GLDefs.h" - -/////////////////////////////////////////////////////////////////////////////// -// General types - -enum ANPBitmapFormats { - kUnknown_ANPBitmapFormat = 0, - kRGBA_8888_ANPBitmapFormat = 1, - kRGB_565_ANPBitmapFormat = 2 -}; -typedef int32_t ANPBitmapFormat; - -struct ANPPixelPacking { - uint8_t AShift; - uint8_t ABits; - uint8_t RShift; - uint8_t RBits; - uint8_t GShift; - uint8_t GBits; - uint8_t BShift; - uint8_t BBits; -}; - -struct ANPBitmap { - void* baseAddr; - ANPBitmapFormat format; - int32_t width; - int32_t height; - int32_t rowBytes; -}; - -struct ANPRectF { - float left; - float top; - float right; - float bottom; -}; - -struct ANPRectI { - int32_t left; - int32_t top; - int32_t right; - int32_t bottom; -}; - -struct ANPCanvas; -struct ANPMatrix; -struct ANPPaint; -struct ANPPath; -struct ANPTypeface; - -/////////////////////////////////////////////////////////////////////////////// -// NPN_GetValue - -/** queries for a specific ANPInterface. - - Maybe called with NULL for the NPP instance - - NPN_GetValue(inst, interface_enum, ANPInterface*) - */ -#define kLogInterfaceV0_ANPGetValue ((NPNVariable)1000) -#define kAudioTrackInterfaceV0_ANPGetValue ((NPNVariable)1001) -#define kCanvasInterfaceV0_ANPGetValue ((NPNVariable)1002) -#define kMatrixInterfaceV0_ANPGetValue ((NPNVariable)1003) -#define kPaintInterfaceV0_ANPGetValue ((NPNVariable)1004) -#define kPathInterfaceV0_ANPGetValue ((NPNVariable)1005) -#define kTypefaceInterfaceV0_ANPGetValue ((NPNVariable)1006) -#define kWindowInterfaceV0_ANPGetValue ((NPNVariable)1007) -#define kBitmapInterfaceV0_ANPGetValue ((NPNVariable)1008) -#define kSurfaceInterfaceV0_ANPGetValue ((NPNVariable)1009) -#define kSystemInterfaceV0_ANPGetValue ((NPNVariable)1010) -#define kEventInterfaceV0_ANPGetValue ((NPNVariable)1011) - -#define kAudioTrackInterfaceV1_ANPGetValue ((NPNVariable)1012) -#define kOpenGLInterfaceV0_ANPGetValue ((NPNVariable)1013) -#define kWindowInterfaceV1_ANPGetValue ((NPNVariable)1014) -#define kVideoInterfaceV0_ANPGetValue ((NPNVariable)1015) -#define kSystemInterfaceV1_ANPGetValue ((NPNVariable)1016) -#define kSystemInterfaceV2_ANPGetValue ((NPNVariable)1017) -#define kWindowInterfaceV2_ANPGetValue ((NPNVariable)1018) -#define kNativeWindowInterfaceV0_ANPGetValue ((NPNVariable)1019) -#define kVideoInterfaceV1_ANPGetValue ((NPNVariable)1020) - -/** queries for the drawing models supported on this device. - - NPN_GetValue(inst, kSupportedDrawingModel_ANPGetValue, uint32_t* bits) - */ -#define kSupportedDrawingModel_ANPGetValue ((NPNVariable)2000) - -/** queries for the context (android.content.Context) of the plugin. If no - instance is specified the application's context is returned. If the instance - is given then the context returned is identical to the context used to - create the webview in which that instance resides. - - NOTE: Holding onto a non-application context after your instance has been - destroyed will cause a memory leak. Refer to the android documentation to - determine what context is best suited for your particular scenario. - - NPN_GetValue(inst, kJavaContext_ANPGetValue, jobject context) - */ -#define kJavaContext_ANPGetValue ((NPNVariable)2001) - -/////////////////////////////////////////////////////////////////////////////// -// NPN_SetValue - -/** Request to set the drawing model. SetValue will return false if the drawing - model is not supported or has insufficient information for configuration. - - NPN_SetValue(inst, kRequestDrawingModel_ANPSetValue, (void*)foo_ANPDrawingModel) - */ -#define kRequestDrawingModel_ANPSetValue ((NPPVariable)1000) - -/** These are used as bitfields in ANPSupportedDrawingModels_EnumValue, - and as-is in ANPRequestDrawingModel_EnumValue. The drawing model determines - how to interpret the ANPDrawingContext provided in the Draw event and how - to interpret the NPWindow->window field. - */ -enum ANPDrawingModels { - /** Draw into a bitmap from the browser thread in response to a Draw event. - NPWindow->window is reserved (ignore) - */ - kBitmap_ANPDrawingModel = 1 << 0, - /** Draw into a surface (e.g. raster, openGL, etc.) using the Java surface - interface. When this model is used the browser will invoke the Java - class specified in the plugin's apk manifest. From that class the browser - will invoke the appropriate method to return an an instance of a android - Java View. The instance is then embedded in the html. The plugin can then - manipulate the view as it would any normal Java View in android. - - Unlike the bitmap model, a surface model is opaque so no html content - behind the plugin will be visible. Unless the plugin needs to be - transparent the surface model should be chosen over the bitmap model as - it will have better performance. - - Further, a plugin can manipulate some surfaces in native code using the - ANPSurfaceInterface. This interface can be used to manipulate Java - objects that extend Surface.class by allowing them to access the - surface's underlying bitmap in native code. For instance, if a raster - surface is used the plugin can lock, draw directly into the bitmap, and - unlock the surface in native code without making JNI calls to the Java - surface object. - */ - kSurface_ANPDrawingModel = 1 << 1, - kOpenGL_ANPDrawingModel = 1 << 2, -}; -typedef int32_t ANPDrawingModel; - -/** Request to receive/disable events. If the pointer is NULL then all flags will - be disabled. Otherwise, the event type will be enabled iff its corresponding - bit in the EventFlags bit field is set. - - NPN_SetValue(inst, ANPAcceptEvents, (void*)EventFlags) - */ -#define kAcceptEvents_ANPSetValue ((NPPVariable)1001) - -/** The EventFlags are a set of bits used to determine which types of events the - plugin wishes to receive. For example, if the value is 0x03 then both key - and touch events will be provided to the plugin. - */ -enum ANPEventFlag { - kKey_ANPEventFlag = 0x01, - kTouch_ANPEventFlag = 0x02, -}; -typedef uint32_t ANPEventFlags; - -/////////////////////////////////////////////////////////////////////////////// -// NPP_GetValue - -/** Requests that the plugin return a java surface to be displayed. This will - only be used if the plugin has choosen the kSurface_ANPDrawingModel. - - NPP_GetValue(inst, kJavaSurface_ANPGetValue, jobject surface) - */ -#define kJavaSurface_ANPGetValue ((NPPVariable)2000) - - -/////////////////////////////////////////////////////////////////////////////// -// ANDROID INTERFACE DEFINITIONS - -/** Interfaces provide additional functionality to the plugin via function ptrs. - Once an interface is retrieved, it is valid for the lifetime of the plugin - (just like browserfuncs). - - All ANPInterfaces begin with an inSize field, which must be set by the - caller (plugin) with the number of bytes allocated for the interface. - e.g. SomeInterface si; si.inSize = sizeof(si); browser->getvalue(..., &si); - */ -struct ANPInterface { - uint32_t inSize; // size (in bytes) of this struct -}; - -enum ANPLogTypes { - kError_ANPLogType = 0, // error - kWarning_ANPLogType = 1, // warning - kDebug_ANPLogType = 2 // debug only (informational) -}; -typedef int32_t ANPLogType; - -struct ANPLogInterfaceV0 : ANPInterface { - /** dumps printf messages to the log file - e.g. interface->log(instance, kWarning_ANPLogType, "value is %d", value); - */ - void (*log)(ANPLogType, const char format[], ...); -}; - -/** ANPColor is always defined to have the same packing on all platforms, and - it is always unpremultiplied. - - This is in contrast to 32bit format(s) in bitmaps, which are premultiplied, - and their packing may vary depending on the platform, hence the need for - ANPBitmapInterface::getPixelPacking() - */ -typedef uint32_t ANPColor; -#define ANPColor_ASHIFT 24 -#define ANPColor_RSHIFT 16 -#define ANPColor_GSHIFT 8 -#define ANPColor_BSHIFT 0 -#define ANP_MAKE_COLOR(a, r, g, b) \ - (((a) << ANPColor_ASHIFT) | \ - ((r) << ANPColor_RSHIFT) | \ - ((g) << ANPColor_GSHIFT) | \ - ((b) << ANPColor_BSHIFT)) - -enum ANPPaintFlag { - kAntiAlias_ANPPaintFlag = 1 << 0, - kFilterBitmap_ANPPaintFlag = 1 << 1, - kDither_ANPPaintFlag = 1 << 2, - kUnderlineText_ANPPaintFlag = 1 << 3, - kStrikeThruText_ANPPaintFlag = 1 << 4, - kFakeBoldText_ANPPaintFlag = 1 << 5, -}; -typedef uint32_t ANPPaintFlags; - -enum ANPPaintStyles { - kFill_ANPPaintStyle = 0, - kStroke_ANPPaintStyle = 1, - kFillAndStroke_ANPPaintStyle = 2 -}; -typedef int32_t ANPPaintStyle; - -enum ANPPaintCaps { - kButt_ANPPaintCap = 0, - kRound_ANPPaintCap = 1, - kSquare_ANPPaintCap = 2 -}; -typedef int32_t ANPPaintCap; - -enum ANPPaintJoins { - kMiter_ANPPaintJoin = 0, - kRound_ANPPaintJoin = 1, - kBevel_ANPPaintJoin = 2 -}; -typedef int32_t ANPPaintJoin; - -enum ANPPaintAligns { - kLeft_ANPPaintAlign = 0, - kCenter_ANPPaintAlign = 1, - kRight_ANPPaintAlign = 2 -}; -typedef int32_t ANPPaintAlign; - -enum ANPTextEncodings { - kUTF8_ANPTextEncoding = 0, - kUTF16_ANPTextEncoding = 1, -}; -typedef int32_t ANPTextEncoding; - -enum ANPTypefaceStyles { - kBold_ANPTypefaceStyle = 1 << 0, - kItalic_ANPTypefaceStyle = 1 << 1 -}; -typedef uint32_t ANPTypefaceStyle; - -typedef uint32_t ANPFontTableTag; - -struct ANPFontMetrics { - /** The greatest distance above the baseline for any glyph (will be <= 0) */ - float fTop; - /** The recommended distance above the baseline (will be <= 0) */ - float fAscent; - /** The recommended distance below the baseline (will be >= 0) */ - float fDescent; - /** The greatest distance below the baseline for any glyph (will be >= 0) */ - float fBottom; - /** The recommended distance to add between lines of text (will be >= 0) */ - float fLeading; -}; - -struct ANPTypefaceInterfaceV0 : ANPInterface { - /** Return a new reference to the typeface that most closely matches the - requested name and style. Pass null as the name to return - the default font for the requested style. Will never return null - - The 5 generic font names "serif", "sans-serif", "monospace", "cursive", - "fantasy" are recognized, and will be mapped to their logical font - automatically by this call. - - @param name May be NULL. The name of the font family. - @param style The style (normal, bold, italic) of the typeface. - @return reference to the closest-matching typeface. Caller must call - unref() when they are done with the typeface. - */ - ANPTypeface* (*createFromName)(const char name[], ANPTypefaceStyle); - - /** Return a new reference to the typeface that most closely matches the - requested typeface and specified Style. Use this call if you want to - pick a new style from the same family of the existing typeface. - If family is NULL, this selects from the default font's family. - - @param family May be NULL. The name of the existing type face. - @param s The style (normal, bold, italic) of the type face. - @return reference to the closest-matching typeface. Call must call - unref() when they are done. - */ - ANPTypeface* (*createFromTypeface)(const ANPTypeface* family, - ANPTypefaceStyle); - - /** Return the owner count of the typeface. A newly created typeface has an - owner count of 1. When the owner count is reaches 0, the typeface is - deleted. - */ - int32_t (*getRefCount)(const ANPTypeface*); - - /** Increment the owner count on the typeface - */ - void (*ref)(ANPTypeface*); - - /** Decrement the owner count on the typeface. When the count goes to 0, - the typeface is deleted. - */ - void (*unref)(ANPTypeface*); - - /** Return the style bits for the specified typeface - */ - ANPTypefaceStyle (*getStyle)(const ANPTypeface*); - - /** Some fonts are stored in files. If that is true for the fontID, then - this returns the byte length of the full file path. If path is not null, - then the full path is copied into path (allocated by the caller), up to - length bytes. If index is not null, then it is set to the truetype - collection index for this font, or 0 if the font is not in a collection. - - Note: getFontPath does not assume that path is a null-terminated string, - so when it succeeds, it only copies the bytes of the file name and - nothing else (i.e. it copies exactly the number of bytes returned by the - function. If the caller wants to treat path[] as a C string, it must be - sure that it is allocated at least 1 byte larger than the returned size, - and it must copy in the terminating 0. - - If the fontID does not correspond to a file, then the function returns - 0, and the path and index parameters are ignored. - - @param fontID The font whose file name is being queried - @param path Either NULL, or storage for receiving up to length bytes - of the font's file name. Allocated by the caller. - @param length The maximum space allocated in path (by the caller). - Ignored if path is NULL. - @param index Either NULL, or receives the TTC index for this font. - If the font is not a TTC, then will be set to 0. - @return The byte length of th font's file name, or 0 if the font is not - baked by a file. - */ - int32_t (*getFontPath)(const ANPTypeface*, char path[], int32_t length, - int32_t* index); - - /** Return a UTF8 encoded path name for the font directory, or NULL if not - supported. If returned, this string address will be valid for the life - of the plugin instance. It will always end with a '/' character. - */ - const char* (*getFontDirectoryPath)(); -}; - -struct ANPPaintInterfaceV0 : ANPInterface { - /** Return a new paint object, which holds all of the color and style - attributes that affect how things (geometry, text, bitmaps) are drawn - in a ANPCanvas. - - The paint that is returned is not tied to any particular plugin - instance, but it must only be accessed from one thread at a time. - */ - ANPPaint* (*newPaint)(); - void (*deletePaint)(ANPPaint*); - - ANPPaintFlags (*getFlags)(const ANPPaint*); - void (*setFlags)(ANPPaint*, ANPPaintFlags); - - ANPColor (*getColor)(const ANPPaint*); - void (*setColor)(ANPPaint*, ANPColor); - - ANPPaintStyle (*getStyle)(const ANPPaint*); - void (*setStyle)(ANPPaint*, ANPPaintStyle); - - float (*getStrokeWidth)(const ANPPaint*); - float (*getStrokeMiter)(const ANPPaint*); - ANPPaintCap (*getStrokeCap)(const ANPPaint*); - ANPPaintJoin (*getStrokeJoin)(const ANPPaint*); - void (*setStrokeWidth)(ANPPaint*, float); - void (*setStrokeMiter)(ANPPaint*, float); - void (*setStrokeCap)(ANPPaint*, ANPPaintCap); - void (*setStrokeJoin)(ANPPaint*, ANPPaintJoin); - - ANPTextEncoding (*getTextEncoding)(const ANPPaint*); - ANPPaintAlign (*getTextAlign)(const ANPPaint*); - float (*getTextSize)(const ANPPaint*); - float (*getTextScaleX)(const ANPPaint*); - float (*getTextSkewX)(const ANPPaint*); - void (*setTextEncoding)(ANPPaint*, ANPTextEncoding); - void (*setTextAlign)(ANPPaint*, ANPPaintAlign); - void (*setTextSize)(ANPPaint*, float); - void (*setTextScaleX)(ANPPaint*, float); - void (*setTextSkewX)(ANPPaint*, float); - - /** Return the typeface ine paint, or null if there is none. This does not - modify the owner count of the returned typeface. - */ - ANPTypeface* (*getTypeface)(const ANPPaint*); - - /** Set the paint's typeface. If the paint already had a non-null typeface, - its owner count is decremented. If the new typeface is non-null, its - owner count is incremented. - */ - void (*setTypeface)(ANPPaint*, ANPTypeface*); - - /** Return the width of the text. If bounds is not null, return the bounds - of the text in that rectangle. - */ - float (*measureText)(ANPPaint*, const void* text, uint32_t byteLength, - ANPRectF* bounds); - - /** Return the number of unichars specifed by the text. - If widths is not null, returns the array of advance widths for each - unichar. - If bounds is not null, returns the array of bounds for each unichar. - */ - int (*getTextWidths)(ANPPaint*, const void* text, uint32_t byteLength, - float widths[], ANPRectF bounds[]); - - /** Return in metrics the spacing values for text, respecting the paint's - typeface and pointsize, and return the spacing between lines - (descent - ascent + leading). If metrics is NULL, it will be ignored. - */ - float (*getFontMetrics)(ANPPaint*, ANPFontMetrics* metrics); -}; - -struct ANPCanvasInterfaceV0 : ANPInterface { - /** Return a canvas that will draw into the specified bitmap. Note: the - canvas copies the fields of the bitmap, so it need not persist after - this call, but the canvas DOES point to the same pixel memory that the - bitmap did, so the canvas should not be used after that pixel memory - goes out of scope. In the case of creating a canvas to draw into the - pixels provided by kDraw_ANPEventType, those pixels are only while - handling that event. - - The canvas that is returned is not tied to any particular plugin - instance, but it must only be accessed from one thread at a time. - */ - ANPCanvas* (*newCanvas)(const ANPBitmap*); - void (*deleteCanvas)(ANPCanvas*); - - void (*save)(ANPCanvas*); - void (*restore)(ANPCanvas*); - void (*translate)(ANPCanvas*, float tx, float ty); - void (*scale)(ANPCanvas*, float sx, float sy); - void (*rotate)(ANPCanvas*, float degrees); - void (*skew)(ANPCanvas*, float kx, float ky); - void (*concat)(ANPCanvas*, const ANPMatrix*); - void (*clipRect)(ANPCanvas*, const ANPRectF*); - void (*clipPath)(ANPCanvas*, const ANPPath*); - - /** Return the current matrix on the canvas - */ - void (*getTotalMatrix)(ANPCanvas*, ANPMatrix*); - /** Return the current clip bounds in local coordinates, expanding it to - account for antialiasing edge effects if aa is true. If the - current clip is empty, return false and ignore the bounds argument. - */ - bool (*getLocalClipBounds)(ANPCanvas*, ANPRectF* bounds, bool aa); - /** Return the current clip bounds in device coordinates in bounds. If the - current clip is empty, return false and ignore the bounds argument. - */ - bool (*getDeviceClipBounds)(ANPCanvas*, ANPRectI* bounds); - - void (*drawColor)(ANPCanvas*, ANPColor); - void (*drawPaint)(ANPCanvas*, const ANPPaint*); - void (*drawLine)(ANPCanvas*, float x0, float y0, float x1, float y1, - const ANPPaint*); - void (*drawRect)(ANPCanvas*, const ANPRectF*, const ANPPaint*); - void (*drawOval)(ANPCanvas*, const ANPRectF*, const ANPPaint*); - void (*drawPath)(ANPCanvas*, const ANPPath*, const ANPPaint*); - void (*drawText)(ANPCanvas*, const void* text, uint32_t byteLength, - float x, float y, const ANPPaint*); - void (*drawPosText)(ANPCanvas*, const void* text, uint32_t byteLength, - const float xy[], const ANPPaint*); - void (*drawBitmap)(ANPCanvas*, const ANPBitmap*, float x, float y, - const ANPPaint*); - void (*drawBitmapRect)(ANPCanvas*, const ANPBitmap*, - const ANPRectI* src, const ANPRectF* dst, - const ANPPaint*); -}; - -struct ANPWindowInterfaceV0 : ANPInterface { - /** Registers a set of rectangles that the plugin would like to keep on - screen. The rectangles are listed in order of priority with the highest - priority rectangle in location rects[0]. The browser will attempt to keep - as many of the rectangles on screen as possible and will scroll them into - view in response to the invocation of this method and other various events. - The count specifies how many rectangles are in the array. If the count is - zero it signals the browser that any existing rectangles should be cleared - and no rectangles will be tracked. - */ - void (*setVisibleRects)(NPP instance, const ANPRectI rects[], int32_t count); - /** Clears any rectangles that are being tracked as a result of a call to - setVisibleRects. This call is equivalent to setVisibleRect(inst, NULL, 0). - */ - void (*clearVisibleRects)(NPP instance); - /** Given a boolean value of true the device will be requested to provide - a keyboard. A value of false will result in a request to hide the - keyboard. Further, the on-screen keyboard will not be displayed if a - physical keyboard is active. - */ - void (*showKeyboard)(NPP instance, bool value); - /** Called when a plugin wishes to enter into full screen mode. The plugin's - Java class (defined in the plugin's apk manifest) will be called - asynchronously to provide a View object to be displayed full screen. - */ - void (*requestFullScreen)(NPP instance); - /** Called when a plugin wishes to exit from full screen mode. As a result, - the plugin's full screen view will be discarded by the view system. - */ - void (*exitFullScreen)(NPP instance); - /** Called when a plugin wishes to be zoomed and centered in the current view. - */ - void (*requestCenterFitZoom)(NPP instance); -}; - -enum ANPScreenOrientations { - /** No preference specified: let the system decide the best orientation. - */ - kDefault_ANPScreenOrientation = 0, - /** Would like to have the screen in a landscape orientation, but it will - not allow for 180 degree rotations. - */ - kFixedLandscape_ANPScreenOrientation = 1, - /** Would like to have the screen in a portrait orientation, but it will - not allow for 180 degree rotations. - */ - kFixedPortrait_ANPScreenOrientation = 2, - /** Would like to have the screen in landscape orientation, but can use the - sensor to change which direction the screen is facing. - */ - kLandscape_ANPScreenOrientation = 3, - /** Would like to have the screen in portrait orientation, but can use the - sensor to change which direction the screen is facing. - */ - kPortrait_ANPScreenOrientation = 4 -}; - -typedef int32_t ANPScreenOrientation; - -struct ANPWindowInterfaceV2 : ANPWindowInterfaceV0 { - /** Returns a rectangle representing the visible area of the plugin on - screen. The coordinates are relative to the size of the plugin in the - document and therefore will never be negative or exceed the plugin's size. - */ - ANPRectI (*visibleRect)(NPP instance); - - /** Called when the plugin wants to specify a particular screen orientation - when entering into full screen mode. The orientation must be set prior - to entering into full screen. After entering full screen any subsequent - changes will be updated the next time the plugin goes full screen. - */ - void (*requestFullScreenOrientation)(NPP instance, ANPScreenOrientation orientation); -}; - -/////////////////////////////////////////////////////////////////////////////// - -enum ANPSampleFormats { - kUnknown_ANPSamleFormat = 0, - kPCM16Bit_ANPSampleFormat = 1, - kPCM8Bit_ANPSampleFormat = 2 -}; -typedef int32_t ANPSampleFormat; - -/** The audio buffer is passed to the callback proc to request more samples. - It is owned by the system, and the callback may read it, but should not - maintain a pointer to it outside of the scope of the callback proc. - */ -struct ANPAudioBuffer { - // RO - repeat what was specified in newTrack() - int32_t channelCount; - // RO - repeat what was specified in newTrack() - ANPSampleFormat format; - /** This buffer is owned by the caller. Inside the callback proc, up to - "size" bytes of sample data should be written into this buffer. The - address is only valid for the scope of a single invocation of the - callback proc. - */ - void* bufferData; - /** On input, specifies the maximum number of bytes that can be written - to "bufferData". On output, specifies the actual number of bytes that - the callback proc wrote into "bufferData". - */ - uint32_t size; -}; - -enum ANPAudioEvents { - /** This event is passed to the callback proc when the audio-track needs - more sample data written to the provided buffer parameter. - */ - kMoreData_ANPAudioEvent = 0, - /** This event is passed to the callback proc if the audio system runs out - of sample data. In this event, no buffer parameter will be specified - (i.e. NULL will be passed to the 3rd parameter). - */ - kUnderRun_ANPAudioEvent = 1 -}; -typedef int32_t ANPAudioEvent; - -/** Called to feed sample data to the track. This will be called in a separate - thread. However, you may call trackStop() from the callback (but you - cannot delete the track). - - For example, when you have written the last chunk of sample data, you can - immediately call trackStop(). This will take effect after the current - buffer has been played. - - The "user" parameter is the same value that was passed to newTrack() - */ -typedef void (*ANPAudioCallbackProc)(ANPAudioEvent event, void* user, - ANPAudioBuffer* buffer); - -struct ANPAudioTrack; // abstract type for audio tracks - -struct ANPAudioTrackInterfaceV0 : ANPInterface { - /** Create a new audio track, or NULL on failure. The track is initially in - the stopped state and therefore ANPAudioCallbackProc will not be called - until the track is started. - */ - ANPAudioTrack* (*newTrack)(uint32_t sampleRate, // sampling rate in Hz - ANPSampleFormat, - int channelCount, // MONO=1, STEREO=2 - ANPAudioCallbackProc, - void* user); - /** Deletes a track that was created using newTrack. The track can be - deleted in any state and it waits for the ANPAudioCallbackProc thread - to exit before returning. - */ - void (*deleteTrack)(ANPAudioTrack*); - - void (*start)(ANPAudioTrack*); - void (*pause)(ANPAudioTrack*); - void (*stop)(ANPAudioTrack*); - /** Returns true if the track is not playing (e.g. pause or stop was called, - or start was never called. - */ - bool (*isStopped)(ANPAudioTrack*); -}; - -struct ANPAudioTrackInterfaceV1 : ANPAudioTrackInterfaceV0 { - /** Returns the track's latency in milliseconds. */ - uint32_t (*trackLatency)(ANPAudioTrack*); -}; - - -/////////////////////////////////////////////////////////////////////////////// -// DEFINITION OF VALUES PASSED THROUGH NPP_HandleEvent - -enum ANPEventTypes { - kNull_ANPEventType = 0, - kKey_ANPEventType = 1, - /** Mouse events are triggered by either clicking with the navigational pad - or by tapping the touchscreen (if the kDown_ANPTouchAction is handled by - the plugin then no mouse event is generated). The kKey_ANPEventFlag has - to be set to true in order to receive these events. - */ - kMouse_ANPEventType = 2, - /** Touch events are generated when the user touches on the screen. The - kTouch_ANPEventFlag has to be set to true in order to receive these - events. - */ - kTouch_ANPEventType = 3, - /** Only triggered by a plugin using the kBitmap_ANPDrawingModel. This event - signals that the plugin needs to redraw itself into the provided bitmap. - */ - kDraw_ANPEventType = 4, - kLifecycle_ANPEventType = 5, - - /** This event type is completely defined by the plugin. - When creating an event, the caller must always set the first - two fields, the remaining data is optional. - ANPEvent evt; - evt.inSize = sizeof(ANPEvent); - evt.eventType = kCustom_ANPEventType - // other data slots are optional - evt.other[] = ...; - To post a copy of the event, call - eventInterface->postEvent(myNPPInstance, &evt); - That call makes a copy of the event struct, and post that on the event - queue for the plugin. - */ - kCustom_ANPEventType = 6, -}; -typedef int32_t ANPEventType; - -enum ANPKeyActions { - kDown_ANPKeyAction = 0, - kUp_ANPKeyAction = 1, -}; -typedef int32_t ANPKeyAction; - -#include "ANPKeyCodes.h" -typedef int32_t ANPKeyCode; - -enum ANPKeyModifiers { - kAlt_ANPKeyModifier = 1 << 0, - kShift_ANPKeyModifier = 1 << 1, -}; -// bit-field containing some number of ANPKeyModifier bits -typedef uint32_t ANPKeyModifier; - -enum ANPMouseActions { - kDown_ANPMouseAction = 0, - kUp_ANPMouseAction = 1, -}; -typedef int32_t ANPMouseAction; - -enum ANPTouchActions { - /** This occurs when the user first touches on the screen. As such, this - action will always occur prior to any of the other touch actions. If - the plugin chooses to not handle this action then no other events - related to that particular touch gesture will be generated. - */ - kDown_ANPTouchAction = 0, - kUp_ANPTouchAction = 1, - kMove_ANPTouchAction = 2, - kCancel_ANPTouchAction = 3, - // The web view will ignore the return value from the following actions - kLongPress_ANPTouchAction = 4, - kDoubleTap_ANPTouchAction = 5, -}; -typedef int32_t ANPTouchAction; - -enum ANPLifecycleActions { - /** The web view containing this plugin has been paused. See documentation - on the android activity lifecycle for more information. - */ - kPause_ANPLifecycleAction = 0, - /** The web view containing this plugin has been resumed. See documentation - on the android activity lifecycle for more information. - */ - kResume_ANPLifecycleAction = 1, - /** The plugin has focus and is now the recipient of input events (e.g. key, - touch, etc.) - */ - kGainFocus_ANPLifecycleAction = 2, - /** The plugin has lost focus and will not receive any input events until it - regains focus. This event is always preceded by a GainFocus action. - */ - kLoseFocus_ANPLifecycleAction = 3, - /** The browser is running low on available memory and is requesting that - the plugin free any unused/inactive resources to prevent a performance - degradation. - */ - kFreeMemory_ANPLifecycleAction = 4, - /** The page has finished loading. This happens when the page's top level - frame reports that it has completed loading. - */ - kOnLoad_ANPLifecycleAction = 5, - /** The browser is honoring the plugin's request to go full screen. Upon - returning from this event the browser will resize the plugin's java - surface to full-screen coordinates. - */ - kEnterFullScreen_ANPLifecycleAction = 6, - /** The browser has exited from full screen mode. Immediately prior to - sending this event the browser has resized the plugin's java surface to - its original coordinates. - */ - kExitFullScreen_ANPLifecycleAction = 7, - /** The plugin is visible to the user on the screen. This event will always - occur after a kOffScreen_ANPLifecycleAction event. - */ - kOnScreen_ANPLifecycleAction = 8, - /** The plugin is no longer visible to the user on the screen. This event - will always occur prior to an kOnScreen_ANPLifecycleAction event. - */ - kOffScreen_ANPLifecycleAction = 9, -}; -typedef uint32_t ANPLifecycleAction; - -/* This is what is passed to NPP_HandleEvent() */ -struct ANPEvent { - uint32_t inSize; // size of this struct in bytes - ANPEventType eventType; - // use based on the value in eventType - union { - struct { - ANPKeyAction action; - ANPKeyCode nativeCode; - int32_t virtualCode; // windows virtual key code - ANPKeyModifier modifiers; - int32_t repeatCount; // 0 for initial down (or up) - int32_t unichar; // 0 if there is no value - } key; - struct { - ANPMouseAction action; - int32_t x; // relative to your "window" (0...width) - int32_t y; // relative to your "window" (0...height) - } mouse; - struct { - ANPTouchAction action; - ANPKeyModifier modifiers; - int32_t x; // relative to your "window" (0...width) - int32_t y; // relative to your "window" (0...height) - } touch; - struct { - ANPLifecycleAction action; - } lifecycle; - struct { - ANPDrawingModel model; - // relative to (0,0) in top-left of your plugin - ANPRectI clip; - // use based on the value in model - union { - ANPBitmap bitmap; - struct { - int32_t width; - int32_t height; - } surfaceSize; - } data; - } draw; - } data; -}; - - -struct ANPEventInterfaceV0 : ANPInterface { - /** Post a copy of the specified event to the plugin. The event will be - delivered to the plugin in its main thread (the thread that receives - other ANPEvents). If, after posting before delivery, the NPP instance - is torn down, the event will be discarded. - */ - void (*postEvent)(NPP inst, const ANPEvent* event); -}; - -struct ANPSurfaceInterfaceV0 : ANPInterface { - /** Locks the surface from manipulation by other threads and provides a bitmap - to be written to. The dirtyRect param specifies which portion of the - bitmap will be written to. If the dirtyRect is NULL then the entire - surface will be considered dirty. If the lock was successful the function - will return true and the bitmap will be set to point to a valid bitmap. - If not the function will return false and the bitmap will be set to NULL. - */ - bool (*lock)(JNIEnv* env, jobject surface, ANPBitmap* bitmap, ANPRectI* dirtyRect); - /** Given a locked surface handle (i.e. result of a successful call to lock) - the surface is unlocked and the contents of the bitmap, specifically - those inside the dirtyRect are written to the screen. - */ - void (*unlock)(JNIEnv* env, jobject surface); -}; - -/** - * TODO should we not use EGL and GL data types for ABI safety? - */ -struct ANPTextureInfo { - GLuint textureId; - uint32_t width; - uint32_t height; - GLenum internalFormat; -}; - -typedef void* ANPEGLContext; - -struct ANPOpenGLInterfaceV0 : ANPInterface { - ANPEGLContext (*acquireContext)(NPP instance); - - ANPTextureInfo (*lockTexture)(NPP instance); - - void (*releaseTexture)(NPP instance, const ANPTextureInfo*); - - /** - * Invert the contents of the plugin on the y-axis. - * default is to not be inverted (i.e. use OpenGL coordinates) - */ - void (*invertPluginContent)(NPP instance, bool isContentInverted); -}; - -enum ANPPowerStates { - kDefault_ANPPowerState = 0, - kScreenOn_ANPPowerState = 1 -}; -typedef int32_t ANPPowerState; - -struct ANPSystemInterfaceV1 : ANPInterface { - /** Return the path name for the current Application's plugin data directory, - or NULL if not supported - */ - const char* (*getApplicationDataDirectory)(); - - /** A helper function to load java classes from the plugin's apk. The - function looks for a class given the fully qualified and null terminated - string representing the className. For example, - - const char* className = "com.android.mypackage.MyClass"; - - If the class cannot be found or there is a problem loading the class - NULL will be returned. - */ - jclass (*loadJavaClass)(NPP instance, const char* className); - - void (*setPowerState)(NPP instance, ANPPowerState powerState); -}; - -struct ANPSystemInterfaceV2 : ANPInterface { - /** Return the path name for the current Application's plugin data directory, - or NULL if not supported. This directory will change depending on whether - or not the plugin is found within an incognito tab. - */ - const char* (*getApplicationDataDirectory)(NPP instance); - - // redeclaration of existing features - jclass (*loadJavaClass)(NPP instance, const char* className); - void (*setPowerState)(NPP instance, ANPPowerState powerState); -}; - -typedef void* ANPNativeWindow; - -/** Called to notify the plugin that a video frame has been composited by the -* browser for display. This will be called in a separate thread and as such -* you cannot call releaseNativeWindow from the callback. -* -* The timestamp is in nanoseconds, and is monotonically increasing. -*/ -typedef void (*ANPVideoFrameCallbackProc)(ANPNativeWindow* window, int64_t timestamp); - -struct ANPVideoInterfaceV1 : ANPInterface { - - /** - * Constructs a new native window to be used for rendering video content. - * - * Subsequent calls will produce new windows, but may also return NULL after - * n attempts if the browser has reached it's limit. Further, if the browser - * is unable to acquire the window quickly it may also return NULL in order - * to not prevent the plugin from executing. A subsequent call will then - * return the window if it is avaiable. - * - * NOTE: The hardware may fail if you try to decode more than the allowable - * number of videos supported on that device. - */ - ANPNativeWindow (*acquireNativeWindow)(NPP instance); - - /** - * Sets the rectangle that specifies where the video content is to be drawn. - * The dimensions are in document space. Further, if the rect is NULL the - * browser will not attempt to draw the window, therefore do not set the - * dimensions until you queue the first buffer in the window. - */ - void (*setWindowDimensions)(NPP instance, const ANPNativeWindow window, const ANPRectF* dimensions); - - /** - */ - void (*releaseNativeWindow)(NPP instance, ANPNativeWindow window); - - /** Set a callback to be notified when an ANPNativeWindow is composited by - * the browser. - */ - void (*setFramerateCallback)(NPP instance, const ANPNativeWindow window, ANPVideoFrameCallbackProc); -}; - -struct ANPNativeWindowInterfaceV0 : ANPInterface { - /** - * Constructs a new native window to be used for rendering plugin content. - * - * Subsequent calls will return the original constructed window. Further, if - * the browser is unable to acquire the window quickly it may return NULL in - * order to not block the plugin indefinitely. A subsequent call will then - * return the window if it is available. - */ - ANPNativeWindow (*acquireNativeWindow)(NPP instance); - - /** - * Invert the contents of the plugin on the y-axis. - * default is to not be inverted (e.g. use OpenGL coordinates) - */ - void (*invertPluginContent)(NPP instance, bool isContentInverted); -}; - - -#endif diff --git a/dom/plugins/base/android/moz.build b/dom/plugins/base/android/moz.build deleted file mode 100644 index d95d20d5b..000000000 --- a/dom/plugins/base/android/moz.build +++ /dev/null @@ -1,35 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -EXPORTS += [ - 'android_npapi.h', - 'ANPKeyCodes.h', -] - -SOURCES += [ - 'ANPAudio.cpp', - 'ANPEvent.cpp', - 'ANPLog.cpp', - 'ANPNativeWindow.cpp', - 'ANPSurface.cpp', - 'ANPSystem.cpp', - 'ANPVideo.cpp', - 'ANPWindow.cpp', -] - -include('/ipc/chromium/chromium-config.mozbuild') - -FINAL_LIBRARY = 'xul' -LOCAL_INCLUDES += [ - '/dom/plugins/base', - '/gfx/gl', - '/widget', - '/widget/android', -] - -DEFINES['MOZ_APP_NAME'] = '"%s"' % CONFIG['MOZ_APP_NAME'] - -CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS'] diff --git a/dom/plugins/base/moz.build b/dom/plugins/base/moz.build index f43f75f79..a159d6fc1 100644 --- a/dom/plugins/base/moz.build +++ b/dom/plugins/base/moz.build @@ -4,9 +4,6 @@ # 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/. -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': - DIRS += ['android'] - XPIDL_SOURCES += [ 'nsIHTTPHeaderListener.idl', 'nsIPluginDocument.idl', @@ -89,16 +86,10 @@ LOCAL_INCLUDES += [ '/layout/xul', '/netwerk/base', '/widget', - '/widget/android', '/widget/cocoa', '/xpcom/base', ] -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': - LOCAL_INCLUDES += [ - '/dom/plugins/base/android', - ] - if CONFIG['OS_ARCH'] == 'WINNT': LOCAL_INCLUDES += [ '/xpcom/base', @@ -106,8 +97,6 @@ if CONFIG['OS_ARCH'] == 'WINNT': include('/ipc/chromium/chromium-config.mozbuild') -DEFINES['SK_BUILD_FOR_ANDROID_NDK'] = True - FINAL_LIBRARY = 'xul' CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS'] diff --git a/dom/plugins/base/npfunctions.h b/dom/plugins/base/npfunctions.h index 4c9d66ea0..73097d115 100644 --- a/dom/plugins/base/npfunctions.h +++ b/dom/plugins/base/npfunctions.h @@ -9,10 +9,6 @@ #include "npapi.h" #include "npruntime.h" -#ifdef MOZ_WIDGET_ANDROID -#include -#endif - typedef NPError (* NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved); typedef NPError (* NPP_DestroyProcPtr)(NPP instance, NPSavedData** save); typedef NPError (* NPP_SetWindowProcPtr)(NPP instance, NPWindow* window); @@ -261,14 +257,9 @@ NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs); typedef NPError (*NP_GetEntryPointsFunc)(NPPluginFuncs*); NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs); #else -#ifdef MOZ_WIDGET_ANDROID -typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv* pEnv); -NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, JNIEnv* pEnv); -#else typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*); NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs); #endif -#endif typedef NPError (*NP_ShutdownFunc)(void); NP_EXPORT(NPError) NP_Shutdown(void); typedef NPError (*NP_GetValueFunc)(void *, NPPVariable, void *); diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 697bfacd4..da4f09914 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -97,15 +97,6 @@ using mozilla::plugins::PluginModuleContentParent; #endif #endif -#ifdef MOZ_WIDGET_ANDROID -#include -#include "android_npapi.h" -#include "ANPBase.h" -#include "GeneratedJNIWrappers.h" -#undef LOG -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#endif - #include "nsIAudioChannelAgent.h" #include "AudioChannelService.h" @@ -236,11 +227,7 @@ nsNPAPIPlugin::PluginCrashed(const nsAString& pluginDumpID, bool nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag) { -#ifdef MOZ_WIDGET_ANDROID - return false; -#else return true; -#endif } inline PluginLibrary* @@ -282,7 +269,7 @@ nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult) return NS_ERROR_FAILURE; } -#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) +#ifdef XP_MACOSX if (!pluginLib->HasRequiredFunctions()) { NS_WARNING("Not all necessary functions exposed by plugin, it will not load."); delete pluginLib; @@ -2019,156 +2006,6 @@ _getvalue(NPP npp, NPNVariable variable, void *result) return NPERR_NO_ERROR; } -#ifdef MOZ_WIDGET_ANDROID - case kLogInterfaceV0_ANPGetValue: { - LOG("get log interface"); - ANPLogInterfaceV0 *i = (ANPLogInterfaceV0 *) result; - InitLogInterface(i); - return NPERR_NO_ERROR; - } - - case kBitmapInterfaceV0_ANPGetValue: { - LOG("get bitmap interface"); - return NPERR_GENERIC_ERROR; - } - - case kMatrixInterfaceV0_ANPGetValue: { - LOG("get matrix interface"); - return NPERR_GENERIC_ERROR; - } - - case kPathInterfaceV0_ANPGetValue: { - LOG("get path interface"); - return NPERR_GENERIC_ERROR; - } - - case kTypefaceInterfaceV0_ANPGetValue: { - LOG("get typeface interface"); - ANPTypefaceInterfaceV0 *i = (ANPTypefaceInterfaceV0 *) result; - InitTypeFaceInterface(i); - return NPERR_NO_ERROR; - } - - case kPaintInterfaceV0_ANPGetValue: { - LOG("get paint interface"); - ANPPaintInterfaceV0 *i = (ANPPaintInterfaceV0 *) result; - InitPaintInterface(i); - return NPERR_NO_ERROR; - } - - case kCanvasInterfaceV0_ANPGetValue: { - LOG("get canvas interface"); - ANPCanvasInterfaceV0 *i = (ANPCanvasInterfaceV0 *) result; - InitCanvasInterface(i); - return NPERR_NO_ERROR; - } - - case kWindowInterfaceV0_ANPGetValue: { - LOG("get window interface"); - ANPWindowInterfaceV0 *i = (ANPWindowInterfaceV0 *) result; - InitWindowInterface(i); - return NPERR_NO_ERROR; - } - - case kAudioTrackInterfaceV0_ANPGetValue: { - LOG("get audio interface"); - ANPAudioTrackInterfaceV0 *i = (ANPAudioTrackInterfaceV0 *) result; - InitAudioTrackInterfaceV0(i); - return NPERR_NO_ERROR; - } - - case kEventInterfaceV0_ANPGetValue: { - LOG("get event interface"); - ANPEventInterfaceV0 *i = (ANPEventInterfaceV0 *) result; - InitEventInterface(i); - return NPERR_NO_ERROR; - } - - case kSystemInterfaceV0_ANPGetValue: { - LOG("get system interface"); - return NPERR_GENERIC_ERROR; - } - - case kSurfaceInterfaceV0_ANPGetValue: { - LOG("get surface interface"); - ANPSurfaceInterfaceV0 *i = (ANPSurfaceInterfaceV0 *) result; - InitSurfaceInterface(i); - return NPERR_NO_ERROR; - } - - case kSupportedDrawingModel_ANPGetValue: { - LOG("get supported drawing model"); - return NPERR_GENERIC_ERROR; - } - - case kJavaContext_ANPGetValue: { - LOG("get java context"); - auto ret = java::GeckoAppShell::GetContext(); - if (!ret) - return NPERR_GENERIC_ERROR; - - *static_cast(result) = ret.Forget(); - return NPERR_NO_ERROR; - } - - case kAudioTrackInterfaceV1_ANPGetValue: { - LOG("get audio interface v1"); - ANPAudioTrackInterfaceV1 *i = (ANPAudioTrackInterfaceV1 *) result; - InitAudioTrackInterfaceV1(i); - return NPERR_NO_ERROR; - } - - case kNativeWindowInterfaceV0_ANPGetValue: { - LOG("get native window interface v0"); - ANPNativeWindowInterfaceV0* i = (ANPNativeWindowInterfaceV0 *) result; - InitNativeWindowInterface(i); - return NPERR_NO_ERROR; - } - - case kOpenGLInterfaceV0_ANPGetValue: { - LOG("get openGL interface"); - return NPERR_GENERIC_ERROR; - } - - case kWindowInterfaceV1_ANPGetValue: { - LOG("get Window interface V1"); - return NPERR_GENERIC_ERROR; - } - - case kWindowInterfaceV2_ANPGetValue: { - LOG("get Window interface V2"); - ANPWindowInterfaceV2 *i = (ANPWindowInterfaceV2 *) result; - InitWindowInterfaceV2(i); - return NPERR_NO_ERROR; - } - - case kVideoInterfaceV0_ANPGetValue: { - LOG("get video interface V0"); - return NPERR_GENERIC_ERROR; - } - - case kVideoInterfaceV1_ANPGetValue: { - LOG("get video interface V1"); - ANPVideoInterfaceV1 *i = (ANPVideoInterfaceV1*) result; - InitVideoInterfaceV1(i); - return NPERR_NO_ERROR; - } - - case kSystemInterfaceV1_ANPGetValue: { - LOG("get system interface v1"); - ANPSystemInterfaceV1* i = reinterpret_cast(result); - InitSystemInterfaceV1(i); - return NPERR_NO_ERROR; - } - - case kSystemInterfaceV2_ANPGetValue: { - LOG("get system interface v2"); - ANPSystemInterfaceV2* i = reinterpret_cast(result); - InitSystemInterfaceV2(i); - return NPERR_NO_ERROR; - } -#endif - // we no longer hand out any XPCOM objects case NPNVDOMElement: case NPNVDOMWindow: @@ -2298,8 +2135,6 @@ _setvalue(NPP npp, NPPVariable variable, void *result) return NPERR_NO_ERROR; } -#ifndef MOZ_WIDGET_ANDROID - // On android, their 'drawing model' uses the same constant! case NPPVpluginDrawingModel: { if (inst) { inst->SetDrawingModel((NPDrawingModel)NS_PTR_TO_INT32(result)); @@ -2309,7 +2144,6 @@ _setvalue(NPP npp, NPPVariable variable, void *result) return NPERR_GENERIC_ERROR; } } -#endif #ifdef XP_MACOSX case NPPVpluginEventModel: { @@ -2322,14 +2156,7 @@ _setvalue(NPP npp, NPPVariable variable, void *result) } } #endif -#ifdef MOZ_WIDGET_ANDROID - case kRequestDrawingModel_ANPSetValue: - if (inst) - inst->SetANPDrawingModel(NS_PTR_TO_INT32(result)); - return NPERR_NO_ERROR; - case kAcceptEvents_ANPSetValue: - return NPERR_NO_ERROR; -#endif + default: return NPERR_GENERIC_ERROR; } @@ -2682,13 +2509,8 @@ _unscheduletimer(NPP instance, uint32_t timerID) return; } -#ifdef MOZ_WIDGET_ANDROID - // Sometimes Flash calls this with a dead NPP instance. Ensure the one we have - // here is valid and maps to a nsNPAPIPluginInstance. - nsNPAPIPluginInstance *inst = nsNPAPIPluginInstance::GetFromNPP(instance); -#else nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata; -#endif + if (!inst) return; diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index 4b211ed7e..ce24b6296 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -5,11 +5,6 @@ #include "mozilla/DebugOnly.h" -#ifdef MOZ_WIDGET_ANDROID -// For ScreenOrientation.h and Hal.h -#include "base/basictypes.h" -#endif - #include "mozilla/Logging.h" #include "prmem.h" #include "nscore.h" @@ -45,64 +40,6 @@ using namespace mozilla; using namespace mozilla::dom; -#ifdef MOZ_WIDGET_ANDROID -#include "ANPBase.h" -#include -#include "android_npapi.h" -#include "mozilla/Mutex.h" -#include "mozilla/CondVar.h" -#include "mozilla/dom/ScreenOrientation.h" -#include "mozilla/Hal.h" -#include "GLContextProvider.h" -#include "GLContext.h" -#include "TexturePoolOGL.h" -#include "SurfaceTypes.h" -#include "EGLUtils.h" - -using namespace mozilla; -using namespace mozilla::gl; - -typedef nsNPAPIPluginInstance::VideoInfo VideoInfo; - -class PluginEventRunnable : public Runnable -{ -public: - PluginEventRunnable(nsNPAPIPluginInstance* instance, ANPEvent* event) - : mInstance(instance), mEvent(*event), mCanceled(false) {} - - virtual nsresult Run() { - if (mCanceled) - return NS_OK; - - mInstance->HandleEvent(&mEvent, nullptr); - mInstance->PopPostedEvent(this); - return NS_OK; - } - - void Cancel() { mCanceled = true; } -private: - nsNPAPIPluginInstance* mInstance; - ANPEvent mEvent; - bool mCanceled; -}; - -static RefPtr sPluginContext = nullptr; - -static bool EnsureGLContext() -{ - if (!sPluginContext) { - const auto flags = CreateContextFlags::REQUIRE_COMPAT_PROFILE; - nsCString discardedFailureId; - sPluginContext = GLContextProvider::CreateHeadless(flags, &discardedFailureId); - } - - return sPluginContext != nullptr; -} - -static std::map sPluginNPPMap; - -#endif - using namespace mozilla; using namespace mozilla::plugins::parent; using namespace mozilla::layers; @@ -113,13 +50,6 @@ NS_IMPL_ISUPPORTS(nsNPAPIPluginInstance, nsIAudioChannelAgentCallback) nsNPAPIPluginInstance::nsNPAPIPluginInstance() : mDrawingModel(kDefaultDrawingModel) -#ifdef MOZ_WIDGET_ANDROID - , mANPDrawingModel(0) - , mFullScreenOrientation(dom::eScreenOrientation_LandscapePrimary) - , mWakeLocked(false) - , mFullScreen(false) - , mOriginPos(gl::OriginPos::TopLeft) -#endif , mRunning(NOT_STARTED) , mWindowless(false) , mTransparent(false) @@ -131,9 +61,6 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance() , mOwner(nullptr) #ifdef XP_MACOSX , mCurrentPluginEvent(nullptr) -#endif -#ifdef MOZ_WIDGET_ANDROID - , mOnScreen(true) #endif , mHaveJavaC2PJSObjectQuirk(false) , mCachedParamLength(0) @@ -145,20 +72,12 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance() mNPP.ndata = this; PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this)); - -#ifdef MOZ_WIDGET_ANDROID - sPluginNPPMap[&mNPP] = this; -#endif } nsNPAPIPluginInstance::~nsNPAPIPluginInstance() { PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance dtor: this=%p\n",this)); -#ifdef MOZ_WIDGET_ANDROID - sPluginNPPMap.erase(&mNPP); -#endif - if (mMIMEType) { PR_Free((void *)mMIMEType); mMIMEType = nullptr; @@ -195,21 +114,6 @@ nsNPAPIPluginInstance::Destroy() Stop(); mPlugin = nullptr; mAudioChannelAgent = nullptr; - -#if MOZ_WIDGET_ANDROID - if (mContentSurface) - mContentSurface->SetFrameAvailableCallback(nullptr); - - mContentSurface = nullptr; - - std::map::iterator it; - for (it = mVideos.begin(); it != mVideos.end(); it++) { - it->second->mSurfaceTexture->SetFrameAvailableCallback(nullptr); - delete it->second; - } - mVideos.clear(); - SetWakeLock(false); -#endif } TimeStamp @@ -297,14 +201,6 @@ nsresult nsNPAPIPluginInstance::Stop() } mRunning = DESTROYED; -#if MOZ_WIDGET_ANDROID - for (uint32_t i = 0; i < mPostedEvents.Length(); i++) { - mPostedEvents[i]->Cancel(); - } - - mPostedEvents.Clear(); -#endif - nsJSNPRuntime::OnPluginDestroy(&mNPP); if (error != NPERR_NO_ERROR) @@ -404,13 +300,8 @@ nsNPAPIPluginInstance::Start() mCachedParamValues[i] = ToNewUTF8String(attributes[i].mValue); } - // Android expects and empty string instead of null. mCachedParamNames[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING("PARAM")); - #ifdef MOZ_WIDGET_ANDROID - mCachedParamValues[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING("")); - #else - mCachedParamValues[attributes.Length()] = nullptr; - #endif + mCachedParamValues[attributes.Length()] = nullptr; for (uint32_t i = 0, pos = attributes.Length() + 1; i < params.Length(); i ++) { mCachedParamNames[pos] = ToNewUTF8String(params[i].mName); @@ -738,249 +629,6 @@ void nsNPAPIPluginInstance::SetEventModel(NPEventModel aModel) } #endif -#if defined(MOZ_WIDGET_ANDROID) - -static void SendLifecycleEvent(nsNPAPIPluginInstance* aInstance, uint32_t aAction) -{ - ANPEvent event; - event.inSize = sizeof(ANPEvent); - event.eventType = kLifecycle_ANPEventType; - event.data.lifecycle.action = aAction; - aInstance->HandleEvent(&event, nullptr); -} - -void nsNPAPIPluginInstance::NotifyForeground(bool aForeground) -{ - PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetForeground this=%p\n foreground=%d",this, aForeground)); - if (RUNNING != mRunning) - return; - - SendLifecycleEvent(this, aForeground ? kResume_ANPLifecycleAction : kPause_ANPLifecycleAction); -} - -void nsNPAPIPluginInstance::NotifyOnScreen(bool aOnScreen) -{ - PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetOnScreen this=%p\n onScreen=%d",this, aOnScreen)); - if (RUNNING != mRunning || mOnScreen == aOnScreen) - return; - - mOnScreen = aOnScreen; - SendLifecycleEvent(this, aOnScreen ? kOnScreen_ANPLifecycleAction : kOffScreen_ANPLifecycleAction); -} - -void nsNPAPIPluginInstance::MemoryPressure() -{ - PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::MemoryPressure this=%p\n",this)); - if (RUNNING != mRunning) - return; - - SendLifecycleEvent(this, kFreeMemory_ANPLifecycleAction); -} - -void nsNPAPIPluginInstance::NotifyFullScreen(bool aFullScreen) -{ - PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::NotifyFullScreen this=%p\n",this)); - - if (RUNNING != mRunning || mFullScreen == aFullScreen) - return; - - mFullScreen = aFullScreen; - SendLifecycleEvent(this, mFullScreen ? kEnterFullScreen_ANPLifecycleAction : kExitFullScreen_ANPLifecycleAction); - - if (mFullScreen && mFullScreenOrientation != dom::eScreenOrientation_None) { - java::GeckoAppShell::LockScreenOrientation(mFullScreenOrientation); - } -} - -void nsNPAPIPluginInstance::NotifySize(nsIntSize size) -{ - if (kOpenGL_ANPDrawingModel != GetANPDrawingModel() || - size == mCurrentSize) - return; - - mCurrentSize = size; - - ANPEvent event; - event.inSize = sizeof(ANPEvent); - event.eventType = kDraw_ANPEventType; - event.data.draw.model = kOpenGL_ANPDrawingModel; - event.data.draw.data.surfaceSize.width = size.width; - event.data.draw.data.surfaceSize.height = size.height; - - HandleEvent(&event, nullptr); -} - -void nsNPAPIPluginInstance::SetANPDrawingModel(uint32_t aModel) -{ - mANPDrawingModel = aModel; -} - -void* nsNPAPIPluginInstance::GetJavaSurface() -{ - void* surface = nullptr; - nsresult rv = GetValueFromPlugin(kJavaSurface_ANPGetValue, &surface); - if (NS_FAILED(rv)) - return nullptr; - - return surface; -} - -void nsNPAPIPluginInstance::PostEvent(void* event) -{ - PluginEventRunnable *r = new PluginEventRunnable(this, (ANPEvent*)event); - mPostedEvents.AppendElement(RefPtr(r)); - - NS_DispatchToMainThread(r); -} - -void nsNPAPIPluginInstance::SetFullScreenOrientation(uint32_t orientation) -{ - if (mFullScreenOrientation == orientation) - return; - - uint32_t oldOrientation = mFullScreenOrientation; - mFullScreenOrientation = orientation; - - if (mFullScreen) { - // We're already fullscreen so immediately apply the orientation change - - if (mFullScreenOrientation != dom::eScreenOrientation_None) { - java::GeckoAppShell::LockScreenOrientation(mFullScreenOrientation); - } else if (oldOrientation != dom::eScreenOrientation_None) { - // We applied an orientation when we entered fullscreen, but - // we don't want it anymore - java::GeckoAppShell::UnlockScreenOrientation(); - } - } -} - -void nsNPAPIPluginInstance::PopPostedEvent(PluginEventRunnable* r) -{ - mPostedEvents.RemoveElement(r); -} - -void nsNPAPIPluginInstance::SetWakeLock(bool aLocked) -{ - if (aLocked == mWakeLocked) - return; - - mWakeLocked = aLocked; - hal::ModifyWakeLock(NS_LITERAL_STRING("screen"), - mWakeLocked ? hal::WAKE_LOCK_ADD_ONE : hal::WAKE_LOCK_REMOVE_ONE, - hal::WAKE_LOCK_NO_CHANGE); -} - -GLContext* nsNPAPIPluginInstance::GLContext() -{ - if (!EnsureGLContext()) - return nullptr; - - return sPluginContext; -} - -already_AddRefed nsNPAPIPluginInstance::CreateSurfaceTexture() -{ - if (!EnsureGLContext()) - return nullptr; - - GLuint texture = TexturePoolOGL::AcquireTexture(); - if (!texture) - return nullptr; - - RefPtr surface = AndroidSurfaceTexture::Create(TexturePoolOGL::GetGLContext(), - texture); - if (!surface) { - return nullptr; - } - - nsCOMPtr frameCallback = NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable); - surface->SetFrameAvailableCallback(frameCallback); - return surface.forget(); -} - -void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable() -{ - if (mRunning == RUNNING && mOwner) - mOwner->Recomposite(); -} - -void* nsNPAPIPluginInstance::AcquireContentWindow() -{ - if (!mContentSurface) { - mContentSurface = CreateSurfaceTexture(); - - if (!mContentSurface) - return nullptr; - } - - return mContentSurface->NativeWindow(); -} - -AndroidSurfaceTexture* -nsNPAPIPluginInstance::AsSurfaceTexture() -{ - if (!mContentSurface) - return nullptr; - - return mContentSurface; -} - -void* nsNPAPIPluginInstance::AcquireVideoWindow() -{ - RefPtr surface = CreateSurfaceTexture(); - if (!surface) { - return nullptr; - } - - VideoInfo* info = new VideoInfo(surface); - - void* window = info->mSurfaceTexture->NativeWindow(); - mVideos.insert(std::pair(window, info)); - - return window; -} - -void nsNPAPIPluginInstance::ReleaseVideoWindow(void* window) -{ - std::map::iterator it = mVideos.find(window); - if (it == mVideos.end()) - return; - - delete it->second; - mVideos.erase(window); -} - -void nsNPAPIPluginInstance::SetVideoDimensions(void* window, gfxRect aDimensions) -{ - std::map::iterator it; - - it = mVideos.find(window); - if (it == mVideos.end()) - return; - - it->second->mDimensions = aDimensions; -} - -void nsNPAPIPluginInstance::GetVideos(nsTArray& aVideos) -{ - std::map::iterator it; - for (it = mVideos.begin(); it != mVideos.end(); it++) - aVideos.AppendElement(it->second); -} - -nsNPAPIPluginInstance* nsNPAPIPluginInstance::GetFromNPP(NPP npp) -{ - std::map::iterator it; - - it = sPluginNPPMap.find(npp); - if (it == sPluginNPPMap.end()) - return nullptr; - - return it->second; -} - -#endif - nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel) { *aModel = (int32_t)mDrawingModel; @@ -1083,9 +731,8 @@ nsNPAPIPluginInstance::ShouldCache() nsresult nsNPAPIPluginInstance::IsWindowless(bool* isWindowless) { -#if defined(MOZ_WIDGET_ANDROID) || defined(XP_MACOSX) +#ifdef XP_MACOSX // All OS X plugins are windowless. - // On android, pre-honeycomb, all plugins are treated as windowless. *isWindowless = true; #else *isWindowless = mWindowless; diff --git a/dom/plugins/base/nsNPAPIPluginInstance.h b/dom/plugins/base/nsNPAPIPluginInstance.h index 5f0375637..48e62517d 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.h +++ b/dom/plugins/base/nsNPAPIPluginInstance.h @@ -18,15 +18,6 @@ #include #include "js/TypeDecls.h" #include "nsIAudioChannelAgent.h" -#ifdef MOZ_WIDGET_ANDROID -#include "nsIRunnable.h" -#include "GLContextTypes.h" -#include "AndroidSurfaceTexture.h" -#include "AndroidBridge.h" -#include -class PluginEventRunnable; -#endif - #include "mozilla/EventForwards.h" #include "mozilla/TimeStamp.h" #include "mozilla/PluginLibrary.h" @@ -163,90 +154,6 @@ public: } #endif -#ifdef MOZ_WIDGET_ANDROID - void NotifyForeground(bool aForeground); - void NotifyOnScreen(bool aOnScreen); - void MemoryPressure(); - void NotifyFullScreen(bool aFullScreen); - void NotifySize(nsIntSize size); - - nsIntSize CurrentSize() { return mCurrentSize; } - - bool IsOnScreen() { - return mOnScreen; - } - - uint32_t GetANPDrawingModel() { return mANPDrawingModel; } - void SetANPDrawingModel(uint32_t aModel); - - void* GetJavaSurface(); - - void PostEvent(void* event); - - // These are really mozilla::dom::ScreenOrientation, but it's - // difficult to include that here - uint32_t FullScreenOrientation() { return mFullScreenOrientation; } - void SetFullScreenOrientation(uint32_t orientation); - - void SetWakeLock(bool aLock); - - mozilla::gl::GLContext* GLContext(); - - // For ANPOpenGL - class TextureInfo { - public: - TextureInfo() : - mTexture(0), mWidth(0), mHeight(0), mInternalFormat(0) - { - } - - TextureInfo(GLuint aTexture, int32_t aWidth, int32_t aHeight, GLuint aInternalFormat) : - mTexture(aTexture), mWidth(aWidth), mHeight(aHeight), mInternalFormat(aInternalFormat) - { - } - - GLuint mTexture; - int32_t mWidth; - int32_t mHeight; - GLuint mInternalFormat; - }; - - // For ANPNativeWindow - void* AcquireContentWindow(); - - mozilla::gl::AndroidSurfaceTexture* AsSurfaceTexture(); - - // For ANPVideo - class VideoInfo { - public: - VideoInfo(mozilla::gl::AndroidSurfaceTexture* aSurfaceTexture) : - mSurfaceTexture(aSurfaceTexture) - { - } - - ~VideoInfo() - { - mSurfaceTexture = nullptr; - } - - RefPtr mSurfaceTexture; - gfxRect mDimensions; - }; - - void* AcquireVideoWindow(); - void ReleaseVideoWindow(void* aWindow); - void SetVideoDimensions(void* aWindow, gfxRect aDimensions); - - void GetVideos(nsTArray& aVideos); - - void SetOriginPos(mozilla::gl::OriginPos aOriginPos) { - mOriginPos = aOriginPos; - } - mozilla::gl::OriginPos OriginPos() const { return mOriginPos; } - - static nsNPAPIPluginInstance* GetFromNPP(NPP npp); -#endif - nsresult NewStreamListener(const char* aURL, void* notifyData, nsNPAPIPluginStreamListener** listener); @@ -347,23 +254,6 @@ protected: NPDrawingModel mDrawingModel; -#ifdef MOZ_WIDGET_ANDROID - uint32_t mANPDrawingModel; - - friend class PluginEventRunnable; - - nsTArray> mPostedEvents; - void PopPostedEvent(PluginEventRunnable* r); - void OnSurfaceTextureFrameAvailable(); - - uint32_t mFullScreenOrientation; - bool mWakeLocked; - bool mFullScreen; - mozilla::gl::OriginPos mOriginPos; - - RefPtr mContentSurface; -#endif - enum { NOT_STARTED, RUNNING, @@ -410,15 +300,6 @@ private: // This is only valid when the plugin is actually stopped! mozilla::TimeStamp mStopTime; -#ifdef MOZ_WIDGET_ANDROID - already_AddRefed CreateSurfaceTexture(); - - std::map mVideos; - bool mOnScreen; - - nsIntSize mCurrentSize; -#endif - // is this instance Java and affected by bug 750480? bool mHaveJavaC2PJSObjectQuirk; @@ -434,13 +315,7 @@ private: bool mMuted; }; -// On Android, we need to guard against plugin code leaking entries in the local -// JNI ref table. See https://bugzilla.mozilla.org/show_bug.cgi?id=780831#c21 -#ifdef MOZ_WIDGET_ANDROID - #define MAIN_THREAD_JNI_REF_GUARD mozilla::AutoLocalJNIFrame jniFrame -#else - #define MAIN_THREAD_JNI_REF_GUARD -#endif +#define MAIN_THREAD_JNI_REF_GUARD void NS_NotifyBeginPluginCall(NSPluginCallReentry aReentryState); void NS_NotifyPluginCall(NSPluginCallReentry aReentryState); diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index c3de136d0..1b98855d1 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -104,11 +104,6 @@ #include "winbase.h" #endif -#ifdef ANDROID -#include -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#endif - #include "npapi.h" using namespace mozilla; @@ -293,10 +288,6 @@ nsPluginHost::nsPluginHost() if (obsService) { obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); obsService->AddObserver(this, "blocklist-updated", false); -#ifdef MOZ_WIDGET_ANDROID - obsService->AddObserver(this, "application-foreground", false); - obsService->AddObserver(this, "application-background", false); -#endif } #ifdef PLUGIN_LOGGING @@ -2306,11 +2297,6 @@ WatchRegKey(uint32_t aRoot, nsCOMPtr& aKey) nsresult nsPluginHost::LoadPlugins() { -#ifdef ANDROID - if (XRE_IsContentProcess()) { - return NS_OK; - } -#endif // do not do anything if it is already done // use ReloadPlugins() to enforce loading if (mPluginsLoaded) @@ -2453,10 +2439,6 @@ nsresult nsPluginHost::FindPlugins(bool aCreatePluginList, bool * aPluginsChange NS_ITERATIVE_UNREF_LIST(RefPtr, mInvalidPlugins, mNext); return NS_OK; } - } else { -#ifdef ANDROID - LOG("getting plugins dir failed"); -#endif } mPluginsLoaded = true; // at this point 'some' plugins have been loaded, @@ -3069,14 +3051,6 @@ nsPluginHost::ReadPluginInfo() if (!reader.NextLine()) return rv; -#if MOZ_WIDGET_ANDROID - // Flash on Android does not populate the version field, but it is tacked on to the description. - // For example, "Shockwave Flash 11.1 r115" - if (PL_strncmp("Shockwave Flash ", description, 16) == 0 && description[16]) { - version = &description[16]; - } -#endif - const char *name = reader.LinePtr(); if (!reader.NextLine()) return rv; @@ -3144,31 +3118,6 @@ nsPluginHost::ReadPluginInfo() mCachedPlugins = tag; } -// On Android we always want to try to load a plugin again (Flash). Bug 935676. -#ifndef MOZ_WIDGET_ANDROID - if (!ReadSectionHeader(reader, "INVALID")) { - return rv; - } - - while (reader.NextLine()) { - const char *fullpath = reader.LinePtr(); - if (!reader.NextLine()) { - return rv; - } - - const char *lastModifiedTimeStamp = reader.LinePtr(); - int64_t lastmod = nsCRT::atoll(lastModifiedTimeStamp); - - RefPtr invalidTag = new nsInvalidPluginTag(fullpath, lastmod); - - invalidTag->mNext = mInvalidPlugins; - if (mInvalidPlugins) { - mInvalidPlugins->mPrev = invalidTag; - } - mInvalidPlugins = invalidTag; - } -#endif - return NS_OK; } @@ -3491,24 +3440,7 @@ NS_IMETHODIMP nsPluginHost::Observe(nsISupports *aSubject, plugin = plugin->mNext; } } -#ifdef MOZ_WIDGET_ANDROID - if (!strcmp("application-background", aTopic)) { - for(uint32_t i = 0; i < mInstances.Length(); i++) { - mInstances[i]->NotifyForeground(false); - } - } - if (!strcmp("application-foreground", aTopic)) { - for(uint32_t i = 0; i < mInstances.Length(); i++) { - if (mInstances[i]->IsOnScreen()) - mInstances[i]->NotifyForeground(true); - } - } - if (!strcmp("memory-pressure", aTopic)) { - for(uint32_t i = 0; i < mInstances.Length(); i++) { - mInstances[i]->MemoryPressure(); - } - } -#endif + return NS_OK; } diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index d5b1eb9ea..22c4783ca 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -87,20 +87,6 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); #include #endif -#ifdef MOZ_WIDGET_ANDROID -#include "ANPBase.h" -#include "AndroidBridge.h" -#include "ClientLayerManager.h" -#include "nsWindow.h" - -static nsPluginInstanceOwner* sFullScreenInstance = nullptr; - -using namespace mozilla::dom; - -#include -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) -#endif - using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::layers; @@ -165,29 +151,6 @@ nsPluginInstanceOwner::NotifyPaintWaiter(nsDisplayListBuilder* aBuilder) } } -#if MOZ_WIDGET_ANDROID -static void -AttachToContainerAsSurfaceTexture(ImageContainer* container, - nsNPAPIPluginInstance* instance, - const LayoutDeviceRect& rect, - RefPtr* out_image) -{ - MOZ_ASSERT(out_image); - MOZ_ASSERT(!*out_image); - - mozilla::gl::AndroidSurfaceTexture* surfTex = instance->AsSurfaceTexture(); - if (!surfTex) { - return; - } - - RefPtr img = new SurfaceTextureImage( - surfTex, - gfx::IntSize::Truncate(rect.width, rect.height), - instance->OriginPos()); - *out_image = img; -} -#endif - bool nsPluginInstanceOwner::NeedsScrollImageLayer() { @@ -211,27 +174,6 @@ nsPluginInstanceOwner::GetImageContainer() RefPtr container; -#if MOZ_WIDGET_ANDROID - LayoutDeviceRect r = GetPluginRect(); - - // NotifySize() causes Flash to do a bunch of stuff like ask for surfaces to render - // into, set y-flip flags, etc, so we do this at the beginning. - float resolution = mPluginFrame->PresContext()->PresShell()->GetCumulativeResolution(); - ScreenSize screenSize = (r * LayoutDeviceToScreenScale(resolution)).Size(); - mInstance->NotifySize(nsIntSize::Truncate(screenSize.width, screenSize.height)); - - container = LayerManager::CreateImageContainer(); - - if (r.width && r.height) { - // Try to get it as an EGLImage first. - RefPtr img; - AttachToContainerAsSurfaceTexture(container, mInstance, r, &img); - - if (img) { - container->SetCurrentImageInTransaction(img); - } - } -#else if (NeedsScrollImageLayer()) { // windowed plugin under e10s #if defined(XP_WIN) @@ -241,7 +183,6 @@ nsPluginInstanceOwner::GetImageContainer() // async windowless rendering mInstance->GetImageContainer(getter_AddRefs(container)); } -#endif return container.forget(); } @@ -358,11 +299,6 @@ nsPluginInstanceOwner::nsPluginInstanceOwner() mWaitingForPaint = false; -#ifdef MOZ_WIDGET_ANDROID - mFullScreen = false; - mJavaView = nullptr; -#endif - #ifdef XP_WIN mGotCompositionData = false; mSentStartComposition = false; @@ -387,10 +323,6 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner() PLUG_DeletePluginNativeWindow(mPluginWindow); mPluginWindow = nullptr; -#ifdef MOZ_WIDGET_ANDROID - RemovePluginView(); -#endif - if (mInstance) { mInstance->SetOwner(nullptr); } @@ -413,10 +345,6 @@ nsPluginInstanceOwner::SetInstance(nsNPAPIPluginInstance *aInstance) // from our destructor. This fixes bug 613376. if (mInstance && !aInstance) { mInstance->SetOwner(nullptr); - -#ifdef MOZ_WIDGET_ANDROID - RemovePluginView(); -#endif } mInstance = aInstance; @@ -601,7 +529,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(NPRect *invalidRect) if (!mPluginFrame || !invalidRect || !mWidgetVisible) return NS_ERROR_FAILURE; -#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) +#ifdef XP_MACOSX // Each time an asynchronously-drawing plugin sends a new surface to display, // the image in the ImageContainer is updated and InvalidateRect is called. // There are different side effects for (sync) Android plugins. @@ -624,6 +552,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(NPRect *invalidRect) } } #endif + nsIntRect rect(invalidRect->left, invalidRect->top, invalidRect->right - invalidRect->left, @@ -1485,185 +1414,6 @@ nsPluginInstanceOwner::GetEventloopNestingLevel() return currentLevel; } -#ifdef MOZ_WIDGET_ANDROID - -// Modified version of nsFrame::GetOffsetToCrossDoc that stops when it -// hits an element with a displayport (or runs out of frames). This is -// not really the right thing to do, but it's better than what was here before. -static nsPoint -GetOffsetRootContent(nsIFrame* aFrame) -{ - // offset will hold the final offset - // docOffset holds the currently accumulated offset at the current APD, it - // will be converted and added to offset when the current APD changes. - nsPoint offset(0, 0), docOffset(0, 0); - const nsIFrame* f = aFrame; - int32_t currAPD = aFrame->PresContext()->AppUnitsPerDevPixel(); - int32_t apd = currAPD; - while (f) { - if (f->GetContent() && nsLayoutUtils::HasDisplayPort(f->GetContent())) - break; - - docOffset += f->GetPosition(); - nsIFrame* parent = f->GetParent(); - if (parent) { - f = parent; - } else { - nsPoint newOffset(0, 0); - f = nsLayoutUtils::GetCrossDocParentFrame(f, &newOffset); - int32_t newAPD = f ? f->PresContext()->AppUnitsPerDevPixel() : 0; - if (!f || newAPD != currAPD) { - // Convert docOffset to the right APD and add it to offset. - offset += docOffset.ScaleToOtherAppUnits(currAPD, apd); - docOffset.x = docOffset.y = 0; - } - currAPD = newAPD; - docOffset += newOffset; - } - } - - offset += docOffset.ScaleToOtherAppUnits(currAPD, apd); - - return offset; -} - -LayoutDeviceRect nsPluginInstanceOwner::GetPluginRect() -{ - // Get the offset of the content relative to the page - nsRect bounds = mPluginFrame->GetContentRectRelativeToSelf() + GetOffsetRootContent(mPluginFrame); - LayoutDeviceIntRect rect = LayoutDeviceIntRect::FromAppUnitsToNearest(bounds, mPluginFrame->PresContext()->AppUnitsPerDevPixel()); - return LayoutDeviceRect(rect); -} - -bool nsPluginInstanceOwner::AddPluginView(const LayoutDeviceRect& aRect /* = LayoutDeviceRect(0, 0, 0, 0) */) -{ - if (!mJavaView) { - mJavaView = mInstance->GetJavaSurface(); - - if (!mJavaView) - return false; - - mJavaView = (void*)jni::GetGeckoThreadEnv()->NewGlobalRef((jobject)mJavaView); - } - - if (mFullScreen) { - java::GeckoAppShell::AddFullScreenPluginView(jni::Object::Ref::From(jobject(mJavaView))); - sFullScreenInstance = this; - } - - return true; -} - -void nsPluginInstanceOwner::RemovePluginView() -{ - if (!mInstance || !mJavaView) - return; - - if (mFullScreen) { - java::GeckoAppShell::RemoveFullScreenPluginView(jni::Object::Ref::From(jobject(mJavaView))); - } - jni::GetGeckoThreadEnv()->DeleteGlobalRef((jobject)mJavaView); - mJavaView = nullptr; - - if (mFullScreen) - sFullScreenInstance = nullptr; -} - -void -nsPluginInstanceOwner::GetVideos(nsTArray& aVideos) -{ - if (!mInstance) - return; - - mInstance->GetVideos(aVideos); -} - -already_AddRefed -nsPluginInstanceOwner::GetImageContainerForVideo(nsNPAPIPluginInstance::VideoInfo* aVideoInfo) -{ - RefPtr container = LayerManager::CreateImageContainer(); - - if (aVideoInfo->mDimensions.width && aVideoInfo->mDimensions.height) { - RefPtr img = new SurfaceTextureImage( - aVideoInfo->mSurfaceTexture, - gfx::IntSize::Truncate(aVideoInfo->mDimensions.width, aVideoInfo->mDimensions.height), - gl::OriginPos::BottomLeft); - container->SetCurrentImageInTransaction(img); - } - - return container.forget(); -} - -void nsPluginInstanceOwner::Invalidate() { - NPRect rect; - rect.left = rect.top = 0; - rect.right = mPluginWindow->width; - rect.bottom = mPluginWindow->height; - InvalidateRect(&rect); -} - -void nsPluginInstanceOwner::Recomposite() { - nsIWidget* const widget = mPluginFrame->GetNearestWidget(); - NS_ENSURE_TRUE_VOID(widget); - - LayerManager* const lm = widget->GetLayerManager(); - NS_ENSURE_TRUE_VOID(lm); - - ClientLayerManager* const clm = lm->AsClientLayerManager(); - NS_ENSURE_TRUE_VOID(clm && clm->GetRoot()); - - clm->SendInvalidRegion( - clm->GetRoot()->GetLocalVisibleRegion().ToUnknownRegion().GetBounds()); - clm->Composite(); -} - -void nsPluginInstanceOwner::RequestFullScreen() { - if (mFullScreen) - return; - - // Remove whatever view we currently have (if any, fullscreen or otherwise) - RemovePluginView(); - - mFullScreen = true; - AddPluginView(); - - mInstance->NotifyFullScreen(mFullScreen); -} - -void nsPluginInstanceOwner::ExitFullScreen() { - if (!mFullScreen) - return; - - RemovePluginView(); - - mFullScreen = false; - - int32_t model = mInstance->GetANPDrawingModel(); - - if (model == kSurface_ANPDrawingModel) { - // We need to do this immediately, otherwise Flash - // sometimes causes a deadlock (bug 762407) - AddPluginView(GetPluginRect()); - } - - mInstance->NotifyFullScreen(mFullScreen); - - // This will cause Paint() to be called, which is where - // we normally add/update views and layers - Invalidate(); -} - -void nsPluginInstanceOwner::ExitFullScreen(jobject view) { - JNIEnv* env = jni::GetGeckoThreadEnv(); - - if (sFullScreenInstance && sFullScreenInstance->mInstance && - env->IsSameObject(view, (jobject)sFullScreenInstance->mInstance->GetJavaSurface())) { - sFullScreenInstance->ExitFullScreen(); - } -} - -#endif - void nsPluginInstanceOwner::NotifyHostAsyncInitFailed() { @@ -1705,27 +1455,6 @@ nsPluginInstanceOwner::NotifyDestroyPending() nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent) { -#ifdef MOZ_WIDGET_ANDROID - if (mInstance) { - ANPEvent event; - event.inSize = sizeof(ANPEvent); - event.eventType = kLifecycle_ANPEventType; - - nsAutoString eventType; - aFocusEvent->GetType(eventType); - if (eventType.EqualsLiteral("focus")) { - event.data.lifecycle.action = kGainFocus_ANPLifecycleAction; - } - else if (eventType.EqualsLiteral("blur")) { - event.data.lifecycle.action = kLoseFocus_ANPLifecycleAction; - } - else { - NS_ASSERTION(false, "nsPluginInstanceOwner::DispatchFocusToPlugin, wierd eventType"); - } - mInstance->HandleEvent(&event, nullptr); - } -#endif - #ifndef XP_MACOSX if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow)) { // continue only for cases without child window @@ -2786,96 +2515,6 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent) rv = nsEventStatus_eConsumeNoDefault; #endif -#ifdef MOZ_WIDGET_ANDROID - // this code supports windowless plugins - { - // The plugin needs focus to receive keyboard and touch events - nsIFocusManager* fm = nsFocusManager::GetFocusManager(); - if (fm) { - nsCOMPtr elem = do_QueryReferent(mContent); - fm->SetFocus(elem, 0); - } - } - switch(anEvent.mClass) { - case eMouseEventClass: - { - switch (anEvent.mMessage) { - case eMouseClick: - case eMouseDoubleClick: - case eMouseAuxClick: - // Button up/down events sent instead. - return rv; - default: - break; - } - - // Get reference point relative to plugin origin. - const nsPresContext* presContext = mPluginFrame->PresContext(); - nsPoint appPoint = - nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mPluginFrame) - - mPluginFrame->GetContentRectRelativeToSelf().TopLeft(); - nsIntPoint pluginPoint(presContext->AppUnitsToDevPixels(appPoint.x), - presContext->AppUnitsToDevPixels(appPoint.y)); - - switch (anEvent.mMessage) { - case eMouseMove: - { - // are these going to be touch events? - // pluginPoint.x; - // pluginPoint.y; - } - break; - case eMouseDown: - { - ANPEvent event; - event.inSize = sizeof(ANPEvent); - event.eventType = kMouse_ANPEventType; - event.data.mouse.action = kDown_ANPMouseAction; - event.data.mouse.x = pluginPoint.x; - event.data.mouse.y = pluginPoint.y; - mInstance->HandleEvent(&event, nullptr, NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO); - } - break; - case eMouseUp: - { - ANPEvent event; - event.inSize = sizeof(ANPEvent); - event.eventType = kMouse_ANPEventType; - event.data.mouse.action = kUp_ANPMouseAction; - event.data.mouse.x = pluginPoint.x; - event.data.mouse.y = pluginPoint.y; - mInstance->HandleEvent(&event, nullptr, NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO); - } - break; - default: - break; - } - } - break; - - case eKeyboardEventClass: - { - const WidgetKeyboardEvent& keyEvent = *anEvent.AsKeyboardEvent(); - LOG("Firing eKeyboardEventClass %d %d\n", - keyEvent.mKeyCode, keyEvent.mCharCode); - // pluginEvent is initialized by nsWindow::InitKeyEvent(). - const ANPEvent* pluginEvent = static_cast(keyEvent.mPluginEvent); - if (pluginEvent) { - MOZ_ASSERT(pluginEvent->inSize == sizeof(ANPEvent)); - MOZ_ASSERT(pluginEvent->eventType == kKey_ANPEventType); - mInstance->HandleEvent(const_cast(pluginEvent), - nullptr, - NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO); - } - } - break; - - default: - break; - } - rv = nsEventStatus_eConsumeNoDefault; -#endif - return rv; } @@ -2922,10 +2561,6 @@ nsPluginInstanceOwner::Destroy() this, true); content->RemoveSystemEventListener(NS_LITERAL_STRING("text"), this, true); -#if MOZ_WIDGET_ANDROID - RemovePluginView(); -#endif - if (mWidget) { if (mPluginWindow) { mPluginWindow->SetPluginWidget(nullptr); @@ -2995,72 +2630,6 @@ void nsPluginInstanceOwner::Paint(const RECT& aDirty, HDC aDC) } #endif -#ifdef MOZ_WIDGET_ANDROID - -void nsPluginInstanceOwner::Paint(gfxContext* aContext, - const gfxRect& aFrameRect, - const gfxRect& aDirtyRect) -{ - if (!mInstance || !mPluginFrame || !mPluginDocumentActiveState || mFullScreen) - return; - - int32_t model = mInstance->GetANPDrawingModel(); - - if (model == kSurface_ANPDrawingModel) { - if (!AddPluginView(GetPluginRect())) { - Invalidate(); - } - return; - } - - if (model != kBitmap_ANPDrawingModel) - return; - -#ifdef ANP_BITMAP_DRAWING_MODEL - static RefPtr pluginSurface; - - if (pluginSurface == nullptr || - aFrameRect.width != pluginSurface->Width() || - aFrameRect.height != pluginSurface->Height()) { - - pluginSurface = new gfxImageSurface(gfx::IntSize(aFrameRect.width, aFrameRect.height), - SurfaceFormat::A8R8G8B8_UINT32); - if (!pluginSurface) - return; - } - - // Clears buffer. I think this is needed. - gfxUtils::ClearThebesSurface(pluginSurface); - - ANPEvent event; - event.inSize = sizeof(ANPEvent); - event.eventType = 4; - event.data.draw.model = 1; - - event.data.draw.clip.top = 0; - event.data.draw.clip.left = 0; - event.data.draw.clip.bottom = aFrameRect.width; - event.data.draw.clip.right = aFrameRect.height; - - event.data.draw.data.bitmap.format = kRGBA_8888_ANPBitmapFormat; - event.data.draw.data.bitmap.width = aFrameRect.width; - event.data.draw.data.bitmap.height = aFrameRect.height; - event.data.draw.data.bitmap.baseAddr = pluginSurface->Data(); - event.data.draw.data.bitmap.rowBytes = aFrameRect.width * 4; - - if (!mInstance) - return; - - mInstance->HandleEvent(&event, nullptr); - - aContext->SetOp(gfx::CompositionOp::OP_SOURCE); - aContext->SetSource(pluginSurface, gfxPoint(aFrameRect.x, aFrameRect.y)); - aContext->Clip(aFrameRect); - aContext->Paint(); -#endif -} -#endif - #if defined(MOZ_X11) void nsPluginInstanceOwner::Paint(gfxContext* aContext, const gfxRect& aFrameRect, @@ -3663,24 +3232,6 @@ nsPluginInstanceOwner::UpdateDocumentActiveState(bool aIsActive) #ifndef XP_MACOSX UpdateWindowPositionAndClipRect(true); -#ifdef MOZ_WIDGET_ANDROID - if (mInstance) { - if (!mPluginDocumentActiveState) { - RemovePluginView(); - } - - mInstance->NotifyOnScreen(mPluginDocumentActiveState); - - // This is, perhaps, incorrect. It is supposed to be sent - // when "the webview has paused or resumed". The side effect - // is that Flash video players pause or resume (if they were - // playing before) based on the value here. I personally think - // we want that on Android when switching to another tab, so - // that's why we call it here. - mInstance->NotifyForeground(mPluginDocumentActiveState); - } -#endif // #ifdef MOZ_WIDGET_ANDROID - // We don't have a connection to PluginWidgetParent in the chrome // process when dealing with tab visibility changes, so this needs // to be forwarded over after the active state is updated. If we diff --git a/dom/plugins/base/nsPluginInstanceOwner.h b/dom/plugins/base/nsPluginInstanceOwner.h index 589bcb02c..2fa67c86e 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.h +++ b/dom/plugins/base/nsPluginInstanceOwner.h @@ -29,7 +29,7 @@ class nsPluginDOMContextMenuListener; class nsPluginFrame; class nsDisplayListBuilder; -#if defined(MOZ_X11) || defined(ANDROID) +#ifdef MOZ_X11 class gfxContext; #endif @@ -108,7 +108,7 @@ public: void Paint(const gfxRect& aDirtyRect, CGContextRef cgContext); void RenderCoreAnimation(CGContextRef aCGContext, int aWidth, int aHeight); void DoCocoaEventDrawRect(const gfxRect& aDrawRect, CGContextRef cgContext); -#elif defined(MOZ_X11) || defined(ANDROID) +#elif defined(MOZ_X11) void Paint(gfxContext* aContext, const gfxRect& aFrameRect, const gfxRect& aDirtyRect); @@ -254,21 +254,6 @@ public: already_AddRefed GetBaseURI() const; -#ifdef MOZ_WIDGET_ANDROID - // Returns the image container for the specified VideoInfo - void GetVideos(nsTArray& aVideos); - already_AddRefed GetImageContainerForVideo(nsNPAPIPluginInstance::VideoInfo* aVideoInfo); - - void Invalidate(); - void Recomposite(); - - void RequestFullScreen(); - void ExitFullScreen(); - - // Called from nsAppShell when we removed the fullscreen view. - static void ExitFullScreen(jobject view); -#endif - void NotifyHostAsyncInitFailed(); void NotifyHostCreateWidget(); void NotifyDestroyPending(); @@ -306,16 +291,7 @@ private: size == nsIntSize(mPluginWindow->width, mPluginWindow->height); } -#ifdef MOZ_WIDGET_ANDROID - mozilla::LayoutDeviceRect GetPluginRect(); - bool AddPluginView(const mozilla::LayoutDeviceRect& aRect = mozilla::LayoutDeviceRect(0, 0, 0, 0)); - void RemovePluginView(); - - bool mFullScreen; - void* mJavaView; -#endif - -#if defined(XP_WIN) +#ifdef XP_WIN nsIWidget* GetContainingWidgetIfOffset(); already_AddRefed GetTextComposition(); void HandleNoConsumedCompositionMessage( diff --git a/dom/plugins/base/nsPluginTags.cpp b/dom/plugins/base/nsPluginTags.cpp index a794c416c..58b413388 100644 --- a/dom/plugins/base/nsPluginTags.cpp +++ b/dom/plugins/base/nsPluginTags.cpp @@ -735,10 +735,6 @@ nsPluginTag::GetNiceName(nsACString & aResult) NS_IMETHODIMP nsPluginTag::GetBlocklistState(uint32_t *aResult) { -#if defined(MOZ_WIDGET_ANDROID) - *aResult = nsIBlocklistService::STATE_NOT_BLOCKED; - return NS_OK; -#else if (mCachedBlocklistStateValid) { *aResult = mCachedBlocklistState; return NS_OK; @@ -772,7 +768,6 @@ nsPluginTag::GetBlocklistState(uint32_t *aResult) mCachedBlocklistState = (uint16_t) *aResult; mCachedBlocklistStateValid = true; return NS_OK; -#endif // defined(MOZ_WIDGET_ANDROID) } void diff --git a/dom/plugins/base/nsPluginsDirUnix.cpp b/dom/plugins/base/nsPluginsDirUnix.cpp index de3b7a2d1..55a4eb0d6 100644 --- a/dom/plugins/base/nsPluginsDirUnix.cpp +++ b/dom/plugins/base/nsPluginsDirUnix.cpp @@ -206,16 +206,6 @@ bool nsPluginsDir::IsPluginFile(nsIFile* file) if (NS_FAILED(file->GetNativeLeafName(filename))) return false; -#ifdef ANDROID - // It appears that if you load - // 'libstagefright_honeycomb.so' on froyo, or - // 'libstagefright_froyo.so' on honeycomb, we will abort. - // Since these are just helper libs, we can ignore. - const char *cFile = filename.get(); - if (strstr(cFile, "libstagefright") != nullptr) - return false; -#endif - NS_NAMED_LITERAL_CSTRING(dllSuffix, LOCAL_PLUGIN_DLL_SUFFIX); if (filename.Length() > dllSuffix.Length() && StringEndsWith(filename, dllSuffix)) diff --git a/dom/plugins/ipc/NPEventAndroid.h b/dom/plugins/ipc/NPEventAndroid.h deleted file mode 100644 index f664af857..000000000 --- a/dom/plugins/ipc/NPEventAndroid.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */ -/* 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/. */ - -// This is a NPEventX11.h derived stub for Android -// Plugins aren't actually supported yet - -#ifndef mozilla_dom_plugins_NPEventAndroid_h -#define mozilla_dom_plugins_NPEventAndroid_h - -#include "npapi.h" - -namespace mozilla { - -namespace plugins { - -struct NPRemoteEvent { - NPEvent event; -}; - -} - -} - - -namespace IPC { - -template <> -struct ParamTraits -{ - typedef mozilla::plugins::NPRemoteEvent paramType; - - static void Write(Message* aMsg, const paramType& aParam) - { - aMsg->WriteBytes(&aParam, sizeof(paramType)); - } - - static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) - { - return aMsg->ReadBytesInto(aIter, aResult, sizeof(paramType)); - } - - static void Log(const paramType& aParam, std::wstring* aLog) - { - // TODO - aLog->append(L"(AndroidEvent)"); - } -}; - -} // namespace IPC - - -#endif // mozilla_dom_plugins_NPEventAndroid_h diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 3f2cdbc13..a4f6b6b51 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -1427,8 +1427,6 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow) if (mPluginIface->setwindow) (void) mPluginIface->setwindow(&mData, &mWindow); -#elif defined(ANDROID) - // TODO: Need Android impl #elif defined(MOZ_WIDGET_UIKIT) // Don't care #else diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index bdd15ca99..24b1410bc 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -265,9 +265,6 @@ PluginInstanceParent::AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle* XID id; #elif defined(XP_DARWIN) intptr_t id; -#elif defined(ANDROID) - // TODO: Need Android impl - int id; #else #warning Implement me #endif diff --git a/dom/plugins/ipc/PluginMessageUtils.h b/dom/plugins/ipc/PluginMessageUtils.h index 4532fac93..a9cd52ae2 100644 --- a/dom/plugins/ipc/PluginMessageUtils.h +++ b/dom/plugins/ipc/PluginMessageUtils.h @@ -111,7 +111,7 @@ struct NPAudioDeviceChangeDetailsIPC typedef HWND NativeWindowHandle; #elif defined(MOZ_X11) typedef XID NativeWindowHandle; -#elif defined(XP_DARWIN) || defined(ANDROID) +#elif defined(XP_DARWIN) typedef intptr_t NativeWindowHandle; // never actually used, will always be 0 #else #error Need NativeWindowHandle for this platform @@ -736,8 +736,6 @@ struct ParamTraits # include "mozilla/plugins/NPEventOSX.h" #elif defined(XP_WIN) # include "mozilla/plugins/NPEventWindows.h" -#elif defined(ANDROID) -# include "mozilla/plugins/NPEventAndroid.h" #elif defined(XP_UNIX) # include "mozilla/plugins/NPEventUnix.h" #else diff --git a/dom/plugins/ipc/moz.build b/dom/plugins/ipc/moz.build index 15ed6410d..051d5a3b4 100644 --- a/dom/plugins/ipc/moz.build +++ b/dom/plugins/ipc/moz.build @@ -17,7 +17,6 @@ EXPORTS.mozilla.plugins += [ 'BrowserStreamParent.h', 'ChildAsyncCall.h', 'ChildTimer.h', - 'NPEventAndroid.h', 'NPEventOSX.h', 'NPEventUnix.h', 'NPEventWindows.h', -- cgit v1.2.3