Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2008-06-15 02:34:54 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2008-06-15 02:34:54 (GMT)
commit20f9a0fcd51e5edc7ea5c66fb655cd028319100d (patch)
tree45f4cd39138a52699982c90d80fa7105cd6b5c6c
parent5818437129222cb7a348f8a948e6b82a6bc5dc1d (diff)
Add support for adding certificate exceptions. Same UI as firefox.
-rw-r--r--Makefile.am2
-rw-r--r--components/.gitignore1
-rw-r--r--components/Makefile.am15
-rw-r--r--components/hulahopAddCertException.idl7
-rw-r--r--components/hulahopAddCertException.js21
-rw-r--r--configure.ac3
-rw-r--r--data/Makefile.am2
-rw-r--r--data/chrome/.gitignore1
-rw-r--r--data/chrome/Makefile.am24
-rw-r--r--data/chrome/brand.properties1
-rw-r--r--data/chrome/chrome.manifest.in2
-rw-r--r--data/chrome/netError.dtd9
-rw-r--r--src/HulahopDirectoryProvider.cpp26
-rw-r--r--src/Makefile.am3
-rw-r--r--src/hulahop.cpp6
-rw-r--r--tests/test-web-view.py10
16 files changed, 125 insertions, 8 deletions
diff --git a/Makefile.am b/Makefile.am
index 4204b17..77694ea 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = data src python
+SUBDIRS = components data src python
EXTRA_DIST = COPYING
diff --git a/components/.gitignore b/components/.gitignore
new file mode 100644
index 0000000..19903b8
--- /dev/null
+++ b/components/.gitignore
@@ -0,0 +1 @@
+*.xpt
diff --git a/components/Makefile.am b/components/Makefile.am
new file mode 100644
index 0000000..23d2895
--- /dev/null
+++ b/components/Makefile.am
@@ -0,0 +1,15 @@
+xptdir = $(pkglibdir)/components
+xpt_in_files = hulahopAddCertException.idl
+xpt_DATA = $(xpt_in_files:.idl=.xpt)
+
+%.xpt: %.idl
+ $(LIBXUL_SDK_DIR)/bin/xpidl -m typelib -w -v -I $(LIBXUL_SDK_DIR)/idl -e $@ $<
+
+componentsdir = $(pkglibdir)/components
+components_DATA = hulahopAddCertException.js
+
+EXTRA_DIST = $(xpt_in_files)
+
+CLEANFILES = $(xpt_DATA)
+
+DISTCLEANFILES = $(xpt_DATA)
diff --git a/components/hulahopAddCertException.idl b/components/hulahopAddCertException.idl
new file mode 100644
index 0000000..066826a
--- /dev/null
+++ b/components/hulahopAddCertException.idl
@@ -0,0 +1,7 @@
+#include "nsISupports.idl"
+#include "nsIDOMWindow.idl"
+
+[scriptable, uuid(4117128f-0e50-4863-b7a7-40a853451cc0)]
+interface hulahopAddCertException : nsISupports {
+ void showDialog (in nsIDOMWindow aWindow);
+};
diff --git a/components/hulahopAddCertException.js b/components/hulahopAddCertException.js
new file mode 100644
index 0000000..3d1f88e
--- /dev/null
+++ b/components/hulahopAddCertException.js
@@ -0,0 +1,21 @@
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+function AddCertException() { };
+
+AddCertException.prototype = {
+ classDescription: "AddCertException XPCOM Component",
+ classID: Components.ID("{4117128f-0e50-4863-b7a7-40a853451cc0}"),
+ contractID: "@sugarlabs.org/add-cert-exception;1",
+ QueryInterface: XPCOMUtils.generateQI([Components.interfaces.hulahopAddCertException]),
+ showDialog: function(window) {
+ var params = { location : window.location.href };
+ window.openDialog('chrome://pippki/content/exceptionDialog.xul',
+ '', 'chrome,centerscreen,modal', params);
+ }
+}
+
+var components = [AddCertException];
+function NSGetModule(compMgr, fileSpec) {
+ return XPCOMUtils.generateModule(components);
+}
+
diff --git a/configure.ac b/configure.ac
index ee5fddb..2cd5928 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,10 +34,13 @@ LIBXUL_CFLAGS=`$PKG_CONFIG --cflags --define-variable=includetype=unstable libxu
AC_SUBST([LIBXUL_CFLAGS])
AC_SUBST([LIBXUL_LIBS])
AC_SUBST([LIBXUL_DIR])
+AC_SUBST([LIBXUL_SDK_DIR])
AC_OUTPUT([
Makefile
+components/Makefile
data/Makefile
+data/chrome/Makefile
src/Makefile
python/Makefile
python/config.py
diff --git a/data/Makefile.am b/data/Makefile.am
index 98d9b33..83b35fd 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS = chrome
+
hulahopdir = $(pkgdatadir)
hulahop_DATA = prefs.js
diff --git a/data/chrome/.gitignore b/data/chrome/.gitignore
new file mode 100644
index 0000000..c590bcb
--- /dev/null
+++ b/data/chrome/.gitignore
@@ -0,0 +1 @@
+chrome.manifest
diff --git a/data/chrome/Makefile.am b/data/chrome/Makefile.am
new file mode 100644
index 0000000..e38f1a2
--- /dev/null
+++ b/data/chrome/Makefile.am
@@ -0,0 +1,24 @@
+manifestdir = $(pkgdatadir)/chrome
+manifest_in_files = chrome.manifest.in
+manifest_DATA = $(manifest_in_files:.manifest.in=.manifest)
+
+%.manifest: %.manifest.in
+ @sed -e "s!@CHROMEDIR@!$(pkgdatadir)/chrome!g" $< > $@
+
+brandingdir = $(manifestdir)/branding
+branding_DATA = brand.properties
+
+globalchromedir = $(manifestdir)/global
+globalchrome_DATA = netError.dtd
+
+EXTRA_DIST = \
+ $(manifest_in_files) \
+ $(branding_in_files) \
+ $(globalchrome_DATA)
+
+CLEANFILES = \
+ $(manifest_DATA)
+
+DISTCLEANFILES = \
+ $(manifest_DATA) \
+ $(branding_DATA)
diff --git a/data/chrome/brand.properties b/data/chrome/brand.properties
new file mode 100644
index 0000000..48b6083
--- /dev/null
+++ b/data/chrome/brand.properties
@@ -0,0 +1 @@
+brandShortName=Hulahop
diff --git a/data/chrome/chrome.manifest.in b/data/chrome/chrome.manifest.in
new file mode 100644
index 0000000..eba0ee0
--- /dev/null
+++ b/data/chrome/chrome.manifest.in
@@ -0,0 +1,2 @@
+override chrome://branding/locale/brand.properties file://@CHROMEDIR@/branding/brand.properties
+override chrome://global/locale/netErrorApp.dtd file://@CHROMEDIR@/global/netError.dtd
diff --git a/data/chrome/netError.dtd b/data/chrome/netError.dtd
new file mode 100644
index 0000000..82fe3b1
--- /dev/null
+++ b/data/chrome/netError.dtd
@@ -0,0 +1,9 @@
+<!ENTITY securityOverride.linkText "Or you can add an exception…">
+<!ENTITY securityOverride.getMeOutOfHereButton "Get me out of here!">
+<!ENTITY securityOverride.exceptionButtonLabel "Add Exception…">
+
+<!ENTITY securityOverride.warningText "
+<p>You should not add an exception if you are using an internet connection that you do not trust completely or if you are not used to seeing a warning for this server.</p>
+
+<xul:button xmlns:xul='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' id='exceptionDialogButton' label='&securityOverride.exceptionButtonLabel;'/>
+">
diff --git a/src/HulahopDirectoryProvider.cpp b/src/HulahopDirectoryProvider.cpp
index 1162dbb..fb21d69 100644
--- a/src/HulahopDirectoryProvider.cpp
+++ b/src/HulahopDirectoryProvider.cpp
@@ -21,6 +21,10 @@
#include <nsAppDirectoryServiceDefs.h>
#include <nsDirectoryServiceDefs.h>
#include <nsArrayEnumerator.h>
+#include <nsIToolkitChromeRegistry.h>
+#include <nsNetUtil.h>
+#include <nsISupportsArray.h>
+#include <nsIMutableArray.h>
#include "HulahopDirectoryProvider.h"
@@ -84,7 +88,27 @@ HulahopDirectoryProvider::GetFiles(const char *aKey,
if (!strcmp(aKey, NS_XPCOM_COMPONENT_DIR_LIST)) {
rv = NS_NewArrayEnumerator(aResult, mComponentsDirs);
- }
+ } else if (!strcmp(aKey, NS_CHROME_MANIFESTS_FILE_LIST)) {
+ nsCOMPtr<nsILocalFile> manifestDir;
+ rv = NS_NewNativeLocalFile (nsDependentCString(DATA_DIR "/chrome"), PR_TRUE,
+ getter_AddRefs (manifestDir));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ nsCOMPtr<nsISupports> element (do_QueryInterface (manifestDir, &rv));
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ nsCOMPtr<nsIMutableArray> array (do_CreateInstance(NS_ARRAY_CONTRACTID));
+ if(!array)
+ return NS_ERROR_OUT_OF_MEMORY;
+ rv = array->AppendElement (manifestDir, PR_FALSE);
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ rv = array->Enumerate(aResult);
+
+ NS_ENSURE_SUCCESS (rv, rv);
+
+ rv = NS_SUCCESS_AGGREGATE_RESULT;
+ }
return rv;
}
diff --git a/src/Makefile.am b/src/Makefile.am
index 6cd5d59..573239e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,8 @@ INCLUDES = \
$(LIBXUL_CFLAGS) \
-DPLUGIN_PATH=\"$(libdir)/mozilla/plugins\" \
-DLIBXUL_DIR=\"$(LIBXUL_DIR)\" \
- -DDATA_DIR=\"$(pkgdatadir)\"
+ -DDATA_DIR=\"$(pkgdatadir)\" \
+ -DLIB_DIR=\"$(pkglibdir)\"
noinst_LTLIBRARIES = libhulahop.la
diff --git a/src/hulahop.cpp b/src/hulahop.cpp
index dbe9497..8d90c6f 100644
--- a/src/hulahop.cpp
+++ b/src/hulahop.cpp
@@ -48,6 +48,8 @@ hulahop_startup()
setup_plugin_path();
+ hulahop_add_components_path(LIB_DIR"/components");
+
nsCOMPtr<nsILocalFile> greDir;
rv = NS_NewNativeLocalFile(nsCString(LIBXUL_DIR), PR_TRUE,
getter_AddRefs(greDir));
@@ -61,8 +63,8 @@ hulahop_startup()
rv = XRE_InitEmbedding(greDir, binDir,
const_cast<HulahopDirectoryProvider *>
(&kDirectoryProvider), nsnull, 0);
- NS_ENSURE_SUCCESS(rv, FALSE);
-
+ NS_ENSURE_SUCCESS(rv, FALSE);
+
XRE_NotifyProfile();
return TRUE;
diff --git a/tests/test-web-view.py b/tests/test-web-view.py
index 63ede6b..0d3574f 100644
--- a/tests/test-web-view.py
+++ b/tests/test-web-view.py
@@ -11,8 +11,12 @@ def quit(window):
gtk.main_quit()
def entry_activate_cb(entry):
- web_view.load_uri(entry.get_text())
- web_view.grab_focus()
+ from xpcom import components
+ from xpcom.components import interfaces
+
+ cls = components.classes['@sugarlabs.org/add-cert-exception;1']
+ cert_exception = cls.createInstance(interfaces.hulahopAddCertException)
+ cert_exception.showDialog(web_view.dom_window)
window = gtk.Window()
window.set_default_size(600, 400)
@@ -26,7 +30,7 @@ vbox.pack_start(entry, False)
entry.show()
web_view = WebView()
-web_view.load_uri('http://www.gnome.org')
+web_view.load_uri('https://mozilla.org')
vbox.pack_start(web_view)
web_view.show()