aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/EphyBrowser.cpp46
-rw-r--r--embed/mozilla/MozRegisterComponents.cpp46
2 files changed, 87 insertions, 5 deletions
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index 03076ef21..86d6b6073 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -188,15 +188,18 @@ EphyFaviconEventListener::HandleEvent(nsIDOMEvent* aDOMEvent)
/* disallow subframes to set favicon */
if (domWinAsISupports != topDomWinAsISupports) return NS_OK;
- nsCOMPtr<nsIDOM3Document> doc = do_QueryInterface (domDoc);
+ nsCOMPtr<nsIDOM3Document> doc (do_QueryInterface (domDoc));
NS_ENSURE_TRUE (doc, NS_ERROR_FAILURE);
nsEmbedString spec;
rv = doc->GetDocumentURI (spec);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ nsEmbedCString encoding;
+ mOwner->GetEncoding (encoding);
+
nsCOMPtr<nsIURI> docUri;
- EphyUtils::NewURI (getter_AddRefs(docUri), spec);
+ EphyUtils::NewURI (getter_AddRefs(docUri), spec, encoding.get());
NS_ENSURE_TRUE (docUri, NS_ERROR_FAILURE);
nsEmbedCString faviconUrl;
@@ -497,9 +500,42 @@ nsresult EphyBrowser::Init (GtkMozEmbed *mozembed)
* but we cannot get to it!
* See https://bugzilla.mozilla.org/show_bug.cgi?id=94974
*/
- mSecurityInfo = do_CreateInstance(NS_SECURE_BROWSER_UI_CONTRACTID, &rv);
- NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && mSecurityInfo, NS_ERROR_FAILURE);
- mSecurityInfo->Init (mDOMWindow);
+ /* First try GI */
+ mSecurityInfo = do_GetInterface (mWebBrowser);
+ /* Try to instantiate it under the re-registered contract ID */
+ if (!mSecurityInfo)
+ {
+ /* This will cause all security warning dialogs to be shown
+ * twice (once by this instance, and another time by nsWebBrowser's
+ * instance of nsSecurityBrowserUIImpl), but there appears to be
+ * no other way :-(
+ */
+ mSecurityInfo = do_CreateInstance("@gnome.org/project/epiphany/hacks/secure-browser-ui;1", &rv);
+ if (NS_SUCCEEDED (rv) && mSecurityInfo)
+ {
+ rv = mSecurityInfo->Init (mDOMWindow);
+ NS_ENSURE_SUCCESS (rv, rv);
+ }
+ }
+ /* Try the original contract ID */
+ if (!mSecurityInfo)
+ {
+ /* This will cause all security warning dialogs to be shown
+ * twice (once by this instance, and another time by nsWebBrowser's
+ * instance of nsSecurityBrowserUIImpl), but there appears to be
+ * no other way :-(
+ */
+ mSecurityInfo = do_CreateInstance(NS_SECURE_BROWSER_UI_CONTRACTID, &rv);
+ if (NS_SUCCEEDED (rv) && mSecurityInfo)
+ {
+ rv = mSecurityInfo->Init (mDOMWindow);
+ NS_ENSURE_SUCCESS (rv, rv);
+ }
+ }
+ if (!mSecurityInfo)
+ {
+ g_warning ("Failed to instantiate nsISecureBrowserUI!\n");
+ }
#endif
mInitialized = PR_TRUE;
diff --git a/embed/mozilla/MozRegisterComponents.cpp b/embed/mozilla/MozRegisterComponents.cpp
index 8dd86b6ee..9dba24c9b 100644
--- a/embed/mozilla/MozRegisterComponents.cpp
+++ b/embed/mozilla/MozRegisterComponents.cpp
@@ -39,6 +39,7 @@
#include "GtkNSSDialogs.h"
#include "GtkNSSKeyPairDialogs.h"
#include "GtkNSSSecurityWarningDialogs.h"
+#include <nsISecureBrowserUI.h>
#endif
#include <nsMemory.h>
@@ -185,6 +186,42 @@ static const nsModuleComponentInfo sAppComps[] = {
},
};
+#ifdef HAVE_MOZILLA_PSM
+/* 5999dfd3-571f-4fcf-964b-386879f5cded */
+#define NEW_CID { 0x5999dfd3, 0x571f, 0x4fcf, { 0x96, 0x4b, 0x38, 0x68, 0x79, 0xf5, 0xcd, 0xed } }
+
+static nsresult
+reregister_secure_browser_ui (nsIComponentManager *cm,
+ nsIComponentRegistrar *cr)
+{
+ NS_ENSURE_ARG (cm);
+ NS_ENSURE_ARG (cr);
+
+ /* Workaround as a result of:
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=94974
+ * see
+ * http://bugzilla.gnome.org/show_bug.cgi?id=164670
+ */
+
+ nsresult rv;
+ nsCOMPtr<nsIFactory> factory;
+ rv = cm->GetClassObjectByContractID (NS_SECURE_BROWSER_UI_CONTRACTID, NS_GET_IID(nsIFactory), getter_AddRefs (factory));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ nsCID *cidPtr = nsnull;
+ rv = cr->ContractIDToCID(NS_SECURE_BROWSER_UI_CONTRACTID, &cidPtr);
+ NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && cidPtr, rv);
+
+ rv = cr->UnregisterFactory (*cidPtr, factory);
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ const nsCID new_cid = NEW_CID;
+ rv = cr->RegisterFactory (new_cid, "Epiphany Secure Browser Class", "@gnome.org/project/epiphany/hacks/secure-browser-ui;1", factory);
+ nsMemory::Free (cidPtr);
+
+ return rv;
+}
+#endif /* HAVE_MOZILLA_PSM */
gboolean
mozilla_register_components (void)
@@ -236,5 +273,14 @@ mozilla_register_components (void)
}
}
+#ifdef HAVE_MOZILLA_PSM
+ /* Workaround for http://bugzilla.gnome.org/show_bug.cgi?id=164670 */
+ rv = reregister_secure_browser_ui (cm, cr);
+ if (NS_FAILED (rv))
+ {
+ g_warning ("Failed to divert the nsISecureBrowserUI implementation!\n");
+ }
+#endif /* HAVE_MOZILLA_PSM */
+
return ret;
}