2
* Copyright (c) 2016 elementary LLC (http://launchpad.net/capnet-assist)
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
21
public class TabbedWebView : Granite.Widgets.Tab {
22
public WebKit.WebView web_view;
23
public CertButton.Security security { get; private set; }
25
public TabbedWebView (string uri, bool load_cookies) {
26
web_view = new WebKit.WebView ();
30
setup_web_view (load_cookies);
32
web_view.insecure_content_detected.connect (() => {
33
security = CertButton.Security.MIXED_CONTENT;
36
web_view.notify["title"].connect ((view, param_spec) => {
37
label = web_view.get_title ();
40
web_view.load_changed.connect ((view, event) => {
42
case WebKit.LoadEvent.STARTED:
43
security = CertButton.Security.LOADING;
45
case WebKit.LoadEvent.COMMITTED:
51
web_view.load_uri (uri);
54
private void update_tls_info () {
56
TlsCertificateFlags cert_flags;
59
if (!web_view.get_tls_info (out cert, out cert_flags)) {
60
// The page is served over HTTP
63
// The page is served over HTTPS, if cert_flags is set then there's
64
// some problem with the certificate provided by the website.
65
is_secure = (cert_flags == 0);
69
security = CertButton.Security.SECURE;
71
security = CertButton.Security.NONE;
75
private void setup_web_view (bool load_cookies) {
77
var cookies_db_path = Path.build_path (Path.DIR_SEPARATOR_S,
78
Environment.get_user_config_dir (),
82
if (!FileUtils.test (cookies_db_path, FileTest.IS_REGULAR)) {
83
debug ("No cookies store found, not saving the cookies...\n");
87
var cookie_manager = web_view.get_context ().get_cookie_manager ();
89
cookie_manager.set_accept_policy (WebKit.CookieAcceptPolicy.ALWAYS);
90
cookie_manager.set_persistent_storage (cookies_db_path, WebKit.CookiePersistentStorage.SQLITE);