diff options
author | Lucian Branescu Mihaila <lucian.branescu@gmail.com> | 2010-07-15 21:50:22 (GMT) |
---|---|---|
committer | Lucian Branescu Mihaila <lucian.branescu@gmail.com> | 2010-07-15 21:50:22 (GMT) |
commit | 6a706e919e3d2d3ad7dcafa87086ade09f5b5aeb (patch) | |
tree | 4afe8d52fe806bc73ea96ddd4a156c407db4a79a | |
parent | f8bacfeeb40a198cd37f356ea966ae72311f78cf (diff) |
Enable downloading for unknown mime types.
-rw-r--r-- | browser.py | 11 | ||||
-rw-r--r-- | downloadmanager.py | 8 |
2 files changed, 15 insertions, 4 deletions
@@ -194,6 +194,8 @@ class Browser(webkit.WebView): self.connect('load-finished', self.__loading_finished_cb) self.connect('download-requested', self.__download_requested_cb) + self.connect('mime-type-policy-decision-requested', + self.__mime_type_policy_cb) def load_uri(self, uri): '''Load a URI. @@ -207,7 +209,14 @@ class Browser(webkit.WebView): super(Browser, self).load_uri(uri) def __download_requested_cb(self, browser, download): - user_download = downloadmanager.UserDownload(download, self._activity_p) + downloadmanager.process_download(download, self._activity_p) + return True + + def __mime_type_policy_cb(self, webview, frame, request, mimetype, + policy_decision): + if not self.can_show_mime_type(mimetype): + policy_decision.download() + return True def __loading_finished_cb(self, frame, user_data): diff --git a/downloadmanager.py b/downloadmanager.py index 2cc11dd..6b57036 100644 --- a/downloadmanager.py +++ b/downloadmanager.py @@ -251,6 +251,8 @@ class UserDownload(object): self.cancel() _active_downloads.remove(self) -def save_link(uri, title, owner_doc): - #TODO - pass +#def save_link(uri, title, mime_type=None): +# pass + +def process_download(download, activity): + user_download = UserDownload(download, activity)
\ No newline at end of file |