diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-05-15 00:43:26 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-05-15 00:43:26 +0800 |
commit | 8c5a1404b36c9962b4f0e8c1a5746639ac939a19 (patch) | |
tree | a283cf7230fc3ef66106a0cd2c40ecb0082a3d13 /embed/mozilla/EphyContentPolicy.cpp | |
parent | 1a6118c2d8524c48261bdcb2aa9eedbe39bb2173 (diff) | |
download | gsoc2013-epiphany-8c5a1404b36c9962b4f0e8c1a5746639ac939a19.tar gsoc2013-epiphany-8c5a1404b36c9962b4f0e8c1a5746639ac939a19.tar.gz gsoc2013-epiphany-8c5a1404b36c9962b4f0e8c1a5746639ac939a19.tar.bz2 gsoc2013-epiphany-8c5a1404b36c9962b4f0e8c1a5746639ac939a19.tar.lz gsoc2013-epiphany-8c5a1404b36c9962b4f0e8c1a5746639ac939a19.tar.xz gsoc2013-epiphany-8c5a1404b36c9962b4f0e8c1a5746639ac939a19.tar.zst gsoc2013-epiphany-8c5a1404b36c9962b4f0e8c1a5746639ac939a19.zip |
Yet another mozilla API change.
2004-05-14 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/EphyContentPolicy.cpp:
Yet another mozilla API change.
Diffstat (limited to 'embed/mozilla/EphyContentPolicy.cpp')
-rw-r--r-- | embed/mozilla/EphyContentPolicy.cpp | 74 |
1 files changed, 61 insertions, 13 deletions
diff --git a/embed/mozilla/EphyContentPolicy.cpp b/embed/mozilla/EphyContentPolicy.cpp index eda29c0ba..b5f661517 100644 --- a/embed/mozilla/EphyContentPolicy.cpp +++ b/embed/mozilla/EphyContentPolicy.cpp @@ -49,23 +49,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, @@ -75,10 +131,7 @@ NS_IMETHODIMP EphyContentPolicy::ShouldLoad(PRInt32 contentType, { if (!mLocked) { - LOG ("Not locked!") - *_retval = PR_TRUE; - return NS_OK; } @@ -88,8 +141,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 */ @@ -99,8 +150,6 @@ NS_IMETHODIMP EphyContentPolicy::ShouldLoad(PRInt32 contentType, *_retval = PR_TRUE; } - LOG ("Decision: %sallowing load", *_retval == PR_TRUE ? "" : "NOT ") - return NS_OK; } @@ -111,11 +160,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 */ |