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



commit 88c366bf3a9a62087f8c2b0ba1d746e2d3c80350
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Jul 19 06:37:56 2020 -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                     |   65 -
 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                              |    4 -
 lib/safe-browsing/ephy-gsb-service.c         |  767 ------------
 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 --
 meson_options.txt                            |    6 -
 src/ephy-window.c                            |   70 +-
 src/preferences/prefs-privacy-page.c         |    8 -
 src/profile-migrator/ephy-profile-migrator.c |   14 +
 src/resources/gtk/prefs-privacy-page.ui      |   14 -
 tests/ephy-gsb-service-test.c                |  286 -----
 tests/meson.build                            |   13 -
 21 files changed, 24 insertions(+), 4224 deletions(-)
---
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index f4d613e89..205f9ee03 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -186,21 +186,11 @@
                        <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="b" name="enable-itp">
                        <default>true</default>
                        <summary>Enable Intelligent Tracking Prevention (ITP)</summary>
                        <description>Whether to enable Intelligent Tracking Prevention.</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 a7702860a..fb61d543d 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -55,7 +55,6 @@
 typedef struct {
   WebKitWebContext *web_context;
   EphyHistoryService *global_history_service;
-  EphyGSBService *global_gsb_service;
   EphyEncodings *encodings;
   GtkPageSetup *page_setup;
   GtkPrintSettings *print_settings;
@@ -77,7 +76,6 @@ enum {
   RESTORED_WINDOW,
   WEB_VIEW_CREATED,
   ALLOW_TLS_CERTIFICATE,
-  ALLOW_UNSAFE_BROWSING,
   PASSWORD_FORM_FOCUSED,
 
   LAST_SIGNAL
@@ -190,7 +188,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->reader_handler);
   g_clear_object (&priv->source_handler);
@@ -308,17 +305,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,
@@ -624,31 +610,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_assert (EPHY_IS_EMBED_SHELL (shell));
-
-  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
@@ -875,8 +836,6 @@ ephy_embed_shell_startup (GApplication *application)
 
   G_APPLICATION_CLASS (ephy_embed_shell_parent_class)->startup (application);
 
-  webkit_web_context_set_process_model (priv->web_context, 
WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
-
   webkit_web_context_set_sandbox_enabled (priv->web_context, TRUE);
   webkit_web_context_add_path_to_sandbox (priv->web_context, ephy_profile_dir (), TRUE);
   webkit_web_context_add_path_to_sandbox (priv->web_context, ephy_cache_dir (), TRUE);
@@ -1109,22 +1068,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
@@ -1376,12 +1319,6 @@ ephy_embed_shell_register_ucm_handler (EphyEmbedShell           *shell,
                            G_CALLBACK (web_process_extension_tls_error_page_message_received_cb),
                            shell, 0);
 
-  webkit_user_content_manager_register_script_message_handler (ucm,
-                                                               "unsafeBrowsingErrorPage");
-  g_signal_connect_object (ucm, "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 (ucm,
                                                                         "passwordFormFocused",
                                                                         priv->guid);
@@ -1439,8 +1376,6 @@ ephy_embed_shell_unregister_ucm_handler (EphyEmbedShell           *shell,
                                                                           priv->guid);
   webkit_user_content_manager_unregister_script_message_handler (ucm,
                                                                  "tlsErrorPage");
-  webkit_user_content_manager_unregister_script_message_handler (ucm,
-                                                                 "unsafeBrowsingErrorPage");
   webkit_user_content_manager_unregister_script_message_handler_in_world (ucm,
                                                                           "passwordManagerRequestSave",
                                                                           priv->guid);
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index 9464d42d4..60f136170 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"
@@ -64,7 +63,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 ec9d7b048..71d381c29 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -35,7 +35,6 @@
 #include "ephy-file-helpers.h"
 #include "ephy-file-monitor.h"
 #include "ephy-filters-manager.h"
-#include "ephy-gsb-utils.h"
 #include "ephy-history-service.h"
 #include "ephy-lib-type-builtins.h"
 #include "ephy-permissions-manager.h"
@@ -118,7 +117,6 @@ struct _EphyWebView {
   GTlsCertificate *certificate;
   GTlsCertificateFlags tls_errors;
 
-  gboolean bypass_safe_browsing;
   gboolean loading_error_page;
   char *tls_error_failing_uri;
 
@@ -647,18 +645,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
 _ephy_web_view_set_is_blank (EphyWebView *view,
                              gboolean     is_blank)
@@ -1894,95 +1880,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.svg";
-  *style = "danger";
-
-  g_free (formatted_origin);
-  g_free (first_paragraph);
-}
-
 static void
 format_no_such_file_error_page (EphyWebView  *view,
                                 char        **page_title,
@@ -2135,23 +2032,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,
@@ -2994,23 +2874,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,
@@ -3781,10 +3644,6 @@ ephy_web_view_init (EphyWebView *web_view)
   g_signal_connect_object (shell, "allow-tls-certificate",
                            G_CALLBACK (allow_tls_certificate_cb),
                            web_view, 0);
-
-  g_signal_connect_object (shell, "allow-unsafe-browsing",
-                           G_CALLBACK (allow_unsafe_browsing_cb),
-                           web_view, 0);
 }
 
 static void
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 45a58b2d3..888ab38cb 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -71,7 +71,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;
 
@@ -100,9 +99,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 05bbb2399..e2e81edc2 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -114,9 +114,7 @@ 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_ENABLE_ITP                   "enable-itp"
-#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"
@@ -144,9 +142,7 @@ 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_ENABLE_ITP,
-  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 c97910063..caa6bbea6 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 35
+#define EPHY_PROFILE_MIGRATION_VERSION 36
 #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 616e7da0a..04b5bbf8a 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -44,9 +44,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
 ]
 
@@ -74,7 +71,6 @@ libephymisc_includes = include_directories(
   '..',
   'contrib',
   'history',
-  'safe-browsing'
 )
 
 libephymisc = shared_library('ephymisc',
diff --git a/meson_options.txt b/meson_options.txt
index 512ef4079..dd9143911 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -4,12 +4,6 @@ option('developer_mode',
   description: 'Enable developer mode'
 )
 
-option('network_tests',
-  type: 'feature',
-  value: 'disabled',
-  description: 'Enable tests that require network access, if unit_tests are enabled'
-)
-
 option('tech_preview',
   type: 'boolean',
   value: false,
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 975c03fb3..23e18786e 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -37,7 +37,6 @@
 #include "ephy-file-helpers.h"
 #include "ephy-filters-manager.h"
 #include "ephy-find-toolbar.h"
-#include "ephy-gsb-utils.h"
 #include "ephy-gui.h"
 #include "ephy-header-bar.h"
 #include "ephy-link.h"
@@ -2079,10 +2078,11 @@ accept_navigation_policy_decision (EphyWindow           *window,
 }
 
 static gboolean
-decide_navigation_policy (WebKitWebView            *web_view,
-                          WebKitPolicyDecision     *decision,
-                          WebKitPolicyDecisionType  decision_type,
-                          EphyWindow               *window)
+decide_navigation (EphyWindow               *window,
+                   WebKitWebView            *web_view,
+                   WebKitPolicyDecision     *decision,
+                   WebKitPolicyDecisionType  decision_type,
+                   const char               *request_uri)
 {
   WebKitNavigationPolicyDecision *navigation_decision;
   WebKitNavigationAction *navigation_action;
@@ -2091,6 +2091,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);
@@ -2243,62 +2247,6 @@ decide_navigation_policy (WebKitWebView            *web_view,
   return accept_navigation_policy_decision (window, decision, uri);
 }
 
-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_navigation (EphyWindow               *window,
-                   WebKitWebView            *web_view,
-                   WebKitPolicyDecision     *decision,
-                   WebKitPolicyDecisionType  decision_type,
-                   const char               *request_uri)
-{
-  EphyGSBService *service;
-
-  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
 resolve_pending_decision (VerifyUrlAsyncData *async_data)
 {
diff --git a/src/preferences/prefs-privacy-page.c b/src/preferences/prefs-privacy-page.c
index a0b843979..e1123048a 100644
--- a/src/preferences/prefs-privacy-page.c
+++ b/src/preferences/prefs-privacy-page.c
@@ -38,7 +38,6 @@ struct _PrefsPrivacyPage {
   /* Web Content */
   GtkWidget *popups_allow_switch;
   GtkWidget *adblock_allow_switch;
-  GtkWidget *enable_safe_browsing_switch;
   GtkWidget *enable_itp_switch;
 
   /* Cookies */
@@ -130,12 +129,6 @@ setup_privacy_page (PrefsPrivacyPage *privacy_page)
                    "active",
                    G_SETTINGS_BIND_INVERT_BOOLEAN);
 
-  g_settings_bind (web_settings,
-                   EPHY_PREFS_WEB_ENABLE_SAFE_BROWSING,
-                   privacy_page->enable_safe_browsing_switch,
-                   "active",
-                   G_SETTINGS_BIND_DEFAULT);
-
   g_settings_bind (web_settings,
                    EPHY_PREFS_WEB_ENABLE_ITP,
                    privacy_page->enable_itp_switch,
@@ -210,7 +203,6 @@ prefs_privacy_page_class_init (PrefsPrivacyPageClass *klass)
   /* Web Content */
   gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, popups_allow_switch);
   gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, adblock_allow_switch);
-  gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, enable_safe_browsing_switch);
   gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, enable_itp_switch);
 
   /* Cookies */
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index 12512c0a9..57097dd35 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -1421,6 +1421,19 @@ next:
   }
 }
 
+static void
+migrate_gsb_db (void)
+{
+  g_autofree char *threats_db = g_build_filename (ephy_default_cache_dir (), "gsb-threats.db", NULL);
+  g_autofree char *threats_db_journal = g_build_filename (ephy_default_cache_dir (), 
"gsb-threats.db-journal", NULL);
+
+  if (g_unlink (threats_db) == -1 && errno != ENOENT)
+    g_warning ("Failed to delete %s: %s", threats_db, g_strerror (errno));
+
+  if (g_unlink (threats_db_journal) == -1 && errno != ENOENT)
+    g_warning ("Failed to delete %s: %s", threats_db_journal, g_strerror (errno));
+}
+
 static void
 migrate_nothing (void)
 {
@@ -1471,6 +1484,7 @@ const EphyProfileMigrator migrators[] = {
   /* 33 */ migrate_adblock_to_content_filters,
   /* 34 */ migrate_adblock_to_shared_cache_dir,
   /* 35 */ migrate_webapp_names,
+  /* 36 */ migrate_gsb_db
 };
 
 static gboolean
diff --git a/src/resources/gtk/prefs-privacy-page.ui b/src/resources/gtk/prefs-privacy-page.ui
index ad3980f0e..43fe9f207 100644
--- a/src/resources/gtk/prefs-privacy-page.ui
+++ b/src/resources/gtk/prefs-privacy-page.ui
@@ -40,20 +40,6 @@
             </child>
           </object>
         </child>
-        <child>
-          <object class="HdyActionRow">
-            <property name="activatable_widget">enable_safe_browsing_switch</property>
-            <property name="title" translatable="yes">Try to Block Dangerous Web_sites</property>
-            <property name="use_underline">True</property>
-            <property name="visible">True</property>
-            <child>
-              <object class="GtkSwitch" id="enable_safe_browsing_switch">
-                <property name="valign">center</property>
-                <property name="visible">True</property>
-              </object>
-            </child>
-          </object>
-        </child>
         <child>
           <object class="HdyActionRow">
             <property name="activatable_widget">enable_itp_switch</property>
diff --git a/tests/meson.build b/tests/meson.build
index f2a0ac6a9..225255483 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -186,17 +186,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]