[shotwell/shotwell-0.30] authenticator: Make it possible to click on new-window links



commit 22017d19b44c798dae84e1307cc87ae91651402e
Author: Jens Georg <mail jensge org>
Date:   Thu May 7 10:50:30 2020 +0200

    authenticator: Make it possible to click on new-window links
    
    For example Google's link to our privacy policy was not opening before

 plugins/common/WebAuthenticationPane.vala | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/plugins/common/WebAuthenticationPane.vala b/plugins/common/WebAuthenticationPane.vala
index 43afe651..fe447477 100644
--- a/plugins/common/WebAuthenticationPane.vala
+++ b/plugins/common/WebAuthenticationPane.vala
@@ -25,6 +25,24 @@ namespace Shotwell.Plugins.Common {
             this.webview.load_changed.connect (this.on_page_load_changed);
             this.webview.load_failed.connect (this.on_page_load_failed);
             this.webview.context_menu.connect ( () => { return false; });
+            this.webview.decide_policy.connect (this.on_decide_policy);
+        }
+
+        private bool on_decide_policy(WebKit.PolicyDecision decision, WebKit.PolicyDecisionType type) {
+            switch (type) {
+                case WebKit.PolicyDecisionType.NEW_WINDOW_ACTION: {
+                    var navigation = (WebKit.NavigationPolicyDecision) decision;
+                    var action = navigation.get_navigation_action();
+                    var uri = action.get_request().uri;
+                    decision.ignore();
+                    AppInfo.launch_default_for_uri_async.begin(uri, null);
+                    return true;
+                }
+                default:
+                    break;
+            }
+
+            return false;
         }
 
         public abstract void on_page_load ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]