diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-05-15 00:44:39 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-05-15 00:44:39 +0800 |
commit | 8b98e5a84ca0346c9a86d51f0f9e22f24e7ad480 (patch) | |
tree | 868df0a35334e599fd2bf869ad2a0849ffd6e6dc | |
parent | acbf19f2b304633890aeb8705f6269f45c30d987 (diff) | |
download | gsoc2013-epiphany-8b98e5a84ca0346c9a86d51f0f9e22f24e7ad480.tar gsoc2013-epiphany-8b98e5a84ca0346c9a86d51f0f9e22f24e7ad480.tar.gz gsoc2013-epiphany-8b98e5a84ca0346c9a86d51f0f9e22f24e7ad480.tar.bz2 gsoc2013-epiphany-8b98e5a84ca0346c9a86d51f0f9e22f24e7ad480.tar.lz gsoc2013-epiphany-8b98e5a84ca0346c9a86d51f0f9e22f24e7ad480.tar.xz gsoc2013-epiphany-8b98e5a84ca0346c9a86d51f0f9e22f24e7ad480.tar.zst gsoc2013-epiphany-8b98e5a84ca0346c9a86d51f0f9e22f24e7ad480.zip |
Yet another mozilla API change (backported from HEAD).
2004-05-14 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/EphyContentPolicy.cpp:
Yet another mozilla API change (backported from HEAD).
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | embed/mozilla/EphyContentPolicy.cpp | 81 |
2 files changed, 67 insertions, 20 deletions
@@ -1,3 +1,9 @@ +2004-05-14 Christian Persch <chpe@cvs.gnome.org> + + * embed/mozilla/EphyContentPolicy.cpp: + + Yet another mozilla API change (backported from HEAD). + 2004-05-12 Christian Persch <chpe@cvs.gnome.org> * src/epiphany.in: diff --git a/embed/mozilla/EphyContentPolicy.cpp b/embed/mozilla/EphyContentPolicy.cpp index e84e7d73b..3a537c42c 100644 --- a/embed/mozilla/EphyContentPolicy.cpp +++ b/embed/mozilla/EphyContentPolicy.cpp @@ -19,13 +19,6 @@ * $Id$ */ -/* Relevant Mozilla bug numbers: - * - * The API will change soon: - * http://bugzilla.mozilla.org/show_bug.cgi?id=191839 - * "Content Policy API sucks rock" - */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -46,23 +39,79 @@ NS_IMPL_ISUPPORTS1(EphyContentPolicy, nsIContentPolicy) EphyContentPolicy::EphyContentPolicy() { - LOG ("EphyContentPolicy constructor") + LOG ("EphyContentPolicy ctor (%p)", this) mLocked = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_UNSAFE_PROTOCOLS); - mSafeProtocols = eel_gconf_get_string_list (CONF_LOCKDOWN_ADDITIONAL_SAFE_PROTOCOLS); + mSafeProtocols = eel_gconf_get_string_list (CONF_LOCKDOWN_ADDITIONAL_SAFE_PROTOCOLS); mSafeProtocols = g_slist_prepend (mSafeProtocols, g_strdup ("https")); mSafeProtocols = g_slist_prepend (mSafeProtocols, g_strdup ("http")); + } EphyContentPolicy::~EphyContentPolicy() { - LOG ("EphyContentPolicy destructor") + LOG ("EphyContentPolicy dtor (%p)", this) g_slist_foreach (mSafeProtocols, (GFunc) g_free, NULL); g_slist_free (mSafeProtocols); } +#if MOZILLA_SNAPSHOT >= 18 +NS_IMETHODIMP +EphyContentPolicy::ShouldLoad(PRUint32 aContentType, + nsIURI *aContentLocation, + nsIURI *aRequestingLocation, + nsIDOMNode *aRequestingNode, + const nsACString &aMimeTypeGuess, + nsISupports *aExtra, + PRInt16 *aDecision) +{ + if (!mLocked) + { + *aDecision = nsIContentPolicy::ACCEPT; + return NS_OK; + } + + NS_ENSURE_TRUE (aContentLocation, NS_ERROR_FAILURE); + + nsCAutoString scheme; + aContentLocation->GetScheme (scheme); + + nsCAutoString spec; + aContentLocation->GetSpec (spec); + + LOG ("ShouldLoad type=%d location=%s (scheme %s)", aContentType, spec.get(), scheme.get()) + + *aDecision = nsIContentPolicy::REJECT_REQUEST; + + /* Allow the load if the protocol is in safe list, or it's about:blank */ + if (g_slist_find_custom (mSafeProtocols, scheme.get(), (GCompareFunc) strcmp) + || spec.Equals ("about:blank")) + { + *aDecision = nsIContentPolicy::ACCEPT; + } + + LOG ("Decision: %sallowing load", *aDecision >= 0 ? "" : "DIS") + + return NS_OK; +} + +NS_IMETHODIMP +EphyContentPolicy::ShouldProcess(PRUint32 aContentType, + nsIURI *aContentLocation, + nsIURI *aRequestingLocation, + nsIDOMNode *aRequestingNode, + const nsACString &aMimeType, + nsISupports *aExtra, + PRInt16 *aDecision) +{ + *aDecision = nsIContentPolicy::ACCEPT; + return NS_OK; +} + +#else + /* boolean shouldLoad (in PRInt32 contentType, in nsIURI contentLocation, in nsISupports ctxt, in nsIDOMWindow window); */ NS_IMETHODIMP EphyContentPolicy::ShouldLoad(PRInt32 contentType, nsIURI *contentLocation, @@ -72,10 +121,7 @@ NS_IMETHODIMP EphyContentPolicy::ShouldLoad(PRInt32 contentType, { if (!mLocked) { - LOG ("Not locked!") - *_retval = PR_TRUE; - return NS_OK; } @@ -85,8 +131,6 @@ NS_IMETHODIMP EphyContentPolicy::ShouldLoad(PRInt32 contentType, nsCAutoString spec; contentLocation->GetSpec (spec); - LOG ("ShouldLoad type=%d location=%s (scheme %s)", contentType, spec.get(), scheme.get()) - *_retval = PR_FALSE; /* Allow the load if the protocol is in safe list, or it's about:blank */ @@ -96,8 +140,6 @@ NS_IMETHODIMP EphyContentPolicy::ShouldLoad(PRInt32 contentType, *_retval = PR_TRUE; } - LOG ("Decision: %sallowing load", *_retval == PR_TRUE ? "" : "NOT ") - return NS_OK; } @@ -108,11 +150,10 @@ NS_IMETHODIMP EphyContentPolicy::ShouldProcess(PRInt32 contentType, nsIDOMWindow *window, PRBool *_retval) { - /* As far as I can tell from reading mozilla code, this is never called. */ - + /* This is never called. */ LOG ("ShouldProcess: this is quite unexpected!") *_retval = PR_TRUE; - return NS_OK; } +#endif /* MOZILLA_SNAPSHOT >= 18 */ |