[Sugar-devel] [PATCH Browse] Handle LoadInterruptedByPolicyChange SL #3972

2012-10-01 Thread Manuel Kaufmann
This error is raised when the mimetype policy suffers a change. When
this happens __load_error_cb is called and we were showing the error
page in any case.

With this patch that case is properly handled in __load_error_cb and
the error page is not shown on the current tab. In fact, we keep the
same page where the user clicked the link in the tab.

Signed-off-by: Manuel Kaufmann humi...@gmail.com
---
 browser.py | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/browser.py b/browser.py
index fb8a985..ccdf78c 100644
--- a/browser.py
+++ b/browser.py
@@ -653,6 +653,12 @@ class Browser(WebKit.WebView):
 'url': uri,
 }
 
+# Don't show error page if the load was interrupted by policy
+# change. For example, if a file was requested for download
+if web_error.code == WebKit.PolicyError.\
+FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE:
+return True
+
 html = open(DEFAULT_ERROR_PAGE, 'r').read() % data
 web_frame.load_alternate_string(html, '', uri)
 
-- 
1.7.11.4

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Handle LoadInterruptedByPolicyChange SL #3972

2012-10-01 Thread Manuel QuiƱones
Great, is working as expected.

2012/10/1 Manuel Kaufmann humi...@gmail.com:
 This error is raised when the mimetype policy suffers a change. When
 this happens __load_error_cb is called and we were showing the error
 page in any case.

 With this patch that case is properly handled in __load_error_cb and
 the error page is not shown on the current tab. In fact, we keep the
 same page where the user clicked the link in the tab.

 Signed-off-by: Manuel Kaufmann humi...@gmail.com
 ---
  browser.py | 6 ++
  1 file changed, 6 insertions(+)

 diff --git a/browser.py b/browser.py
 index fb8a985..ccdf78c 100644
 --- a/browser.py
 +++ b/browser.py
 @@ -653,6 +653,12 @@ class Browser(WebKit.WebView):
  'url': uri,
  }

 +# Don't show error page if the load was interrupted by policy
 +# change. For example, if a file was requested for download
 +if web_error.code == WebKit.PolicyError.\
 +FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE:
 +return True
 +

Just a small improvement, I will move the added piece of code before
the data dictionary, at the beginning of the callback.

Pushed as 369e3223 .

  html = open(DEFAULT_ERROR_PAGE, 'r').read() % data
  web_frame.load_alternate_string(html, '', uri)

 --
 1.7.11.4




-- 
.. manuq ..
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel