Bug 1167690 - Part 1: Hook up NPPVpluginIsPlayingAudio to the plugin process; r=josh

This commit is contained in:
Benoit Girard 2015-07-28 16:59:26 -04:00 коммит произвёл Ehsan Akhgari
Родитель c34722a98d
Коммит 61e92462cb
5 изменённых файлов: 43 добавлений и 0 удалений

Просмотреть файл

@ -2402,6 +2402,27 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
return inst->SetUsesDOMForCursor(useDOMForCursor);
}
case NPPVpluginIsPlayingAudio: {
// For testing, remove me
printf("set audio %p\n", result);
bool isPlaying = !!result;
nsCOMPtr<nsIDocument> doc = GetDocumentFromNPP(npp);
if (doc) {
nsCOMPtr<nsPIDOMWindow> domwindow = doc->GetWindow();
nsCOMPtr<nsIObserverService> observerService =
services::GetObserverService();
if (observerService) {
// XXX THIS NEEDS A BETTER API
observerService->NotifyObservers(ToSupports(domwindow),
"media-playback",
isPlaying ? NS_LITERAL_STRING("active").get() :
NS_LITERAL_STRING("inactive").get());
}
}
return NPERR_NO_ERROR;
}
#ifndef MOZ_WIDGET_ANDROID
// On android, their 'drawing model' uses the same constant!
case NPPVpluginDrawingModel: {

Просмотреть файл

@ -150,6 +150,8 @@ parent:
returns (NPError result);
intr NPN_SetValue_NPPVpluginEventModel(int eventModel)
returns (NPError result);
intr NPN_SetValue_NPPVpluginIsPlayingAudio(bool isAudioPlaying)
returns (NPError result);
intr NPN_GetURL(nsCString url, nsCString target)
returns (NPError result);

Просмотреть файл

@ -626,6 +626,14 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
}
#endif
case NPPVpluginIsPlayingAudio: {
NPError rv = NPERR_GENERIC_ERROR;
if (!CallNPN_SetValue_NPPVpluginIsPlayingAudio((NPBool)(intptr_t)aValue, &rv)) {
return NPERR_GENERIC_ERROR;
}
return rv;
}
default:
MOZ_LOG(GetPluginLog(), LogLevel::Warning,
("In PluginInstanceChild::NPN_SetValue: Unhandled NPPVariable %i (%s)",

Просмотреть файл

@ -440,6 +440,15 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginEventModel(
#endif
}
bool
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginIsPlayingAudio(
const bool& isAudioPlaying, NPError* result)
{
*result = mNPNIface->setvalue(mNPP, NPPVpluginIsPlayingAudio,
(void*)(intptr_t)isAudioPlaying);
return true;
}
bool
PluginInstanceParent::AnswerNPN_GetURL(const nsCString& url,
const nsCString& target,

Просмотреть файл

@ -128,6 +128,9 @@ public:
virtual bool
AnswerNPN_SetValue_NPPVpluginEventModel(const int& eventModel,
NPError* result) override;
virtual bool
AnswerNPN_SetValue_NPPVpluginIsPlayingAudio(const bool& isAudioPlaying,
NPError* result) override;
virtual bool
AnswerNPN_GetURL(const nsCString& url, const nsCString& target,