js: Add support for parental controls filtering to the desktop
Filter the apps shown on the desktop and in search results according to whether they are blacklisted by the user’s parental controls. This supports dynamically updating the filter during the user’s session. This adds an optional dependency on libmalcontent. If that’s unavailable, no parental controls filtering will occur. Signed-off-by: Philip Withnall <withnall@endlessm.com> https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/465
This commit is contained in:

committed by
Florian Müllner

parent
b82039e324
commit
3e5b90dbba
@ -10,6 +10,7 @@ const GrabHelper = imports.ui.grabHelper;
|
||||
const IconGrid = imports.ui.iconGrid;
|
||||
const Main = imports.ui.main;
|
||||
const PageIndicators = imports.ui.pageIndicators;
|
||||
const ParentalControlsManager = imports.misc.parentalControlsManager;
|
||||
const PopupMenu = imports.ui.popupMenu;
|
||||
const Search = imports.ui.search;
|
||||
const SwipeTracker = imports.ui.swipeTracker;
|
||||
@ -161,6 +162,12 @@ var BaseAppView = GObject.registerClass({
|
||||
this._animateLaterId = 0;
|
||||
this._viewLoadedHandlerId = 0;
|
||||
this._viewIsReady = false;
|
||||
|
||||
// Filter the apps through the user’s parental controls.
|
||||
this._parentalControlsManager = ParentalControlsManager.getDefault();
|
||||
this._parentalControlsManager.connect('app-filter-changed', () => {
|
||||
this._redisplay();
|
||||
});
|
||||
}
|
||||
|
||||
_childFocused(_actor) {
|
||||
@ -514,7 +521,7 @@ var AllView = GObject.registerClass({
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return appInfo.should_show();
|
||||
return this._parentalControlsManager.shouldShowApp(appInfo);
|
||||
});
|
||||
|
||||
let apps = this._appInfoList.map(app => app.get_id());
|
||||
@ -1004,7 +1011,7 @@ class FrequentView extends BaseAppView {
|
||||
let favoritesWritable = global.settings.is_writable('favorite-apps');
|
||||
|
||||
for (let i = 0; i < mostUsed.length; i++) {
|
||||
if (!mostUsed[i].get_app_info().should_show())
|
||||
if (!this._parentalControlsManager.shouldShowApp(mostUsed[i].get_app_info()))
|
||||
continue;
|
||||
let appIcon = this._items.get(mostUsed[i].get_id());
|
||||
if (!appIcon) {
|
||||
@ -1250,6 +1257,8 @@ var AppSearchProvider = class AppSearchProvider {
|
||||
this.canLaunchSearch = false;
|
||||
|
||||
this._systemActions = new SystemActions.getDefault();
|
||||
|
||||
this._parentalControlsManager = ParentalControlsManager.getDefault();
|
||||
}
|
||||
|
||||
getResultMetas(apps, callback) {
|
||||
@ -1284,14 +1293,27 @@ var AppSearchProvider = class AppSearchProvider {
|
||||
}
|
||||
|
||||
getInitialResultSet(terms, callback, _cancellable) {
|
||||
// Defer until the parental controls manager is initialised, so the
|
||||
// results can be filtered correctly.
|
||||
if (!this._parentalControlsManager.initialized) {
|
||||
let initializedId = this._parentalControlsManager.connect('app-filter-changed', () => {
|
||||
if (this._parentalControlsManager.initialized) {
|
||||
this._parentalControlsManager.disconnect(initializedId);
|
||||
this.getInitialResultSet(terms, callback, _cancellable);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let query = terms.join(' ');
|
||||
let groups = Shell.AppSystem.search(query);
|
||||
let usage = Shell.AppUsage.get_default();
|
||||
let results = [];
|
||||
|
||||
groups.forEach(group => {
|
||||
group = group.filter(appID => {
|
||||
const app = this._appSys.lookup_app(appID);
|
||||
return app && app.app_info.should_show();
|
||||
return app && this._parentalControlsManager.shouldShowApp(app.app_info);
|
||||
});
|
||||
results = results.concat(group.sort(
|
||||
(a, b) => usage.compare(a, b)
|
||||
@ -1430,7 +1452,7 @@ class FolderView extends BaseAppView {
|
||||
if (!app)
|
||||
return;
|
||||
|
||||
if (!app.get_app_info().should_show())
|
||||
if (!this._parentalControlsManager.shouldShowApp(app.get_app_info()))
|
||||
return;
|
||||
|
||||
if (apps.some(appIcon => appIcon.id == appId))
|
||||
|
@ -46,6 +46,7 @@ const XdndHandler = imports.ui.xdndHandler;
|
||||
const KbdA11yDialog = imports.ui.kbdA11yDialog;
|
||||
const LocatePointer = imports.ui.locatePointer;
|
||||
const PointerA11yTimeout = imports.ui.pointerA11yTimeout;
|
||||
const ParentalControlsManager = imports.misc.parentalControlsManager;
|
||||
|
||||
const A11Y_SCHEMA = 'org.gnome.desktop.a11y.keyboard';
|
||||
const STICKY_KEYS_ENABLE = 'stickykeys-enable';
|
||||
@ -140,6 +141,10 @@ function start() {
|
||||
sessionMode.connect('updated', _sessionUpdated);
|
||||
|
||||
St.Settings.get().connect('notify::gtk-theme', _loadDefaultStylesheet);
|
||||
|
||||
// Initialize ParentalControlsManager before the UI
|
||||
ParentalControlsManager.getDefault();
|
||||
|
||||
_initializeUI();
|
||||
|
||||
shellAccessDialogDBusService = new AccessDialog.AccessDialogDBus();
|
||||
|
Reference in New Issue
Block a user