[epiphany/mcatanzaro/unsafe-browsing] Remove safe browsing support



commit 18dfb15c3a31d82cd3677702253b2cdbf93d22a7
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sun May 26 16:14:02 2019 -0500

    Remove safe browsing support
    
    This is unfortunate, but keeping this feature is no longer possible due
    to changes in Google's terms of service.
    
    Fixes #682

 data/org.gnome.epiphany.gschema.xml          |   10 -
 embed/ephy-embed-shell.c                     |   63 -
 embed/ephy-embed-shell.h                     |    2 -
 embed/ephy-web-view.c                        |  141 ---
 embed/ephy-web-view.h                        |    4 -
 lib/ephy-prefs.h                             |    4 -
 lib/ephy-profile-utils.h                     |    4 +-
 lib/meson.build                              |    6 +-
 lib/safe-browsing/ephy-gsb-service.c         |  770 ------------
 lib/safe-browsing/ephy-gsb-service.h         |   41 -
 lib/safe-browsing/ephy-gsb-storage.c         | 1710 --------------------------
 lib/safe-browsing/ephy-gsb-storage.h         |   68 -
 lib/safe-browsing/ephy-gsb-utils.c           |  919 --------------
 lib/safe-browsing/ephy-gsb-utils.h           |   98 --
 org.gnome.Epiphany.json                      |    9 +
 src/ephy-window.c                            |   81 +-
 src/prefs-dialog.c                           |    7 -
 src/profile-migrator/ephy-profile-migrator.c |   14 +
 src/resources/gtk/prefs-dialog.ui            |    7 -
 tests/ephy-gsb-service-test.c                |  285 -----
 tests/meson.build                            |   13 -
 21 files changed, 33 insertions(+), 4223 deletions(-)
---
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index 758668cbc..2a6072fd7 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -204,16 +204,6 @@
                        <summary>Enable site-specific quirks</summary>
                        <description>Enable quirks to make specific websites work better. You might want to 
disable this setting if debugging a specific issue.</description>
                </key>
-               <key type="b" name="enable-safe-browsing">
-                       <default>true</default>
-                       <summary>Enable safe browsing</summary>
-                       <description>Whether to enable safe browsing. Safe browsing operates via Google Safe 
Browsing API v4.</description>
-               </key>
-               <key type="s" name="gsb-api-key">
-                       <default>'AIzaSyAtuURrRblYXvwCyDC5ZFq0mEw1x4VN6KA'</default>
-                       <summary>Google Safe Browsing API key</summary>
-                       <description>The API key used to access the Google Safe Browsing API v4.</description>
-               </key>
                <key type="d" name="default-zoom-level">
                        <default>1.0</default>
                        <summary>Default zoom level for new pages</summary>
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 4632065a3..aaf6a63b6 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -56,7 +56,6 @@
 typedef struct {
   WebKitWebContext *web_context;
   EphyHistoryService *global_history_service;
-  EphyGSBService *global_gsb_service;
   EphyEncodings *encodings;
   GtkPageSetup *page_setup;
   GtkPrintSettings *print_settings;
@@ -80,7 +79,6 @@ enum {
   WEB_VIEW_CREATED,
   PAGE_CREATED,
   ALLOW_TLS_CERTIFICATE,
-  ALLOW_UNSAFE_BROWSING,
   PASSWORD_FORM_FOCUSED,
 
   LAST_SIGNAL
@@ -205,7 +203,6 @@ ephy_embed_shell_dispose (GObject *object)
   g_clear_object (&priv->page_setup);
   g_clear_object (&priv->print_settings);
   g_clear_object (&priv->global_history_service);
-  g_clear_object (&priv->global_gsb_service);
   g_clear_object (&priv->about_handler);
   g_clear_object (&priv->source_handler);
   g_clear_object (&priv->user_content);
@@ -319,17 +316,6 @@ web_process_extension_tls_error_page_message_received_cb (WebKitUserContentManag
   g_signal_emit (shell, signals[ALLOW_TLS_CERTIFICATE], 0, page_id);
 }
 
-static void
-web_process_extension_unsafe_browsing_error_page_message_received_cb (WebKitUserContentManager *manager,
-                                                                      WebKitJavascriptResult   *message,
-                                                                      EphyEmbedShell           *shell)
-{
-  guint64 page_id;
-
-  page_id = jsc_value_to_double (webkit_javascript_result_get_js_value (message));
-  g_signal_emit (shell, signals[ALLOW_UNSAFE_BROWSING], 0, page_id);
-}
-
 static void
 web_process_extension_about_apps_message_received_cb (WebKitUserContentManager *manager,
                                                       WebKitJavascriptResult   *message,
@@ -801,31 +787,6 @@ ephy_embed_shell_get_global_history_service (EphyEmbedShell *shell)
   return priv->global_history_service;
 }
 
-/**
- * ephy_embed_shell_get_global_gsb_service:
- * @shell: the #EphyEmbedShell
- *
- * Return value: (transfer none): the global #EphyGSBService
- **/
-EphyGSBService *
-ephy_embed_shell_get_global_gsb_service (EphyEmbedShell *shell)
-{
-  EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
-
-  g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), NULL);
-
-  if (!priv->global_gsb_service) {
-    g_autofree char *api_key = NULL;
-    g_autofree char *db_path = NULL;
-
-    api_key = g_settings_get_string (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_GSB_API_KEY);
-    db_path = g_build_filename (ephy_default_cache_dir (), EPHY_GSB_FILE, NULL);
-    priv->global_gsb_service = ephy_gsb_service_new (api_key, db_path);
-  }
-
-  return priv->global_gsb_service;
-}
-
 /**
  * ephy_embed_shell_get_encodings:
  * @shell: the #EphyEmbedShell
@@ -1139,12 +1100,6 @@ ephy_embed_shell_startup (GApplication *application)
                            G_CALLBACK (web_process_extension_tls_error_page_message_received_cb),
                            shell, 0);
 
-  webkit_user_content_manager_register_script_message_handler (priv->user_content,
-                                                               "unsafeBrowsingErrorPage");
-  g_signal_connect_object (priv->user_content, "script-message-received::unsafeBrowsingErrorPage",
-                           G_CALLBACK (web_process_extension_unsafe_browsing_error_page_message_received_cb),
-                           shell, 0);
-
   webkit_user_content_manager_register_script_message_handler_in_world (priv->user_content,
                                                                         "passwordFormFocused",
                                                                         priv->guid);
@@ -1272,8 +1227,6 @@ ephy_embed_shell_shutdown (GApplication *application)
                                                                           priv->guid);
   webkit_user_content_manager_unregister_script_message_handler (priv->user_content,
                                                                  "tlsErrorPage");
-  webkit_user_content_manager_unregister_script_message_handler (priv->user_content,
-                                                                 "unsafeBrowsingErrorPage");
   webkit_user_content_manager_unregister_script_message_handler_in_world (priv->user_content,
                                                                           "passwordManagerRequestSave",
                                                                           priv->guid);
@@ -1452,22 +1405,6 @@ ephy_embed_shell_class_init (EphyEmbedShellClass *klass)
                   G_TYPE_NONE, 1,
                   G_TYPE_UINT64);
 
-  /**
-   * EphyEmbedShell::allow-unsafe-browsing:
-   * @shell: the #EphyEmbedShell
-   * @page_id: the identifier of the web page
-   *
-   * Emitted when the web process extension requests an exception be
-   * permitted for the unsafe browsing warning on the given page
-   */
-  signals[ALLOW_UNSAFE_BROWSING] =
-    g_signal_new ("allow-unsafe-browsing",
-                  EPHY_TYPE_EMBED_SHELL,
-                  G_SIGNAL_RUN_FIRST,
-                  0, NULL, NULL, NULL,
-                  G_TYPE_NONE, 1,
-                  G_TYPE_UINT64);
-
   /**
    * EphyEmbedShell::password-form-focused
    * @shell: the #EphyEmbedShell
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index 4d9a351b6..4073c976f 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -26,7 +26,6 @@
 
 #include "ephy-downloads-manager.h"
 #include "ephy-encodings.h"
-#include "ephy-gsb-service.h"
 #include "ephy-history-service.h"
 #include "ephy-password-manager.h"
 #include "ephy-permissions-manager.h"
@@ -62,7 +61,6 @@ const char        *ephy_embed_shell_get_guid                   (EphyEmbedShell
 WebKitWebContext  *ephy_embed_shell_get_web_context            (EphyEmbedShell   *shell);
 EphyHistoryService
                   *ephy_embed_shell_get_global_history_service (EphyEmbedShell   *shell);
-EphyGSBService    *ephy_embed_shell_get_global_gsb_service     (EphyEmbedShell   *shell);
 EphyEncodings     *ephy_embed_shell_get_encodings              (EphyEmbedShell   *shell);
 void               ephy_embed_shell_restored_window            (EphyEmbedShell   *shell);
 void               ephy_embed_shell_set_page_setup             (EphyEmbedShell   *shell,
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index ed76678a2..22ecd666c 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -34,7 +34,6 @@
 #include "ephy-file-chooser.h"
 #include "ephy-file-helpers.h"
 #include "ephy-file-monitor.h"
-#include "ephy-gsb-utils.h"
 #include "ephy-history-service.h"
 #include "ephy-lib-type-builtins.h"
 #include "ephy-permissions-manager.h"
@@ -128,7 +127,6 @@ struct _EphyWebView {
   GTlsCertificate *certificate;
   GTlsCertificateFlags tls_errors;
 
-  gboolean bypass_safe_browsing;
   gboolean loading_error_page;
   char *tls_error_failing_uri;
 
@@ -894,18 +892,6 @@ allow_tls_certificate_cb (EphyEmbedShell *shell,
   soup_uri_free (uri);
 }
 
-static void
-allow_unsafe_browsing_cb (EphyEmbedShell *shell,
-                          guint64         page_id,
-                          EphyWebView    *view)
-{
-  if (webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)) != page_id)
-    return;
-
-  ephy_web_view_set_should_bypass_safe_browsing (view, TRUE);
-  ephy_web_view_load_url (view, ephy_web_view_get_address (view));
-}
-
 static void
 page_created_cb (EphyEmbedShell               *shell,
                  guint64                       page_id,
@@ -925,10 +911,6 @@ page_created_cb (EphyEmbedShell               *shell,
   g_signal_connect_object (shell, "allow-tls-certificate",
                            G_CALLBACK (allow_tls_certificate_cb),
                            view, 0);
-
-  g_signal_connect_object (shell, "allow-unsafe-browsing",
-                           G_CALLBACK (allow_unsafe_browsing_cb),
-                           view, 0);
 }
 
 static void
@@ -2368,95 +2350,6 @@ format_tls_error_page (EphyWebView *view,
   g_free (first_paragraph);
 }
 
-static void
-format_unsafe_browsing_error_page (EphyWebView *view,
-                                   const char  *origin,
-                                   const char  *threat_type,
-                                   char       **page_title,
-                                   char       **message_title,
-                                   char       **message_body,
-                                   char       **message_details,
-                                   char       **button_label,
-                                   char       **button_action,
-                                   const char **button_accesskey,
-                                   char       **hidden_button_label,
-                                   char       **hidden_button_action,
-                                   const char **hidden_button_accesskey,
-                                   const char **icon_name,
-                                   const char **style)
-{
-  char *formatted_origin;
-  char *first_paragraph;
-
-  /* Page title when a site is flagged by Google Safe Browsing verification. */
-  *page_title = g_strdup_printf (_("Security Warning"));
-
-  /* Message title on the unsafe browsing error page. */
-  *message_title = g_strdup (_("Unsafe website detected!"));
-
-  formatted_origin = g_strdup_printf ("<strong>%s</strong>", origin);
-  /* Error details on the unsafe browsing error page.
-   * https://developers.google.com/safe-browsing/v4/usage-limits#UserWarnings
-   */
-  if (!g_strcmp0 (threat_type, GSB_THREAT_TYPE_MALWARE)) {
-    first_paragraph = g_strdup_printf (_("Visiting %s may harm your computer. This "
-                                         "page appears to contain malicious code that could "
-                                         "be downloaded to your computer without your consent."),
-                                       formatted_origin);
-    *message_details = g_strdup_printf (_("You can learn more about harmful web content "
-                                          "including viruses and other malicious code "
-                                          "and how to protect your computer at %s."),
-                                        "<a href=\"https://www.stopbadware.org/\";>"
-                                          "www.stopbadware.org"
-                                        "</a>");
-  } else if (!g_strcmp0 (threat_type, GSB_THREAT_TYPE_SOCIAL_ENGINEERING)) {
-    first_paragraph = g_strdup_printf (_("Attackers on %s may trick you into doing "
-                                         "something dangerous like installing software or "
-                                         "revealing your personal information (for example, "
-                                         "passwords, phone numbers, or credit cards)."),
-                                       formatted_origin);
-    *message_details = g_strdup_printf (_("You can find out more about social engineering "
-                                          "(phishing) at %s or from %s."),
-                                        "<a href=\"https://support.google.com/webmasters/answer/6350487\";>"
-                                          "Social Engineering (Phishing and Deceptive Sites)"
-                                        "</a>",
-                                        "<a href=\"https://www.antiphishing.org/\";>"
-                                          "www.antiphishing.org"
-                                        "</a>");
-  } else {
-    first_paragraph = g_strdup_printf (_("%s may contain harmful programs. Attackers might "
-                                         "attempt to trick you into installing programs that "
-                                         "harm your browsing experience (for example, by changing "
-                                         "your homepage or showing extra ads on sites you visit)."),
-                                       formatted_origin);
-    *message_details = g_strdup_printf (_("You can learn more about unwanted software at %s."),
-                                        "<a 
href=\"https://www.google.com/about/unwanted-software-policy.html\";>"
-                                          "Unwanted Software Policy"
-                                        "</a>");
-  }
-
-  *message_body = g_strdup_printf ("<p>%s</p>", first_paragraph);
-
-  /* The button on unsafe browsing error page. DO NOT ADD MNEMONICS HERE. */
-  *button_label = g_strdup (_("Go Back"));
-  *button_action = g_strdup ("window.history.back();");
-  /* Mnemonic for the Go Back button on the unsafe browsing error page. */
-  *button_accesskey = C_("back-access-key", "B");
-
-  /* The hidden button on the unsafe browsing error page. Do not add mnemonics here. */
-  *hidden_button_label = g_strdup (_("Accept Risk and Proceed"));
-  *hidden_button_action = g_strdup_printf 
("window.webkit.messageHandlers.unsafeBrowsingErrorPage.postMessage(%"G_GUINT64_FORMAT ");",
-                                           webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)));
-  /* Mnemonic for the Accept Risk and Proceed button on the unsafe browsing error page. */
-  *hidden_button_accesskey = C_("proceed-anyway-access-key", "P");
-
-  *icon_name = "security-high-symbolic.png";
-  *style = "danger";
-
-  g_free (formatted_origin);
-  g_free (first_paragraph);
-}
-
 static void
 format_no_such_file_error_page (EphyWebView  *view,
                                 char        **page_title,
@@ -2609,23 +2502,6 @@ ephy_web_view_load_error_page (EphyWebView         *view,
                              &icon_name,
                              &style);
       break;
-    case EPHY_WEB_VIEW_ERROR_UNSAFE_BROWSING:
-      format_unsafe_browsing_error_page (view,
-                                         origin,
-                                         user_data,
-                                         &page_title,
-                                         &msg_title,
-                                         &msg_body,
-                                         &msg_details,
-                                         &button_label,
-                                         &button_action,
-                                         &button_accesskey,
-                                         &hidden_button_label,
-                                         &hidden_button_action,
-                                         &hidden_button_accesskey,
-                                         &icon_name,
-                                         &style);
-      break;
     case EPHY_WEB_VIEW_ERROR_NO_SUCH_FILE:
       format_no_such_file_error_page (view,
                                       &page_title,
@@ -3359,23 +3235,6 @@ ephy_web_view_set_typed_address (EphyWebView *view,
   g_object_notify_by_pspec (G_OBJECT (view), obj_properties[PROP_TYPED_ADDRESS]);
 }
 
-gboolean
-ephy_web_view_get_should_bypass_safe_browsing (EphyWebView *view)
-{
-  g_assert (EPHY_IS_WEB_VIEW (view));
-
-  return view->bypass_safe_browsing;
-}
-
-void
-ephy_web_view_set_should_bypass_safe_browsing (EphyWebView *view,
-                                               gboolean     bypass_safe_browsing)
-{
-  g_assert (EPHY_IS_WEB_VIEW (view));
-
-  view->bypass_safe_browsing = bypass_safe_browsing;
-}
-
 static void
 has_modified_forms_cb (WebKitWebView *view,
                        GAsyncResult  *result,
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 751166547..c926cc1ac 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -68,7 +68,6 @@ typedef enum {
   EPHY_WEB_VIEW_ERROR_PAGE_CRASH,
   EPHY_WEB_VIEW_ERROR_PROCESS_CRASH,
   EPHY_WEB_VIEW_ERROR_INVALID_TLS_CERTIFICATE,
-  EPHY_WEB_VIEW_ERROR_UNSAFE_BROWSING,
   EPHY_WEB_VIEW_ERROR_NO_SUCH_FILE,
 } EphyWebViewErrorPage;
 
@@ -97,9 +96,6 @@ void                       ephy_web_view_set_security_level       (EphyWebView
 const char *               ephy_web_view_get_typed_address        (EphyWebView               *view);
 void                       ephy_web_view_set_typed_address        (EphyWebView               *view,
                                                                    const char                *address);
-gboolean            ephy_web_view_get_should_bypass_safe_browsing (EphyWebView               *view);
-void                ephy_web_view_set_should_bypass_safe_browsing (EphyWebView               *view,
-                                                                   gboolean                   
bypass_safe_browsing);
 gboolean                   ephy_web_view_get_is_blank             (EphyWebView               *view);
 gboolean                   ephy_web_view_is_overview              (EphyWebView               *view);
 void                       ephy_web_view_has_modified_forms       (EphyWebView               *view,
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 34cadfcf1..540fa5e9d 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -117,8 +117,6 @@ static const char * const ephy_prefs_state_schema[] = {
 #define EPHY_PREFS_WEB_ENABLE_ADBLOCK               "enable-adblock"
 #define EPHY_PREFS_WEB_REMEMBER_PASSWORDS           "remember-passwords"
 #define EPHY_PREFS_WEB_ENABLE_SITE_SPECIFIC_QUIRKS  "enable-site-specific-quirks"
-#define EPHY_PREFS_WEB_ENABLE_SAFE_BROWSING         "enable-safe-browsing"
-#define EPHY_PREFS_WEB_GSB_API_KEY                  "gsb-api-key"
 #define EPHY_PREFS_WEB_DEFAULT_ZOOM_LEVEL           "default-zoom-level"
 #define EPHY_PREFS_WEB_ENABLE_AUTOSEARCH            "enable-autosearch"
 #define EPHY_PREFS_WEB_ENABLE_MOUSE_GESTURES        "enable-mouse-gestures"
@@ -148,8 +146,6 @@ static const char * const ephy_prefs_web_schema[] = {
   EPHY_PREFS_WEB_ENABLE_ADBLOCK,
   EPHY_PREFS_WEB_REMEMBER_PASSWORDS,
   EPHY_PREFS_WEB_ENABLE_SITE_SPECIFIC_QUIRKS,
-  EPHY_PREFS_WEB_ENABLE_SAFE_BROWSING,
-  EPHY_PREFS_WEB_GSB_API_KEY,
   EPHY_PREFS_WEB_DEFAULT_ZOOM_LEVEL,
   EPHY_PREFS_WEB_ENABLE_AUTOSEARCH,
   EPHY_PREFS_WEB_ENABLE_MOUSE_GESTURES,
diff --git a/lib/ephy-profile-utils.h b/lib/ephy-profile-utils.h
index f64f324f5..45fab557d 100644
--- a/lib/ephy-profile-utils.h
+++ b/lib/ephy-profile-utils.h
@@ -24,7 +24,7 @@
 
 G_BEGIN_DECLS
 
-#define EPHY_PROFILE_MIGRATION_VERSION 32
+#define EPHY_PROFILE_MIGRATION_VERSION 33
 #define EPHY_INSECURE_PASSWORDS_MIGRATION_VERSION 11
 #define EPHY_FIREFOX_SYNC_PASSWORDS_MIGRATION_VERSION 19
 #define EPHY_TARGET_ORIGIN_MIGRATION_VERSION 21
@@ -33,8 +33,6 @@ G_BEGIN_DECLS
 
 #define EPHY_BOOKMARKS_FILE     "bookmarks.gvdb"
 #define EPHY_HISTORY_FILE       "ephy-history.db"
-/* Threat list database for Google Safe Browsing. */
-#define EPHY_GSB_FILE           "gsb-threats.db"
 
 int ephy_profile_utils_get_migration_version (void);
 int ephy_profile_utils_get_migration_version_for_profile_dir (const char *profile_directory);
diff --git a/lib/meson.build b/lib/meson.build
index 0bef938f2..a9b7dbed3 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -48,9 +48,6 @@ libephymisc_sources = [
   'history/ephy-history-service-urls-table.c',
   'history/ephy-history-service-visits-table.c',
   'history/ephy-history-types.c',
-  'safe-browsing/ephy-gsb-service.c',
-  'safe-browsing/ephy-gsb-storage.c',
-  'safe-browsing/ephy-gsb-utils.c',
   enums
 ]
 
@@ -77,8 +74,7 @@ libephymisc_includes = include_directories(
   '..',
   'contrib',
   'contrib/gvdb',
-  'history',
-  'safe-browsing'
+  'history'
 )
 
 libephymisc = shared_library('ephymisc',
diff --git a/org.gnome.Epiphany.json b/org.gnome.Epiphany.json
index c37534b6a..85da50773 100644
--- a/org.gnome.Epiphany.json
+++ b/org.gnome.Epiphany.json
@@ -65,6 +65,15 @@
                 }
             ]
         },
+        {
+            "name" : "fdk-aac",
+            "sources" : [
+                {
+                    "type" : "git",
+                    "url" : "https://github.com/mstorsjo/fdk-aac.git";
+                }
+            ]
+        },
         {
             "name" : "epiphany",
             "config-opts" : [
diff --git a/src/ephy-window.c b/src/ephy-window.c
index e94e0363d..ca927cd88 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -35,7 +35,6 @@
 #include "ephy-embed-utils.h"
 #include "ephy-file-helpers.h"
 #include "ephy-find-toolbar.h"
-#include "ephy-gsb-utils.h"
 #include "ephy-gui.h"
 #include "ephy-header-bar.h"
 #include "ephy-link.h"
@@ -2014,10 +2013,10 @@ verify_url_async_data_free (VerifyUrlAsyncData *data)
 }
 
 static gboolean
-decide_navigation_policy (WebKitWebView            *web_view,
-                          WebKitPolicyDecision     *decision,
-                          WebKitPolicyDecisionType  decision_type,
-                          EphyWindow               *window)
+decide_policy_cb (WebKitWebView           *web_view,
+                  WebKitPolicyDecision    *decision,
+                  WebKitPolicyDecisionType decision_type,
+                  EphyWindow              *window)
 {
   WebKitNavigationPolicyDecision *navigation_decision;
   WebKitNavigationAction *navigation_action;
@@ -2026,6 +2025,10 @@ decide_navigation_policy (WebKitWebView            *web_view,
   const char *uri;
   EphyEmbed *embed;
 
+  if (decision_type != WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION &&
+      decision_type != WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION)
+    return FALSE;
+
   g_assert (WEBKIT_IS_WEB_VIEW (web_view));
   g_assert (WEBKIT_IS_NAVIGATION_POLICY_DECISION (decision));
   g_assert (decision_type != WEBKIT_POLICY_DECISION_TYPE_RESPONSE);
@@ -2173,74 +2176,6 @@ decide_navigation_policy (WebKitWebView            *web_view,
   return FALSE;
 }
 
-static void
-verify_url_cb (EphyGSBService     *service,
-               GAsyncResult       *result,
-               VerifyUrlAsyncData *data)
-{
-  GList *threats = ephy_gsb_service_verify_url_finish (service, result);
-
-  if (threats) {
-    webkit_policy_decision_ignore (data->decision);
-
-    /* Very rarely there are URLs that pose multiple types of threats.
-     * However, inform the user only about the first threat type.
-     */
-    ephy_web_view_load_error_page (EPHY_WEB_VIEW (data->web_view),
-                                   data->request_uri,
-                                   EPHY_WEB_VIEW_ERROR_UNSAFE_BROWSING,
-                                   NULL, threats->data);
-
-    g_list_free_full (threats, g_free);
-  } else {
-    decide_navigation_policy (data->web_view, data->decision,
-                              data->decision_type, data->window);
-  }
-
-  verify_url_async_data_free (data);
-}
-
-static gboolean
-decide_policy_cb (WebKitWebView           *web_view,
-                  WebKitPolicyDecision    *decision,
-                  WebKitPolicyDecisionType decision_type,
-                  EphyWindow              *window)
-{
-  EphyGSBService *service;
-  WebKitNavigationPolicyDecision *navigation_decision;
-  WebKitNavigationAction *navigation_action;
-  WebKitURIRequest *request;
-  const char *request_uri;
-
-  if (decision_type != WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION &&
-      decision_type != WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION)
-    return FALSE;
-
-  navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
-  navigation_action = webkit_navigation_policy_decision_get_navigation_action (navigation_decision);
-  request = webkit_navigation_action_get_request (navigation_action);
-  request_uri = webkit_uri_request_get_uri (request);
-
-  if (g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_SAFE_BROWSING)) {
-    if (ephy_web_view_get_should_bypass_safe_browsing (EPHY_WEB_VIEW (web_view))) {
-      /* This means the user has decided to proceed to an unsafe website. */
-      ephy_web_view_set_should_bypass_safe_browsing (EPHY_WEB_VIEW (web_view), FALSE);
-      return decide_navigation_policy (web_view, decision, decision_type, window);
-    }
-
-    service = ephy_embed_shell_get_global_gsb_service (ephy_embed_shell_get_default ());
-    ephy_gsb_service_verify_url (service, request_uri,
-                                 (GAsyncReadyCallback)verify_url_cb,
-                                 /* Note: this refs the policy decision, so we can complete it 
asynchronously. */
-                                 verify_url_async_data_new (window, web_view,
-                                                            decision, decision_type,
-                                                            request_uri));
-    return TRUE;
-  }
-
-  return decide_navigation_policy (web_view, decision, decision_type, window);
-}
-
 static void
 progress_update (WebKitWebView *web_view,
                  GParamSpec    *pspec,
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index f7d3ea37e..2234c560d 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -94,7 +94,6 @@ struct _PrefsDialog {
   GtkWidget *popups_allow_checkbutton;
   GtkWidget *adblock_allow_checkbutton;
   GtkWidget *enable_plugins_checkbutton;
-  GtkWidget *enable_safe_browsing_checkbutton;
   GtkWidget *enable_smooth_scrolling_checkbutton;
   GtkWidget *ask_on_download_checkbutton;
   GtkWidget *start_in_incognito_mode_checkbutton;
@@ -989,7 +988,6 @@ prefs_dialog_class_init (PrefsDialogClass *klass)
   gtk_widget_class_bind_template_child (widget_class, PrefsDialog, restore_session_checkbutton);
   gtk_widget_class_bind_template_child (widget_class, PrefsDialog, popups_allow_checkbutton);
   gtk_widget_class_bind_template_child (widget_class, PrefsDialog, adblock_allow_checkbutton);
-  gtk_widget_class_bind_template_child (widget_class, PrefsDialog, enable_safe_browsing_checkbutton);
   gtk_widget_class_bind_template_child (widget_class, PrefsDialog, enable_smooth_scrolling_checkbutton);
   gtk_widget_class_bind_template_child (widget_class, PrefsDialog, download_button_hbox);
   gtk_widget_class_bind_template_child (widget_class, PrefsDialog, download_button_label);
@@ -1998,11 +1996,6 @@ setup_general_page (PrefsDialog *dialog)
                    dialog->popups_allow_checkbutton,
                    "active",
                    G_SETTINGS_BIND_INVERT_BOOLEAN);
-  g_settings_bind (web_settings,
-                   EPHY_PREFS_WEB_ENABLE_SAFE_BROWSING,
-                   dialog->enable_safe_browsing_checkbutton,
-                   "active",
-                   G_SETTINGS_BIND_DEFAULT);
 
   g_settings_bind (web_settings,
                    EPHY_PREFS_WEB_ENABLE_ADBLOCK,
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index 5ba3fe24e..450d1f1e1 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -1320,6 +1320,19 @@ migrate_webapps_harder (void)
   }
 }
 
+static void
+migrate_gsb_db (void)
+{
+  g_autofree char *threats_db = g_build_filename (ephy_profile_dir (), "gsb-threats.db");
+  g_autofree char *threats_db_journal = g_build_filename (ephy_profile_dir (), "gsb-threats.db-journal");
+
+  if (g_unlink (threats_db) == -1)
+    g_warning ("Failed to delete %s: %s", threats_db, g_strerror (errno));
+
+  if (g_unlink (threats_db_journal) == -1)
+    g_warning ("Failed to delete %s: %s", threats_db_journal, g_strerror (errno));
+}
+
 static void
 migrate_nothing (void)
 {
@@ -1366,6 +1379,7 @@ const EphyProfileMigrator migrators[] = {
   /* 30 */ migrate_profile_directories,
   /* 31 */ migrate_web_extension_config_dir,
   /* 32 */ migrate_webapps_harder,
+  /* 33 */ migrate_gsb_db
 };
 
 static gboolean
diff --git a/src/resources/gtk/prefs-dialog.ui b/src/resources/gtk/prefs-dialog.ui
index a6c6b1e60..b792fbe4f 100644
--- a/src/resources/gtk/prefs-dialog.ui
+++ b/src/resources/gtk/prefs-dialog.ui
@@ -416,13 +416,6 @@
                             <property name="use-underline">True</property>
                           </object>
                         </child>
-                        <child>
-                          <object class="GtkCheckButton" id="enable_safe_browsing_checkbutton">
-                            <property name="label" translatable="yes">Try to block dangerous 
web_sites</property>
-                            <property name="visible">True</property>
-                            <property name="use-underline">True</property>
-                          </object>
-                        </child>
                       </object>
                     </child>
                   </object>
diff --git a/tests/meson.build b/tests/meson.build
index a6572b721..fb9a6c105 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -185,17 +185,4 @@ if get_option('unit_tests').enabled()
   #      web_view_test,
   #      env: envs
   # )
-
-  if get_option('network_tests').enabled()
-    gsb_service_test = executable('test-ephy-gsb-service',
-      'ephy-gsb-service-test.c',
-      dependencies: ephymain_dep,
-      c_args: test_cargs,
-    )
-    test('GSB service test',
-         gsb_service_test,
-         env: envs,
-         timeout: 90 # slow!
-    )
-  endif
 endif


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