[totem] Pass referrer info to the plugin viewer
- From: Christian Persch <chpe src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [totem] Pass referrer info to the plugin viewer
- Date: Mon, 26 Oct 2009 14:26:16 +0000 (UTC)
commit 7f1a540554ff24698fafe8ad9f2a718e0a944153
Author: Christian Persch <chpe gnome org>
Date: Thu Oct 22 13:26:15 2009 +0200
Pass referrer info to the plugin viewer
Get the plugin document's URI and pass that as the referrer to the
plugin viewer.
Part of bug #581857.
browser-plugin/totem-plugin-viewer-options.h | 1 +
browser-plugin/totem-plugin-viewer.c | 16 +++++++++-
browser-plugin/totemPlugin.cpp | 40 +++++++++++++++++++++++++-
browser-plugin/totemPlugin.h | 1 +
4 files changed, 56 insertions(+), 2 deletions(-)
---
diff --git a/browser-plugin/totem-plugin-viewer-options.h b/browser-plugin/totem-plugin-viewer-options.h
index a168709..59f1070 100644
--- a/browser-plugin/totem-plugin-viewer-options.h
+++ b/browser-plugin/totem-plugin-viewer-options.h
@@ -36,5 +36,6 @@
#define TOTEM_OPTION_USER_AGENT "user-agent"
#define TOTEM_OPTION_STATUSBAR "statusbar"
#define TOTEM_OPTION_AUDIOONLY "audio-only"
+#define TOTEM_OPTION_REFERRER "referrer"
#endif /* !__TOTEM_PLUGIN_VIEWER_OPTIONS_H__ */
diff --git a/browser-plugin/totem-plugin-viewer.c b/browser-plugin/totem-plugin-viewer.c
index 6d02d07..0b3afac 100644
--- a/browser-plugin/totem-plugin-viewer.c
+++ b/browser-plugin/totem-plugin-viewer.c
@@ -2,7 +2,7 @@
*
* Copyright © 2004-2006 Bastien Nocera <hadess hadess net>
* Copyright © 2002 David A. Schleef <ds schleef org>
- * Copyright © 2006 Christian Persch
+ * Copyright © 2006, 2009 Christian Persch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -112,6 +112,7 @@ typedef struct _TotemEmbedded {
int width, height;
char *user_agent;
const char *mimetype;
+ char *referrer_uri;
char *base_uri;
char *current_uri;
char *href_uri;
@@ -1751,6 +1752,16 @@ totem_embedded_construct (TotemEmbedded *emb,
emb->user_agent = NULL;
}
+ /* FIXMEchpe: this is just the initial value. I think in case e.g. we're doing
+ * a playlist, the playlist's URI should become the referrer?
+ */
+ g_print ("Referrer URI: %s\n", emb->referrer_uri);
+ if (emb->referrer_uri != NULL) {
+ bacon_video_widget_set_referrer (emb->bvw, emb->referrer_uri);
+ g_free (emb->referrer_uri);
+ emb->referrer_uri = NULL;
+ }
+
/* Fullscreen setup */
emb->fs_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_realize (emb->fs_window);
@@ -2122,6 +2133,7 @@ totem_embedded_push_parser (gpointer data)
static char *arg_user_agent = NULL;
static char *arg_mime_type = NULL;
static char **arg_remaining = NULL;
+static char *arg_referrer = NULL;
static gboolean arg_no_controls = FALSE;
static gboolean arg_statusbar = FALSE;
static gboolean arg_hidden = FALSE;
@@ -2169,6 +2181,7 @@ static GOptionEntry option_entries [] =
{ TOTEM_OPTION_REPEAT, 0, 0, G_OPTION_ARG_NONE, &arg_repeat, NULL, NULL },
{ TOTEM_OPTION_NOAUTOSTART, 0, 0, G_OPTION_ARG_NONE, &arg_no_autostart, NULL, NULL },
{ TOTEM_OPTION_AUDIOONLY, 0, 0, G_OPTION_ARG_NONE, &arg_audioonly, NULL, NULL },
+ { TOTEM_OPTION_REFERRER, 0, 0, G_OPTION_ARG_STRING, &arg_referrer, NULL, NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY /* STRING? */, &arg_remaining, NULL },
{ NULL }
};
@@ -2314,6 +2327,7 @@ int main (int argc, char **argv)
emb->audioonly = arg_audioonly;
emb->type = arg_plugin_type;
emb->user_agent = arg_user_agent;
+ emb->referrer_uri = arg_referrer;
/* FIXME: register this BEFORE requesting the service name? */
dbus_g_connection_register_g_object
diff --git a/browser-plugin/totemPlugin.cpp b/browser-plugin/totemPlugin.cpp
index 3d9c862..30dea4b 100644
--- a/browser-plugin/totemPlugin.cpp
+++ b/browser-plugin/totemPlugin.cpp
@@ -2,7 +2,7 @@
*
* Copyright © 2004-2006 Bastien Nocera <hadess hadess net>
* Copyright © 2002 David A. Schleef <ds schleef org>
- * Copyright © 2006, 2007, 2008 Christian Persch
+ * Copyright © 2006, 2007, 2008, 2009 Christian Persch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -210,6 +210,7 @@ totemPlugin::operator new (size_t aSize) throw ()
totemPlugin::totemPlugin (NPP aNPP)
: mNPP (aNPP),
mMimeType (NULL),
+ mDocumentURI (NULL),
mBaseURI (NULL),
mSrcURI (NULL),
mRequestBaseURI (NULL),
@@ -280,6 +281,7 @@ totemPlugin::~totemPlugin ()
g_free (mMimeType);
g_free (mSrcURI);
+ g_free (mDocumentURI);
g_free (mBaseURI);
g_free (mRequestURI);
g_free (mRequestBaseURI);
@@ -538,6 +540,15 @@ totemPlugin::ViewerFork ()
g_ptr_array_add (arr, g_strdup (userAgent));
}
+ /* FIXMEchpe: This passes the document URI of the document the plugin is in
+ * as the HTTP referrer. I'm not at all sure this is the right URI! Need
+ * to check what exactly the various legacy plugins pass here.
+ */
+ if (mDocumentURI) {
+ g_ptr_array_add (arr, g_strdup (DASHES TOTEM_OPTION_REFERRER));
+ g_ptr_array_add (arr, g_strdup (mDocumentURI));
+ }
+
/* FIXME: remove this */
if (mMimeType) {
g_ptr_array_add (arr, g_strdup (DASHES TOTEM_OPTION_MIMETYPE));
@@ -1924,6 +1935,33 @@ totemPlugin::Init (NPMIMEType mimetype,
}
#endif /* TOTEM_COMPLEX_PLUGIN */
+ /* FIXMEchpe: should use totemNPObjectWrapper + getter_Retains(),
+ * but that causes a crash somehow, deep inside libxul...
+ */
+ totemNPVariantWrapper ownerDocument;
+ if (!NPN_GetProperty (mNPP,
+ mPluginElement,
+ NPN_GetStringIdentifier ("ownerDocument"),
+ getter_Copies (ownerDocument)) ||
+ !ownerDocument.IsObject ()) {
+ Dm ("Failed to get the plugin element's ownerDocument");
+ return NPERR_GENERIC_ERROR;
+ }
+
+ totemNPVariantWrapper docURI;
+ if (!NPN_GetProperty (mNPP,
+ ownerDocument.GetObject(),
+ NPN_GetStringIdentifier ("documentURI"),
+ getter_Copies (docURI)) ||
+ !docURI.IsString ()) {
+ Dm ("Failed to get the document URI");
+ return NPERR_GENERIC_ERROR;
+ }
+
+ /* FIXMEchpe: need to resolve this against any base URIs ? */
+ mDocumentURI = g_strndup (docURI.GetString(), docURI.GetStringLen());
+ D ("Document URI is '%s'", mDocumentURI ? mDocumentURI : "");
+
/* We'd like to get the base URI of our DOM element as a nsIURI,
* but there's no frozen method to do so (nsIContent/nsINode isn't available
* for non-MOZILLA_INTERNAL_API code). nsIDOM3Node isn't frozen either,
diff --git a/browser-plugin/totemPlugin.h b/browser-plugin/totemPlugin.h
index fe7101f..4f91ed6 100644
--- a/browser-plugin/totemPlugin.h
+++ b/browser-plugin/totemPlugin.h
@@ -190,6 +190,7 @@ class totemPlugin {
char* mMimeType;
+ char* mDocumentURI;
char* mBaseURI;
char* mSrcURI; /* relative to mBaseURI */
char* mRequestBaseURI;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]