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

[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-128.3.0esr-14.0-1] fixup! [android] Modify add-on support



Title: GitLab

ma1 pushed to branch tor-browser-128.3.0esr-14.0-1 at The Tor Project / Applications / Tor Browser

Commits:

  • d1579ad1
    by hackademix at 2024-10-08T14:25:29+02:00
    fixup! [android] Modify add-on support
    
    Bug 43132: Enable scriptless installation on Android.
    

4 changed files:

Changes:

  • mobile/shared/modules/geckoview/GeckoViewWebExtension.sys.mjs
    ... ... @@ -354,7 +354,9 @@ async function exportExtension(aAddon, aSourceURI) {
    354 354
         disabledFlags.push("appVersionDisabled");
    
    355 355
       }
    
    356 356
       const baseURL = policy ? policy.getURL() : "";
    
    357
    -  const privateBrowsingAllowed = policy ? policy.privateBrowsingAllowed : false;
    
    357
    +  const privateBrowsingAllowed = policy
    
    358
    +    ? policy.privateBrowsingAllowed
    
    359
    +    : lazy.PrivateBrowsingUtils.permanentPrivateBrowsing;
    
    358 360
     
    
    359 361
       let updateDate;
    
    360 362
       try {
    
    ... ... @@ -509,6 +511,9 @@ class ExtensionInstallListener {
    509 511
     
    
    510 512
       async onInstallEnded(aInstall, aAddon) {
    
    511 513
         debug`onInstallEnded addonId=${aAddon.id}`;
    
    514
    +    if (lazy.PrivateBrowsingUtils.permanentPrivateBrowsing) {
    
    515
    +      await GeckoViewWebExtension.setPrivateBrowsingAllowed(aAddon.id, true);
    
    516
    +    }
    
    512 517
         const extension = await exportExtension(aAddon, aInstall.sourceURI);
    
    513 518
         this.resolve({ extension });
    
    514 519
       }
    

  • toolkit/mozapps/extensions/AddonManager.sys.mjs
    ... ... @@ -83,7 +83,10 @@ const lazy = {};
    83 83
     ChromeUtils.defineESModuleGetters(lazy, {
    
    84 84
       AbuseReporter: "resource://gre/modules/AbuseReporter.sys.mjs",
    
    85 85
       AddonRepository: "resource://gre/modules/addons/AddonRepository.sys.mjs",
    
    86
    +  GeckoViewWebExtension: "resource://gre/modules/GeckoViewWebExtension.sys.mjs",
    
    87
    +  EventDispatcher: "resource://gre/modules/Messaging.sys.mjs",
    
    86 88
       Extension: "resource://gre/modules/Extension.sys.mjs",
    
    89
    +  PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
    
    87 90
       RemoteSettings: "resource://services-settings/remote-settings.sys.mjs",
    
    88 91
       TelemetryTimestamps: "resource://gre/modules/TelemetryTimestamps.sys.mjs",
    
    89 92
       isGatedPermissionType:
    
    ... ... @@ -2346,6 +2349,24 @@ var AddonManagerInternal = {
    2346 2349
         return promiseInstall;
    
    2347 2350
       },
    
    2348 2351
     
    
    2352
    +  async installGeckoViewWebExtension(extensionUri) {
    
    2353
    +    const installId = Services.uuid.generateUUID().toString();
    
    2354
    +    let { extension } = await lazy.GeckoViewWebExtension.installWebExtension(
    
    2355
    +      installId,
    
    2356
    +      extensionUri
    
    2357
    +    );
    
    2358
    +    if (lazy.PrivateBrowsingUtils.permanentPrivateBrowsing) {
    
    2359
    +      extension = await lazy.GeckoViewWebExtension.setPrivateBrowsingAllowed(
    
    2360
    +        extension.webExtensionId,
    
    2361
    +        true
    
    2362
    +      );
    
    2363
    +    }
    
    2364
    +    await lazy.EventDispatcher.instance.sendRequest({
    
    2365
    +      type: "GeckoView:WebExtension:OnInstalled",
    
    2366
    +      extension,
    
    2367
    +    });
    
    2368
    +  },
    
    2369
    +
    
    2349 2370
       /**
    
    2350 2371
        * Starts installation of an AddonInstall notifying the registered
    
    2351 2372
        * web install listener of a blocked or started install.
    
    ... ... @@ -2518,6 +2539,10 @@ var AddonManagerInternal = {
    2518 2539
           );
    
    2519 2540
     
    
    2520 2541
           if (installAllowed) {
    
    2542
    +        if (AppConstants.platform == "android") {
    
    2543
    +          aInstall.cancel();
    
    2544
    +          return this.installGeckoViewWebExtension(aInstall.sourceURI);
    
    2545
    +        }
    
    2521 2546
             startInstall("AMO");
    
    2522 2547
           } else if (installPerm === Ci.nsIPermissionManager.DENY_ACTION) {
    
    2523 2548
             // Block without prompt
    

  • toolkit/mozapps/extensions/components.conf
    ... ... @@ -32,14 +32,13 @@ Classes = [
    32 32
             'esModule': 'resource://gre/modules/amWebAPI.sys.mjs',
    
    33 33
             'constructor': 'WebAPI',
    
    34 34
         },
    
    35
    +    # tor-browser#43132: re-enable XPI handler on Android to allow scriptless extensions installation.
    
    36
    +    # This reverts https://bugzilla.mozilla.org/show_bug.cgi?id=1610571, which made sense for generic
    
    37
    +    # GeckoView extensionless embedders and for Firefox, relying on navigator.mozAddonManager.
    
    38
    +    {
    
    39
    +        'cid': '{7beb3ba8-6ec3-41b4-b67c-da89b8518922}',
    
    40
    +        'contract_ids': ['@mozilla.org/uriloader/content-handler;1?type=application/x-xpinstall'],
    
    41
    +        'esModule': 'resource://gre/modules/amContentHandler.sys.mjs',
    
    42
    +        'constructor': 'amContentHandler',
    
    43
    +    },
    
    35 44
     ]
    36
    -
    
    37
    -if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] != 'android':
    
    38
    -    Classes += [
    
    39
    -        {
    
    40
    -            'cid': '{7beb3ba8-6ec3-41b4-b67c-da89b8518922}',
    
    41
    -            'contract_ids': ['@mozilla.org/uriloader/content-handler;1?type=application/x-xpinstall'],
    
    42
    -            'esModule': 'resource://gre/modules/amContentHandler.sys.mjs',
    
    43
    -            'constructor': 'amContentHandler',
    
    44
    -        },
    
    45
    -    ]

  • toolkit/mozapps/extensions/internal/XPIInstall.sys.mjs
    ... ... @@ -4475,6 +4475,11 @@ export var XPIInstall = {
    4475 4475
           return false;
    
    4476 4476
         }
    
    4477 4477
     
    
    4478
    +    // tor-browser#43132: short-circuit permission check on Android scriptless install from AMO
    
    4479
    +    if (AppConstants.platform == "android" && uri.prePath == "https://addons.mozilla.org") {
    
    4480
    +      return true;
    
    4481
    +    }
    
    4482
    +
    
    4478 4483
         let requireWhitelist = Services.prefs.getBoolPref(
    
    4479 4484
           PREF_XPI_WHITELIST_REQUIRED,
    
    4480 4485
           true
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits