Implement NPN_GetURLNotify/NPN_PostURLNotify/NPP_URLNotify. Still without any tests!

This commit is contained in:
Benjamin Smedberg 2009-09-08 17:22:50 -04:00
Родитель 13eb6f3032
Коммит b11c695563
10 изменённых файлов: 279 добавлений и 1 удалений

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

@ -69,6 +69,8 @@ EXPORTS_mozilla/plugins = \
PluginMessageUtils.h \
PluginProcessParent.h \
PluginThreadChild.h \
StreamNotifyParent.h \
StreamNotifyChild.h \
$(NULL)
MODULE = dom

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

@ -40,11 +40,13 @@
include protocol "PPluginModule.ipdl";
include protocol "PPluginScriptableObject.ipdl";
include protocol "PBrowserStream.ipdl";
include protocol "PStreamNotify.ipdl";
include "mozilla/plugins/PluginMessageUtils.h";
using NPError;
using NPWindow;
using NPReason;
// FIXME/bent: demo purposes only
@ -75,6 +77,7 @@ rpc protocol PPluginInstance
manages PPluginScriptableObject;
manages PBrowserStream;
manages PStreamNotify;
@ -90,6 +93,7 @@ child:
rpc PBrowserStream(nsCString url,
uint32_t length,
uint32_t lastmodified,
PStreamNotify notifyData,
nsCString headers,
nsCString mimeType,
bool seekable)
@ -101,6 +105,27 @@ child:
rpc NPP_GetValue(nsString key)
returns (nsString value);
parent:
rpc NPN_GetURL(nsCString url, nsCString target)
returns (NPError result);
rpc NPN_PostURL(nsCString url, nsCString target, nsCString buffer, bool file)
returns (NPError result);
/**
* Covers both NPN_GetURLNotify and NPN_PostURLNotify.
* @TODO This would be more readable as an overloaded method,
* but IPDL doesn't allow that for constructors (or any method?).
*/
rpc PStreamNotify(nsCString url, nsCString target, bool post,
nsCString buffer, bool file)
returns (NPError result);
child:
/**
* Represents NPP_URLNotify
*/
rpc ~PStreamNotify(NPReason reason);
parent:
rpc PPluginScriptableObject()
returns (NPError rv);
@ -113,7 +138,7 @@ both:
* @param artificial True when the stream is closed as a by-product of
* some other call (such as a failure in NPP_Write).
*/
rpc ~PBrowserStream(NPError reason,
rpc ~PBrowserStream(NPReason reason,
bool artificial);
};

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

@ -0,0 +1,17 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
include protocol "PPluginInstance.ipdl";
namespace mozilla {
namespace plugins {
/**
* This empty protocol exists only to be constructed and destroyed.
*/
rpc protocol PStreamNotify
{
manager PPluginInstance;
};
} // namespace plugins
} // namespace mozilla

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

@ -38,6 +38,7 @@
#include "PluginInstanceChild.h"
#include "BrowserStreamChild.h"
#include "StreamNotifyChild.h"
#if defined(OS_LINUX)
@ -381,6 +382,7 @@ PBrowserStreamChild*
PluginInstanceChild::PBrowserStreamConstructor(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
const PStreamNotifyChild* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
@ -400,5 +402,28 @@ PluginInstanceChild::PBrowserStreamDestructor(PBrowserStreamChild* stream,
return NS_OK;
}
PStreamNotifyChild*
PluginInstanceChild::PStreamNotifyConstructor(const nsCString& url,
const nsCString& target,
const bool& post,
const nsCString& buffer,
const bool& file,
NPError* result)
{
NS_RUNTIMEABORT("not reached");
return NULL;
}
nsresult
PluginInstanceChild::PStreamNotifyDestructor(PStreamNotifyChild* notifyData,
const NPReason& reason)
{
StreamNotifyChild* sn = static_cast<StreamNotifyChild*>(notifyData);
mPluginIface->urlnotify(&mData, sn->mURL.get(), reason, sn->mClosure);
delete sn;
return NS_OK;
}
} // namespace plugins
} // namespace mozilla

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

@ -137,6 +137,7 @@ protected:
PBrowserStreamConstructor(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
const PStreamNotifyChild* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
@ -148,6 +149,16 @@ protected:
const NPError& reason,
const bool& artificial);
virtual PStreamNotifyChild*
PStreamNotifyConstructor(const nsCString& url, const nsCString& target,
const bool& post, const nsCString& buffer,
const bool& file,
NPError* result);
virtual nsresult
PStreamNotifyDestructor(PStreamNotifyChild* notifyData,
const NPReason& reason);
public:
PluginInstanceChild(const NPPluginFuncs* aPluginIface) :
mPluginIface(aPluginIface)

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

@ -38,6 +38,7 @@
#include "PluginInstanceParent.h"
#include "BrowserStreamParent.h"
#include "StreamNotifyParent.h"
namespace mozilla {
namespace plugins {
@ -46,6 +47,7 @@ PBrowserStreamParent*
PluginInstanceParent::PBrowserStreamConstructor(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
const PStreamNotifyParent* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
@ -76,6 +78,59 @@ PluginInstanceParent::PBrowserStreamDestructor(PBrowserStreamParent* stream,
return NS_OK;
}
nsresult
PluginInstanceParent::AnswerNPN_GetURL(const nsCString& url,
const nsCString& target,
NPError* result)
{
*result = mNPNIface->geturl(mNPP, url.get(), target.get());
// TODO: what if the method fails?
return NS_OK;
}
nsresult
PluginInstanceParent::AnswerNPN_PostURL(const nsCString& url,
const nsCString& target,
const nsCString& buffer,
const bool& file,
NPError* result)
{
*result = mNPNIface->posturl(mNPP, url.get(), target.get(),
buffer.Length(), buffer.get(), file);
// TODO: what if the method fails?
return NS_OK;
}
PStreamNotifyParent*
PluginInstanceParent::PStreamNotifyConstructor(const nsCString& url,
const nsCString& target,
const bool& post,
const nsCString& buffer,
const bool& file,
NPError* result)
{
StreamNotifyParent* notifyData = new StreamNotifyParent();
if (!post) {
*result = mNPNIface->geturlnotify(mNPP, url.get(), target.get(),
notifyData);
}
else {
*result = mNPNIface->posturlnotify(mNPP, url.get(), target.get(),
buffer.Length(), buffer.get(),
file, notifyData);
}
// TODO: what if this method fails?
return notifyData;
}
nsresult
PluginInstanceParent::PStreamNotifyDestructor(PStreamNotifyParent* notifyData,
const NPReason& reason)
{
delete notifyData;
}
NPError
PluginInstanceParent::NPP_SetWindow(NPWindow* aWindow)
{
@ -120,6 +175,7 @@ PluginInstanceParent::NPP_NewStream(NPMIMEType type, NPStream* stream,
nsCString(stream->url),
stream->end,
stream->lastmodified,
static_cast<PStreamNotifyParent*>(stream->notifyData),
nsCString(stream->headers),
nsCString(type), seekable, &err, stype);
return err;

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

@ -85,6 +85,7 @@ public:
PBrowserStreamConstructor(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
const PStreamNotifyParent* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
@ -101,6 +102,25 @@ public:
const NPError& reason,
const bool& artificial);
virtual nsresult
AnswerNPN_GetURL(const nsCString& url, const nsCString& target,
NPError *result);
virtual nsresult
AnswerNPN_PostURL(const nsCString& url, const nsCString& target,
const nsCString& buffer, const bool& file,
NPError* result);
virtual PStreamNotifyParent*
PStreamNotifyConstructor(const nsCString& url, const nsCString& target,
const bool& post, const nsCString& buffer,
const bool& file,
NPError* result);
virtual nsresult
PStreamNotifyDestructor(PStreamNotifyParent* notifyData,
const NPReason& reason);
NPError NPP_SetWindow(NPWindow* aWindow);
NPError NPP_GetValue(NPPVariable variable, void *ret_value);

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

@ -0,0 +1,64 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=2 et : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_plugins_StreamNotifyChild_h
#define mozilla_plugins_StreamNotifyChild_h
#include "mozilla/plugins/PStreamNotifyChild.h"
namespace mozilla {
namespace plugins {
class StreamNotifyChild : public PStreamNotifyChild
{
friend class PluginInstanceChild;
StreamNotifyChild(const nsCString& aURL, void* aClosure)
: mURL(aURL)
, mClosure(aClosure)
{ }
private:
nsCString mURL;
void* mClosure;
};
} // namespace plugins
} // namespace mozilla
#endif

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

@ -0,0 +1,57 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=2 et : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Plugin App.
*
* The Initial Developer of the Original Code is
* Chris Jones <jones.chris.g@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_plugins_StreamNotifyParent_h
#define mozilla_plugins_StreamNotifyParent_h
#include "mozilla/plugins/PStreamNotifyParent.h"
namespace mozilla {
namespace plugins {
class StreamNotifyParent : public PStreamNotifyParent
{
friend class PluginInstanceParent;
StreamNotifyParent() { }
};
} // namespace plugins
} // namespace mozilla
#endif

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

@ -39,4 +39,5 @@ IPDLSRCS = \
PPluginInstance.ipdl \
PPluginScriptableObject.ipdl \
PBrowserStream.ipdl \
PStreamNotify.ipdl \
$(NULL)