[Sugar-devel] [PATCH v2 Browse] Fix for the MIME type handling of a request SL #3512

Manuel Quiñones manuq at laptop.org
Wed May 2 12:07:56 EDT 2012


We were not returning the right value, the callback
should return True if the signal is handled, False otherwise.

This fixes http://bugs.sugarlabs.org/ticket/3512

-----

v1 -> v2: fixed regression with PDF handling.

Signed-off-by: Manuel Quiñones <manuq at laptop.org>
---
 browser.py |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/browser.py b/browser.py
index c0bb7bc..a40cc03 100644
--- a/browser.py
+++ b/browser.py
@@ -532,14 +532,15 @@ class Browser(WebKit.WebView):
 
     def __mime_type_policy_cb(self, webview, frame, request, mimetype,
                               policy_decision):
+        """Handle downloads and PDF files."""
         if mimetype == 'application/pdf':
             self.emit('open-pdf', request.get_uri())
-            return False
-        elif self.can_show_mime_type(mimetype):
-            return True
-        else:
+
+        elif not self.can_show_mime_type(mimetype):
             policy_decision.download()
-        return True
+            return True
+
+        return False
 
     def __new_window_policy_cb(self, webview, webframe, request,
                                navigation_action, policy_decision):
-- 
1.7.7.6



More information about the Sugar-devel mailing list