[gnome-shell/T29763: 120/249] search: Hide search providers which are blacklisted by parental controls



commit 33794325512889ba4cdf09ecc5c464aed0908a9d
Author: Philip Withnall <withnall endlessm com>
Date:   Thu Jan 24 16:56:42 2019 +0000

    search: Hide search providers which are blacklisted by parental controls
    
    If a search provider is installed by an app which is blacklisted for the
    current user by their parental controls, don’t show it or results for
    it.
    
    Currently, this only filters ‘remote’ (not built-in to the shell) search
    providers. This seems fine for now; in future it could be expanded to
    also filter built-in search providers, if any of them end up needing to
    be filtered.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
     * 2020-03-23:
          + Partially squash with bb0fcec82
    
    https://phabricator.endlessm.com/T25079

 js/ui/search.js | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
---
diff --git a/js/ui/search.js b/js/ui/search.js
index 3aca685684..3358da8f77 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -7,6 +7,7 @@ const AppDisplay = imports.ui.appDisplay;
 const IconGrid = imports.ui.iconGrid;
 const InternetSearch = imports.ui.internetSearch;
 const Main = imports.ui.main;
+const ParentalControlsManager = imports.misc.parentalControlsManager;
 const RemoteSearch = imports.ui.remoteSearch;
 const Util = imports.misc.util;
 
@@ -451,6 +452,12 @@ var SearchResultsView = GObject.registerClass({
     _init() {
         super._init({ name: 'searchResults', vertical: true });
 
+        this._parentalControlsManager = ParentalControlsManager.getDefault();
+        this._parentalControlsManager.connect('app-filter-changed', () => {
+            this._reloadInternetProviders();
+            this._reloadRemoteProviders();
+        });
+
         let closeIcon = new St.Icon({ icon_name: 'window-close-symbolic' });
         let closeButton = new St.Button({
             name: 'searchResultsCloseButton',
@@ -548,6 +555,16 @@ var SearchResultsView = GObject.registerClass({
         return this._terms;
     }
 
+    _reloadInternetProviders() {
+        if (this._internetProvider)
+            this._unregisterProvider(this._internetProvider);
+
+        this._internetProvider = InternetSearch.getInternetSearchProvider();
+
+        if (this._internetProvider)
+            this._registerProvider(this._internetProvider);
+    }
+
     _reloadRemoteProviders() {
         let remoteProviders = this._providers.filter(p => p.isRemoteProvider);
         remoteProviders.forEach(provider => {
@@ -561,6 +578,12 @@ var SearchResultsView = GObject.registerClass({
 
     _registerProvider(provider) {
         provider.searchInProgress = false;
+
+        // Filter out unwanted providers.
+        if (provider.appInfo &&
+            !this._parentalControlsManager.shouldShowApp(provider.appInfo))
+            return;
+
         this._providers.push(provider);
         this._ensureProviderDisplay(provider);
     }


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