From 725bb34a89a5a468f20c530912695f562b3458d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Thu, 3 May 2012 23:37:07 -0300
Subject: [PATCH v3 Browse] Fix for the MIME type handling of a request SL
#3512
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
We were not returning the right value, the callback
should return True if the signal is handled, False otherwise.
And a policy decision should be done, ignore for PDF.
This fixes http://bugs.sugarlabs.org/ticket/3512
-----
v1 -> v2: fixed regression with PDF handling.
v2 -> v3: set policy decision to ignore for PDF.
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
---
browser.py | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/browser.py b/browser.py
index c0bb7bc..4fd3b1a 100644
a
|
b
|
class Browser(WebKit.WebView): |
532 | 532 | |
533 | 533 | def __mime_type_policy_cb(self, webview, frame, request, mimetype, |
534 | 534 | policy_decision): |
| 535 | """Handle downloads and PDF files.""" |
535 | 536 | if mimetype == 'application/pdf': |
536 | 537 | self.emit('open-pdf', request.get_uri()) |
537 | | return False |
538 | | elif self.can_show_mime_type(mimetype): |
| 538 | policy_decision.ignore() |
539 | 539 | return True |
540 | | else: |
| 540 | |
| 541 | elif not self.can_show_mime_type(mimetype): |
541 | 542 | policy_decision.download() |
542 | | return True |
| 543 | return True |
| 544 | |
| 545 | return False |
543 | 546 | |
544 | 547 | def __new_window_policy_cb(self, webview, webframe, request, |
545 | 548 | navigation_action, policy_decision): |