aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-07-24 18:16:10 +0800
committerChristian Persch <chpe@src.gnome.org>2004-07-24 18:16:10 +0800
commitaf8bbdbc5bc95e1e3cd3fc6fc49f9f1e3eea91ed (patch)
treee92bd101d32468f46208992e5bade9ad2bdc2280 /embed
parent4d4808cdc6c565dbdefea90b567b3efe9718c5c4 (diff)
downloadgsoc2013-epiphany-af8bbdbc5bc95e1e3cd3fc6fc49f9f1e3eea91ed.tar
gsoc2013-epiphany-af8bbdbc5bc95e1e3cd3fc6fc49f9f1e3eea91ed.tar.gz
gsoc2013-epiphany-af8bbdbc5bc95e1e3cd3fc6fc49f9f1e3eea91ed.tar.bz2
gsoc2013-epiphany-af8bbdbc5bc95e1e3cd3fc6fc49f9f1e3eea91ed.tar.lz
gsoc2013-epiphany-af8bbdbc5bc95e1e3cd3fc6fc49f9f1e3eea91ed.tar.xz
gsoc2013-epiphany-af8bbdbc5bc95e1e3cd3fc6fc49f9f1e3eea91ed.tar.zst
gsoc2013-epiphany-af8bbdbc5bc95e1e3cd3fc6fc49f9f1e3eea91ed.zip
Refactores storing the security info, move it into EphyBrowser.
2004-07-24 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EphyBrowser.h: * embed/mozilla/mozilla-embed.cpp: Refactores storing the security info, move it into EphyBrowser.
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/EphyBrowser.cpp49
-rw-r--r--embed/mozilla/EphyBrowser.h5
-rw-r--r--embed/mozilla/mozilla-embed.cpp51
3 files changed, 64 insertions, 41 deletions
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index 7e500f431..fe45beb4d 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -65,9 +65,16 @@
#include "nsIDOMWindow2.h"
#include "nsEmbedString.h"
#include "nsMemory.h"
+#include "nsIServiceManager.h"
+#include "nsIChannel.h"
+#include "nsIInterfaceRequestor.h"
#ifdef ALLOW_PRIVATE_API
#include "nsIMarkupDocumentViewer.h"
+#ifdef HAVE_MOZILLA_PSM
+/* not sure about this one: */
+#include <nsITransportSecurityInfo.h>
+#endif
#endif
static PRUnichar DOMLinkAdded[] = { 'D', 'O', 'M', 'L', 'i', 'n', 'k',
@@ -938,3 +945,45 @@ nsresult EphyBrowser::GetHasModifiedForms (PRBool *modified)
return NS_OK;
}
+
+nsresult
+EphyBrowser::SetSecurityInfo (nsIRequest *aRequest)
+{
+#ifdef HAVE_MOZILLA_PSM
+ /* clear previous security info */
+ mSecurityInfo = nsnull;
+
+ nsCOMPtr<nsIChannel> channel (do_QueryInterface (aRequest));
+ NS_ENSURE_TRUE (channel, NS_ERROR_FAILURE);
+
+ channel->GetSecurityInfo (getter_AddRefs (mSecurityInfo));
+
+ return NS_OK;
+#else
+ return NS_ERROR_NOT_IMPLEMENTED;
+#endif
+}
+
+nsresult
+EphyBrowser::GetSecurityDescription (nsACString &aDescription)
+{
+#ifdef HAVE_MOZILLA_PSM
+ if (!mSecurityInfo) return NS_ERROR_FAILURE;
+
+ nsCOMPtr<nsITransportSecurityInfo> tsInfo (do_QueryInterface (mSecurityInfo));
+ NS_ENSURE_TRUE (tsInfo, NS_ERROR_FAILURE);
+
+ nsresult rv;
+ PRUnichar *tooltip = nsnull;
+ rv = tsInfo->GetShortSecurityDescription (&tooltip);
+ NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && tooltip, NS_ERROR_FAILURE);
+
+ NS_UTF16ToCString (nsEmbedString (tooltip),
+ NS_CSTRING_ENCODING_UTF8, aDescription);
+ if (tooltip) nsMemory::Free (tooltip);
+
+ return NS_OK;
+#else
+ return NS_ERROR_NOT_IMPLEMENTED;
+#endif
+}
diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h
index d5bacb97d..9d3cd8979 100644
--- a/embed/mozilla/EphyBrowser.h
+++ b/embed/mozilla/EphyBrowser.h
@@ -33,6 +33,7 @@
#include <nsIDOMDocument.h>
#include <nsIDOMWindow.h>
#include <nsIPrintSettings.h>
+#include <nsIRequest.h>
#ifdef ALLOW_PRIVATE_API
#include <nsIDocShell.h>
@@ -126,12 +127,16 @@ public:
nsresult GetHasModifiedForms (PRBool *modified);
+ nsresult SetSecurityInfo (nsIRequest *aRequest);
+ nsresult GetSecurityDescription (nsACString &aDescription);
+
nsCOMPtr<nsIWebBrowser> mWebBrowser;
private:
nsCOMPtr<nsIDOMDocument> mTargetDocument;
nsCOMPtr<nsIDOMEventReceiver> mEventReceiver;
nsCOMPtr<nsIDOMWindow> mDOMWindow;
+ nsCOMPtr<nsISupports> mSecurityInfo;
EphyFaviconEventListener *mFaviconEventListener;
EphyPopupBlockEventListener *mPopupBlockEventListener;
PRBool mInitialized;
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index cdbd4ea8c..6f5f84f7d 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -38,16 +38,10 @@
#include <nsEmbedString.h>
#include <nsMemory.h>
#include <nsIURI.h>
-#include <nsIChannel.h>
#include <nsIRequest.h>
#include <nsIWebProgressListener.h>
#include <nsGfxCIID.h>
-#ifdef ALLOW_PRIVATE_API
-/* not sure about this one */
-#include <nsITransportSecurityInfo.h>
-#endif
-
static void mozilla_embed_class_init (MozillaEmbedClass *klass);
static void mozilla_embed_init (MozillaEmbed *gs);
static void mozilla_embed_destroy (GtkObject *object);
@@ -92,8 +86,7 @@ typedef enum
struct MozillaEmbedPrivate
{
EphyBrowser *browser;
- nsCOMPtr<nsIRequest> request;
- gint security_state;
+ guint security_state;
MozillaEmbedLoadState load_state;
};
@@ -322,8 +315,6 @@ mozilla_embed_finalize (GObject *object)
embed->priv->browser = nsnull;
}
- embed->priv->request = nsnull;
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -644,41 +635,19 @@ impl_get_security_level (EphyEmbed *embed,
EmbedSecurityLevel *level,
char **description)
{
- nsresult result;
+ MozillaEmbedPrivate *mpriv = MOZILLA_EMBED (embed)->priv;
g_return_if_fail (description != NULL && level != NULL);
*description = NULL;
*level = STATE_IS_UNKNOWN;
- nsCOMPtr<nsIChannel> channel;
- channel = do_QueryInterface (MOZILLA_EMBED(embed)->priv->request,
- &result);
- if (NS_FAILED (result)) return;
-
- nsCOMPtr<nsISupports> info;
- result = channel->GetSecurityInfo(getter_AddRefs(info));
- if (NS_FAILED (result)) return;
-
- if (info)
- {
- nsCOMPtr<nsITransportSecurityInfo> secInfo(do_QueryInterface(info));
- if (!secInfo) return;
-
- PRUnichar *tooltip;
- result = secInfo->GetShortSecurityDescription(&tooltip);
- if (NS_FAILED (result)) return;
+ nsresult rv;
+ nsEmbedCString desc;
+ rv = mpriv->browser->GetSecurityDescription (desc);
+ if (NS_FAILED (rv)) return;
- if (tooltip)
- {
- nsEmbedCString cTooltip;
- NS_UTF16ToCString (nsEmbedString(tooltip),
- NS_CSTRING_ENCODING_UTF8, cTooltip);
- *description = g_strdup (cTooltip.get());
- nsMemory::Free (tooltip);
- }
- }
-
+ *description = g_strdup (desc.get());
*level = mozilla_embed_security_level (MOZILLA_EMBED (embed));
}
@@ -1107,13 +1076,13 @@ mozilla_embed_new_window_cb (GtkMozEmbed *embed,
static void
mozilla_embed_security_change_cb (GtkMozEmbed *embed,
- gpointer request,
- guint state,
+ gpointer requestptr,
+ guint state,
MozillaEmbed *membed)
{
EmbedSecurityLevel level;
- membed->priv->request = static_cast<nsIRequest*>(request);
+ membed->priv->browser->SetSecurityInfo (static_cast<nsIRequest*>(requestptr));
membed->priv->security_state = state;
level = mozilla_embed_security_level (membed);