[geary/wip/728002-webkit2: 35/48] Allow HTML string page loads to occur, so email bodies actually show up.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/728002-webkit2: 35/48] Allow HTML string page loads to occur, so email bodies actually show up.
- Date: Fri, 21 Oct 2016 23:46:34 +0000 (UTC)
commit faa348ce11ab727876c55ca6882df765d1f1a302
Author: Michael James Gratton <mike vee net>
Date: Mon Oct 10 11:48:04 2016 +1100
Allow HTML string page loads to occur, so email bodies actually show up.
* src/client/components/client-web-view.vala
(ClientWebView::on_decide_policy): HTML string page loads are treaded
as other navigation policy decisions, so allow them rather than
ignoring them.
src/client/components/client-web-view.vala | 45 +++++++++++++++++++--------
1 files changed, 31 insertions(+), 14 deletions(-)
---
diff --git a/src/client/components/client-web-view.vala b/src/client/components/client-web-view.vala
index 68e4fe4..21117db 100644
--- a/src/client/components/client-web-view.vala
+++ b/src/client/components/client-web-view.vala
@@ -129,6 +129,37 @@ public class ClientWebView : WebKit.WebView {
this.zoom_level -= (this.zoom_level * ZOOM_FACTOR);
}
+ // Only allow string-based page loads, and notify but ignore if
+ // the user attempts to click on a link. Deny everything else.
+ private bool on_decide_policy(WebKit.WebView view,
+ WebKit.PolicyDecision policy,
+ WebKit.PolicyDecisionType type) {
+ if (type == WebKit.PolicyDecisionType.NAVIGATION_ACTION) {
+ WebKit.NavigationPolicyDecision nav_policy =
+ (WebKit.NavigationPolicyDecision) policy;
+ switch (nav_policy.get_navigation_type()) {
+ case WebKit.NavigationType.OTHER:
+ // HTML string load, and maybe other random things?
+ policy.use();
+ break;
+
+ case WebKit.NavigationType.LINK_CLICKED:
+ // Let the app know a user activated a link, but don't
+ // try to load it ourselves.
+ link_activated(nav_policy.request.uri);
+ policy.ignore();
+ break;
+
+ default:
+ policy.ignore();
+ break;
+ }
+ } else {
+ policy.ignore();
+ }
+ return Gdk.EVENT_STOP;
+ }
+
private void on_resource_load_started(WebKit.WebView view,
WebKit.WebResource resource,
WebKit.URIRequest request) {
@@ -151,20 +182,6 @@ public class ClientWebView : WebKit.WebView {
request.set_uri(resp_uri);
}
- private bool on_decide_policy(WebKit.WebView view,
- WebKit.PolicyDecision policy,
- WebKit.PolicyDecisionType type) {
- policy.ignore();
- if (type == WebKit.PolicyDecisionType.NAVIGATION_ACTION) {
- WebKit.NavigationPolicyDecision nav_policy =
- (WebKit.NavigationPolicyDecision) policy;
- if (nav_policy.navigation_action.is_user_gesture()) {
- link_activated(nav_policy.request.uri);
- }
- }
- return true;
- }
-
private bool on_scroll_event(Gdk.EventScroll event) {
if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0) {
double dir = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]