Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--browser.py25
-rw-r--r--promptservice.py52
-rw-r--r--securitydialogs.py36
-rwxr-xr-xwebactivity.py4
4 files changed, 110 insertions, 7 deletions
diff --git a/browser.py b/browser.py
index 0a08b81..87251d5 100644
--- a/browser.py
+++ b/browser.py
@@ -35,6 +35,8 @@ class Browser(WebView):
cls = components.classes['@mozilla.org/embedcomp/window-watcher;1']
window_watcher = cls.getService(interfaces.nsIWindowWatcher)
window_watcher.setWindowCreator(window_creator)
+
+ self.is_chrome= False
def get_session(self):
return sessionstore.get_session(self)
@@ -60,7 +62,16 @@ class WindowCreator:
browser = popup_creator.get_embed()
if chrome_flags & interfaces.nsIWebBrowserChrome.CHROME_OPENAS_CHROME:
+ logging.debug('Creating chrome window.')
browser.is_chrome = True
+ item = browser.browser.queryInterface(interfaces.nsIDocShellTreeItem)
+ item.itemType = interfaces.nsIDocShellTreeItem.typeChromeWrapper
+ else:
+ logging.debug('Creating browser window.')
+ item = browser.browser.queryInterface(interfaces.nsIDocShellTreeItem)
+ item.itemType = interfaces.nsIDocShellTreeItem.typeContentWrapper
+
+ browser.realize()
return browser.browser.containerWindow
@@ -87,19 +98,22 @@ class _PopupCreator(gobject.GObject):
self._dialog.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
self._embed = Browser()
- self._vis_sid = self._embed.connect('map', self._map_cb)
- self._embed.show()
-
+ self._vis_sid = self._embed.connect('notify::visible', self._notify_visible_cb)
self._dialog.add(self._embed)
- def _map_cb(self, embed):
- if self._embed.type == Browser.TYPE_POPUP:
+ def _notify_visible_cb(self, embed, param):
+ self._embed.disconnect(self._vis_sid)
+
+ if self._embed.type == Browser.TYPE_POPUP or self._embed.is_chrome:
logging.debug('Show the popup')
+ self._embed.show()
self._dialog.set_transient_for(self._parent_window)
self._dialog.show()
else:
logging.debug('Open a new activity for the popup')
self._dialog.remove(self._embed)
+ self._dialog.destroy()
+ self._dialog = None
# FIXME We need a better way to handle this.
# It seem like a pretty special case though, I doubt
@@ -111,7 +125,6 @@ class _PopupCreator(gobject.GObject):
activity = WebActivity(handle, self._embed)
activity.show()
- self._embed.disconnect(self._vis_sid)
self.emit('popup-created')
def get_embed(self):
diff --git a/promptservice.py b/promptservice.py
new file mode 100644
index 0000000..5954d8b
--- /dev/null
+++ b/promptservice.py
@@ -0,0 +1,52 @@
+import logging
+
+import xpcom
+from xpcom import components
+from xpcom.components import interfaces
+from xpcom.server.factory import Factory
+
+class PromptService:
+ _com_interfaces_ = interfaces.nsIPromptService
+
+ cid = '{836a90cb-6304-44f0-97df-c29913b908b7}'
+ description = 'Sugar Prompt Service'
+
+ def __init__(self):
+ pass
+
+ def alert(self, parent, dialogTitle, text):
+ logging.debug('nsIPromptService.alert()')
+
+ def alertCheck(self, parent, dialogTitle, text, checkMsg, checkState):
+ logging.debug('nsIPromptService.alertCheck()')
+
+ def confirm(self, parent, dialogTitle, text):
+ logging.debug('nsIPromptService.confirm()')
+
+ def confirmCheck(self, parent, dialogTitle, text, checkMsg, checkState):
+ logging.debug('nsIPromptService.confirmCheck()')
+
+ def confirmEx(self, parent, dialogTitle, text, buttonFlags, button0Title,
+ button1Title, button2Title, checkMsg, checkState):
+ logging.debug('nsIPromptService.confirmEx()')
+
+ def prompt(self, parent, dialogTitle, text, value, checkMsg, checkState):
+ logging.debug('nsIPromptService.prompt()')
+
+ def promptPassword(self, parent, dialogTitle, text, password, checkMsg,
+ checkState):
+ logging.debug('nsIPromptService.promptPassword()')
+
+ def promptUsernameAndPassword(self, parent, dialogTitle, text, username,
+ password, checkMsg, checkState):
+ logging.debug('nsIPromptService.promptUsernameAndPassword()')
+
+ def select(self, parent, dialogTitle, text, count, selectList, outSelection):
+ logging.debug('nsIPromptService.select()')
+
+
+components.registrar.registerFactory(PromptService.cid,
+ PromptService.description,
+ '@mozilla.org/embedcomp/prompt-service;1',
+ Factory(PromptService))
+
diff --git a/securitydialogs.py b/securitydialogs.py
new file mode 100644
index 0000000..17670ba
--- /dev/null
+++ b/securitydialogs.py
@@ -0,0 +1,36 @@
+import logging
+
+import xpcom
+from xpcom import components
+from xpcom.components import interfaces
+from xpcom.server.factory import Factory
+
+class SecurityDialogs:
+ _com_interfaces_ = interfaces.nsIBadCertListener
+
+ cid = '{267d2fc2-1810-11dc-8314-0800200c9a66}'
+ description = 'Sugar Security Dialogs'
+
+ def __init__(self):
+ pass
+
+ def confirmCertExpired(socketInfo, cert):
+ logging.debug('UNIMPLEMENTED: SecurityDialogs.confirmCertExpired()')
+ return interfaces.nsIBadCertListener.ADD_TRUSTED_FOR_SESSION, True
+
+ def confirmMismatchDomain(socketInfo, targetURL, cert):
+ logging.debug('UNIMPLEMENTED: SecurityDialogs.confirmMismatchDomain()')
+ return interfaces.nsIBadCertListener.ADD_TRUSTED_FOR_SESSION, True
+
+ def confirmUnknownIssuer(socketInfo, cert, certAddType):
+ logging.debug('UNIMPLEMENTED: SecurityDialogs.confirmUnknownIssuer()')
+ return interfaces.nsIBadCertListener.ADD_TRUSTED_FOR_SESSION, True
+
+ def notifyCrlNextupdate(socketInfo, targetURL, cert):
+ logging.debug('UNIMPLEMENTED: SecurityDialogs.notifyCrlNextupdate()')
+
+components.registrar.registerFactory(SecurityDialogs.cid,
+ SecurityDialogs.description,
+ '@mozilla.org/nsBadCertListener;1',
+ Factory(SecurityDialogs))
+
diff --git a/webactivity.py b/webactivity.py
index f7ad9d2..c8b2c89 100755
--- a/webactivity.py
+++ b/webactivity.py
@@ -30,6 +30,8 @@ hulahop.startup(os.path.join(env.get_profile_path(), 'gecko'))
from browser import Browser
from webtoolbar import WebToolbar
import downloadmanager
+import promptservice
+import securitydialogs
_HOMEPAGE = 'http://www.google.com'
@@ -63,7 +65,7 @@ class WebActivity(activity.Activity):
if handle.uri:
self._browser.load_uri(handle.uri)
- elif not self._jobject.file_path:
+ elif not self._jobject.file_path and not browser:
# TODO: we need this hack until we extend the activity API for
# opening URIs and default docs.
self._browser.load_uri(_HOMEPAGE)