From 9cac83dae9eea3074b96095be10dad37cfd0f7e1 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Thu, 06 Aug 2009 17:01:30 +0000 Subject: Able to download Data URIs #1029 (Lucian Branescu) --- diff --git a/downloadmanager.py b/downloadmanager.py index 8402b81..a3fe6d8 100644 --- a/downloadmanager.py +++ b/downloadmanager.py @@ -1,5 +1,5 @@ # Copyright (C) 2007, One Laptop Per Child -# Copyright (C) 2009, Tomeu Vizoso +# Copyright (C) 2009, Tomeu Vizoso, Lucian Branescu # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -252,6 +252,8 @@ class Download: def _get_file_name(self): if self._display_name: return self._display_name + elif self._source.scheme == 'data': + return 'Data URI' else: path = urlparse.urlparse(self._source.spec).path location, file_name = os.path.split(path) @@ -311,9 +313,12 @@ def save_link(url, text, owner_document): interfaces.nsIRequest.LOAD_BYPASS_CACHE | \ interfaces.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS - if _implements_interface(channel, interfaces.nsIHttpChannel): - channel.referrer = io_service.newURI(owner_document.documentURI, None, - None) + # HACK: when we QI for nsIHttpChannel on objects that implement + # just nsIChannel, pyxpcom gets confused trac #1029 + if uri.scheme == 'http': + if _implements_interface(channel, interfaces.nsIHttpChannel): + channel.referrer = io_service.newURI(owner_document.documentURI, + None, None) # kick off the channel with our proxy object as the listener listener = xpcom.server.WrapObject( -- cgit v0.9.1