summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Michael Brummer <jan.brummer@tabos.org>2020-09-29 17:51:04 +0200
committerJan-Michael Brummer <jan.brummer@tabos.org>2020-09-29 17:52:13 +0200
commitfda3de9f89c63aa530a34ffa7365439a8bfd369e (patch)
tree4bc68064051933f985c3731aaccb01a7ff893097
parent0e11f1a84fef660fc9c4e10a97d74db1630837cd (diff)
downloadepiphany-fda3de9f89c63aa530a34ffa7365439a8bfd369e.tar.gz
Add enable_gsb option to active safe browising feature
In case we cannot provide a gsb api key, we should disable the service entirely and hide the config option in preferences window.
-rw-r--r--lib/safe-browsing/ephy-gsb-service.c4
-rw-r--r--meson.build1
-rw-r--r--meson_options.txt7
-rw-r--r--src/preferences/prefs-privacy-page.c5
-rw-r--r--src/resources/gtk/prefs-privacy-page.ui2
5 files changed, 18 insertions, 1 deletions
diff --git a/lib/safe-browsing/ephy-gsb-service.c b/lib/safe-browsing/ephy-gsb-service.c
index 98d23d3fa..795049a3f 100644
--- a/lib/safe-browsing/ephy-gsb-service.c
+++ b/lib/safe-browsing/ephy-gsb-service.c
@@ -475,6 +475,7 @@ EphyGSBService *
ephy_gsb_service_new (const char *api_key,
const char *db_path)
{
+#ifdef ENABLE_GSB
EphyGSBService *service;
EphyGSBStorage *storage;
@@ -486,6 +487,9 @@ ephy_gsb_service_new (const char *api_key,
g_object_unref (storage);
return service;
+#else
+ return NULL;
+#endif
}
static void
diff --git a/meson.build b/meson.build
index 977b49d8c..9160738bd 100644
--- a/meson.build
+++ b/meson.build
@@ -72,6 +72,7 @@ conf.set_quoted('GSB_API_KEY', gsb_api_key)
if gsb_api_key != ''
message('GSB API Key provided')
endif
+conf.set10('ENABLE_GSB', get_option('enable_gsb'))
config_h = declare_dependency(
sources: vcs_tag(
diff --git a/meson_options.txt b/meson_options.txt
index 43e58e2a0..7f3648781 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -28,9 +28,16 @@ option('unit_tests',
description: 'Enable unit tests'
)
+option('enable_gsb',
+ type: 'boolean',
+ value: false,
+ description: 'Enable Google Safe Browsing support'
+)
+
option('gsb_api_key',
type: 'string',
value: '',
description: 'The API key used to access the Google Safe Browsing API v4'
)
+
diff --git a/src/preferences/prefs-privacy-page.c b/src/preferences/prefs-privacy-page.c
index b339b024e..a5fc7d98c 100644
--- a/src/preferences/prefs-privacy-page.c
+++ b/src/preferences/prefs-privacy-page.c
@@ -20,6 +20,7 @@
* along with Epiphany. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "config.h"
#include "prefs-privacy-page.h"
#include "ephy-settings.h"
@@ -36,6 +37,7 @@ struct _PrefsPrivacyPage {
HdyPreferencesPage parent_instance;
/* Web Safety */
+ GtkWidget *safe_browsing_group;
GtkWidget *enable_safe_browsing_switch;
/* Web Tracking */
@@ -79,6 +81,8 @@ setup_privacy_page (PrefsPrivacyPage *privacy_page)
"active",
G_SETTINGS_BIND_DEFAULT);
+ gtk_widget_set_visible (privacy_page->safe_browsing_group, ENABLE_GSB);
+
/* ======================================================================== */
/* ========================== Web Tracking ================================ */
/* ======================================================================== */
@@ -128,6 +132,7 @@ prefs_privacy_page_class_init (PrefsPrivacyPageClass *klass)
G_TYPE_NONE, 0);
/* Web Safety */
+ gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, safe_browsing_group);
gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, enable_safe_browsing_switch);
/* Web Tracking */
diff --git a/src/resources/gtk/prefs-privacy-page.ui b/src/resources/gtk/prefs-privacy-page.ui
index ab80bcdd1..8be4e548b 100644
--- a/src/resources/gtk/prefs-privacy-page.ui
+++ b/src/resources/gtk/prefs-privacy-page.ui
@@ -6,7 +6,7 @@
<property name="title" translatable="yes">Privacy</property>
<property name="visible">True</property>
<child>
- <object class="HdyPreferencesGroup">
+ <object class="HdyPreferencesGroup" id="safe_browsing_group">
<property name="title" translatable="yes">Web Safety</property>
<property name="visible">True</property>
<child>