[gnome-shell/T29763: 2/249] Don't allow endless mode extension to update



commit 01700c95b58cfa34dfada6d6e74cf3842d69b0a2
Author: Ubuntu Developers <ubuntu-devel-discuss lists ubuntu com>
Date:   Wed Jun 20 19:22:06 2018 +0200

    Don't allow endless mode extension to update
    
    Ensure that no update is proposed or loaded if sideloaded (always
    prefer system version) on the ubuntu session.
    
    We want to ensure that the default code running is going through
    our QA and security team process than being loaded from a 3rd
    party website.
    
    Also, that will enable us to upload newer versions on GNOME
    extension website while still letting older Endless release versions
    running expected extension version.
    
    Origin: ubuntu
    Modified by: Endless
    
    Forwarded: https://bugzilla.gnome.org/show_bug.cgi?id=789852

 js/ui/extensionDownloader.js | 11 +++++++++++
 js/ui/extensionSystem.js     |  9 +++++++++
 2 files changed, 20 insertions(+)
---
diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js
index b399394b1b..053ec18781 100644
--- a/js/ui/extensionDownloader.js
+++ b/js/ui/extensionDownloader.js
@@ -4,6 +4,7 @@
 const { Clutter, Gio, GLib, GObject, Soup } = imports.gi;
 
 const Config = imports.misc.config;
+const Desktop = imports.misc.desktop;
 const Dialog = imports.ui.dialog;
 const ExtensionUtils = imports.misc.extensionUtils;
 const FileUtils = imports.misc.fileUtils;
@@ -19,6 +20,13 @@ let _httpSession;
 function installExtension(uuid, invocation) {
     let params = { uuid,
                    shell_version: Config.PACKAGE_VERSION };
+    if (Desktop.is('endless') && Main.extensionManager.isModeExtension(uuid)) {
+        let title = _("Can't install ā€œ%sā€:").format(uuid);
+        let msg = _("This is an extension enabled by your current mode, you can't install manually any 
update in that session.");
+        Main.notifyError(title, msg);
+        invocation.return_dbus_error('org.gnome.Shell.CantInstallError', msg);
+        return;
+    }
 
     let message = Soup.form_request_new_from_hash('GET', REPOSITORY_URL_INFO, params);
 
@@ -129,6 +137,9 @@ function checkForUpdates() {
     let metadatas = {};
     Main.extensionManager.getUuids().forEach(uuid => {
         let extension = Main.extensionManager.lookup(uuid);
+        // don't updates out of repository mode extension
+        if (Desktop.is('endless') && Main.extensionManager.isModeExtension(uuid))
+            return;
         if (extension.type !== ExtensionUtils.ExtensionType.PER_USER)
             return;
         if (extension.hasUpdate)
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index f2e8db79d2..b375b70cd6 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -4,6 +4,7 @@
 const { GLib, Gio, GObject, Shell, St } = imports.gi;
 const Signals = imports.signals;
 
+const Desktop = imports.misc.desktop;
 const ExtensionDownloader = imports.ui.extensionDownloader;
 const ExtensionUtils = imports.misc.extensionUtils;
 const FileUtils = imports.misc.fileUtils;
@@ -351,6 +352,10 @@ var ExtensionManager = class {
         this.loadExtension(newExtension);
     }
 
+    isModeExtension(uuid) {
+        return this._getModeExtensions().indexOf(uuid) !== -1;
+    }
+
     _callExtensionInit(uuid) {
         if (!Main.sessionMode.allowExtensions)
             return false;
@@ -532,6 +537,10 @@ var ExtensionManager = class {
             let type = dir.has_prefix(perUserDir)
                 ? ExtensionType.PER_USER
                 : ExtensionType.SYSTEM;
+            if (Desktop.is('endless') && this.isModeExtension(uuid) && type === ExtensionType.PER_USER) {
+                log(`Found user extension ${uuid}, but not loading from ${dir.get_path()} directory as part 
of session mode.`);
+                return;
+            }
             try {
                 extension = this.createExtensionObject(uuid, dir, type);
             } catch (e) {


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