Renable and update code for clicking on links in messages.

Requires GTK+ 3.12.

* src/client/conversation-viewer/conversation-message.vala
  (ConversationMessage::link_selected): Added to pass through successful
  link clicks to the message_viewer, hook it up to the web_view.
  (ConversationMessage::load_message_body): Hook up WebKit event handler
  for when links are clicked, so phishing links can be intercepted.
  (ConversationMessage::on_link_clicked_self): Use a popover to display
  phishing warning, recursively check link's offset parent's when
  calculating box position, escape link text/href before using it as
  markup.

* src/client/conversation-viewer/conversation-viewer.vala
  (ConversationViewer::add_message): Ensure unhandled mouse clicks o the
  web_view are not used to activate the message's ListBoxRow.

* ui/conversation-message.ui: Add popover (GTK+ 3.12) for phishing links.
This commit is contained in:
Michael James Gratton 2016-04-10 10:46:49 +10:00
parent b2bd231385
commit 3bf173881c
3 changed files with 219 additions and 127 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<requires lib="gtk+" version="3.12"/>
<template class="ConversationMessage" parent="GtkBox">
<property name="name">ConversationMessage</property>
<property name="visible">True</property>
@ -436,4 +436,74 @@
<widget name="date_label"/>
</widgets>
</object>
<object class="GtkPopover" id="link_popover">
<property name="can_focus">False</property>
<property name="relative_to">body_box</property>
<property name="position">bottom</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">This link appears to go to:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="good_link_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">&lt;a href="http://goodlink.com"&gt;http://goodlink.com&lt;/a&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">But actually goes to:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="bad_link_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">&lt;a href="http://badlink.com"&gt;http://badlink.com&lt;/a&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
<style>
<class name="tooltip"/>
</style>
</object>
</interface>