Blob Blame History Raw
From c8bff2cb5f2b3f01dd3f98adb7e8358d604b3c47 Mon Sep 17 00:00:00 2001
From: Yuri Konotopov <ykonotopov@gnome.org>
Date: Sun, 10 May 2020 14:22:47 +0400
Subject: [PATCH] connector: drop updates support in favour of Shell 3.36
 default behavior

Closes: https://gitlab.gnome.org/GNOME/chrome-gnome-shell/-/issues/19
---
 connector/chrome-gnome-shell.py | 91 +--------------------------------
 1 file changed, 1 insertion(+), 90 deletions(-)

diff --git a/connector/chrome-gnome-shell.py b/connector/chrome-gnome-shell.py
index 0bde4dd..6c84ba9 100755
--- a/connector/chrome-gnome-shell.py
+++ b/connector/chrome-gnome-shell.py
@@ -23,12 +23,6 @@ import struct
 import sys
 import traceback
 
-REQUESTS_IMPORTED = True
-try:
-    import requests
-except ImportError:
-    REQUESTS_IMPORTED = False
-
 CONNECTOR_VERSION = 10
 DEBUG_ENABLED = False
 
@@ -371,9 +365,7 @@ class ChromeGNOMEShell(Gio.Application):
                 else:
                     disable_version_check = False
 
-                supports = ['notifications', "update-enabled"]
-                if REQUESTS_IMPORTED:
-                    supports.append('update-check')
+                supports = ['notifications']
 
                 self.send_message(
                     {
@@ -474,16 +466,6 @@ class ChromeGNOMEShell(Gio.Application):
                                     GLib.Variant.new_tuple(GLib.Variant.new_string(request['uuid'])),
                                     "status")
 
-        elif request['execute'] == 'checkUpdate':
-            update_url = 'https://extensions.gnome.org/update-info/'
-            enabled_only = True
-            if 'url' in request:
-                update_url = request['url']
-
-            if 'enabledOnly' in request:
-                enabled_only = request['enabledOnly']
-
-            self.check_update(update_url, enabled_only)
 
         elif request['execute'] == 'createNotification':
             Gio.DBusActionGroup.get(
@@ -502,77 +484,6 @@ class ChromeGNOMEShell(Gio.Application):
 
         debug('Execute: from %s' % request['execute'])
 
-    def check_update(self, update_url, enabled_only):
-        result = self.shell_proxy.call_sync(
-            "ListExtensions",
-            None,
-            Gio.DBusCallFlags.NONE,
-            -1,
-            None
-        )
-
-        extensions = result.unpack()[0]
-        settings = Gio.Settings.new(SHELL_SCHEMA)
-        enabled_extensions = settings.get_strv(ENABLED_EXTENSIONS_KEY)
-
-        if extensions:
-            http_request = {
-                'shell_version': self.shell_proxy.get_cached_property("ShellVersion").unpack(),
-                'installed': {}
-            }
-
-            for uuid in extensions:
-                # gnome-shell/js/misc/extensionUtils.js
-                # EXTENSION_TYPE.PER_USER = 2
-                if is_uuid(uuid) and extensions[uuid]['type'] == 2 and (not enabled_only or uuid in enabled_extensions):
-                    try:
-                        http_request['installed'][uuid] = {
-                            'version': int(extensions[uuid]['version'])
-                        }
-                    except (ValueError, KeyError):
-                        http_request['installed'][uuid] = {
-                            'version': 1
-                        }
-
-            http_request['installed'] = json.dumps(http_request['installed'])
-
-            proxies = Gio.ProxyResolver.get_default().lookup(update_url)
-            if proxies is not None:
-                proxy = proxies[0]
-                if proxy.startswith('direct'):
-                    proxies = None
-                else:
-                    proxies = {}
-                    for scheme in ('http', 'https'):
-                        proxies[scheme] = proxy
-
-            try:
-                response = requests.get(
-                    update_url,
-                    params=http_request,
-                    proxies=proxies,
-                    timeout=5
-                )
-                response.raise_for_status()
-                self.send_message({
-                    'success': True,
-                    'extensions': extensions,
-                    'upgrade': response.json()}
-                )
-            except (
-                    requests.ConnectionError, requests.HTTPError, requests.Timeout,
-                    requests.TooManyRedirects, requests.RequestException, ValueError
-                    ) as ex:
-                error_message = str(ex.message) if hasattr(ex, 'message') else str(ex)
-                log_error('Unable to check extensions updates: %s' % error_message)
-
-                request_url = ex.response.url if ex.response is not None else ex.request.url
-                if request_url:
-                    url_parameters = request_url.replace(update_url, "")
-                    error_message = error_message.replace(url_parameters, "…")
-
-                self.send_message({'success': False, 'message': error_message})
-
 
 if __name__ == '__main__':
     debug('Main. Use Ctrl+D to quit.')
-- 
2.29.2