[Extensions] Remove handling for .user.js files [chromium/src : main]

0 views
Skip to first unread message

Anton Bershanskyi (Gerrit)

unread,
Jun 15, 2026, 12:24:19 PM (14 days ago) Jun 15
to Devlin Cronin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, dtraino...@chromium.org, extension...@chromium.org
Attention needed from Devlin Cronin

Anton Bershanskyi added 6 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Anton Bershanskyi . resolved

Hi Devlin,

This Cl removes broken `extensions::ConvertUserScriptToExtension()` method and its callers (including tests).

This CL removes special handling for files ending in `.user.js` when they are dropped into `chrome://extensions` page. This functionality relied on Manifest Version 1 support because `extensions::ConvertUserScriptToExtension()` does not explicitly insert the `"manifest_version"` key, so `extensions::Manifest:: GetManifestVersion()` defaults manifest to `1`[1]. This drop functionality is already broken since migration to Manifest Version 3 breaks earlier versions.

This patch not affect regular extension load. In particular, it does not affect extensions with MV3 and `"converted_from_user_script"` manifest key. This patch does not touch `extensions::Extension` class in any way. All `.user.js` files which were pulled into earlier versions of Chrome and then were packed into an archive and uploaded to Chrome Web Store, and then updated to be MV3-compliant would still be supported since they already underwent the conversion.

Alternatively, we can fix extension loading by fixing `extensions::ConvertUserScriptToExtension()` by adding `root.Set(manifest_keys::kManifestVersion, 3);`. This one liner would fix converted extension load, but a lot of bugs specific to converted User Scripts would remain.

[1] https://source.chromium.org/chromium/chromium/src/+/main:extensions/common/manifest.cc;l=107

File chrome/browser/chrome_content_browser_client.cc
Line 6964, Patchset 2 (Parent): if (extensions::UserScript::IsURLUserScript(url, mime_type)) {
Anton Bershanskyi . resolved

We should not force-download User Scripts. After removing this clause, User Scripts are treated as regular files.

File chrome/browser/download/chrome_download_manager_delegate.cc
Line 1076, Patchset 2 (Latest): installer->InstallCrx(item->GetFullPath());
Anton Bershanskyi . resolved

Since we removed `extensions::UserScript::IsURLUserScript()`, then this code is reachable only by regular (MV3) extensions.

File chrome/browser/extensions/api/developer_private/developer_private_functions.cc
Line 1056, Patchset 2 (Latest): return RespondNow(Error(kUserScriptsNotSupportedError));
Anton Bershanskyi . resolved

Here in `DeveloperPrivateInstallDroppedFileFunction` we can just abort extension install. This error gets logged into the console. If needed, I can add a user-visible warning.

File extensions/browser/extension_util.cc
Line 584, Patchset 2 (Parent): if (download_item.GetMimeType() == Extension::kMimeType ||
Anton Bershanskyi . resolved

In `IsExtensionDownload()` I remove call to `UserScript::IsURLUserScript()` so it User Scripts will be handled like regular files.

File extensions/common/user_script.cc
Line 109, Patchset 2 (Parent):bool UserScript::IsURLUserScript(const GURL& url,
Anton Bershanskyi . resolved

We can remove every call to `UserScript::IsURLUserScript()` and at very call site pretend that it always returns `false`.

Open in Gerrit

Related details

Attention is currently required from:
  • Devlin Cronin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I91bc0849fd4fe0396468ab07e9501d6afa5f9c5b
Gerrit-Change-Number: 7941590
Gerrit-PatchSet: 2
Gerrit-Owner: Anton Bershanskyi <bersh...@gmail.com>
Gerrit-Reviewer: Anton Bershanskyi <bersh...@gmail.com>
Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Comment-Date: Mon, 15 Jun 2026 16:23:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Devlin Cronin (Gerrit)

unread,
Jun 25, 2026, 4:08:37 PM (4 days ago) Jun 25
to Anton Bershanskyi, Devlin Cronin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, dtraino...@chromium.org, extension...@chromium.org
Attention needed from Anton Bershanskyi

Devlin Cronin added 4 comments

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Devlin Cronin . resolved

Thank you, Anton!

File chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
Line 1908, Patchset 4 (Latest): EXPECT_FALSE(api_test_utils::RunFunction(function.get(), "[]", profile()))
<< "User script support was removed.";
EXPECT_EQ("User Scripts are not supported.", function->GetError());
Devlin Cronin . unresolved

nit: prefer RunFunctionAndReturnError()

File chrome/browser/extensions/api/developer_private/developer_private_functions.cc
Line 1055, Patchset 4 (Latest): if (MatchesExtension(file, FILE_PATH_LITERAL(".user.js"))) {
Devlin Cronin . unresolved

this method is only used by the chrome://extensions page, so we should update that to not call into here with .user.js files (updating [this](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/resources/extensions/drag_and_drop_handler.ts;l=71;drc=409a2f3667e632ee01450646335641b80e5ceab3) code)

File extensions/browser/crx_installer.h
Line 290, Patchset 4 (Latest): void ConvertUserScriptOnSharedFileThread();
Devlin Cronin . unresolved

remove this declaration

Open in Gerrit

Related details

Attention is currently required from:
  • Anton Bershanskyi
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I91bc0849fd4fe0396468ab07e9501d6afa5f9c5b
    Gerrit-Change-Number: 7941590
    Gerrit-PatchSet: 4
    Gerrit-Owner: Anton Bershanskyi <bersh...@gmail.com>
    Gerrit-Reviewer: Anton Bershanskyi <bersh...@gmail.com>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Attention: Anton Bershanskyi <bersh...@gmail.com>
    Gerrit-Comment-Date: Thu, 25 Jun 2026 20:08:23 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Anton Bershanskyi (Gerrit)

    unread,
    Jun 27, 2026, 5:13:14 AM (2 days ago) Jun 27
    to Devlin Cronin, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, dtraino...@chromium.org, extension...@chromium.org
    Attention needed from Devlin Cronin

    Anton Bershanskyi added 4 comments

    Patchset-level comments
    File-level comment, Patchset 7 (Latest):
    Anton Bershanskyi . resolved

    Hi Devlin, thanks for review.

    File chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
    Line 1908, Patchset 4: EXPECT_FALSE(api_test_utils::RunFunction(function.get(), "[]", profile()))

    << "User script support was removed.";
    EXPECT_EQ("User Scripts are not supported.", function->GetError());
    Devlin Cronin . resolved

    nit: prefer RunFunctionAndReturnError()

    Anton Bershanskyi

    I removed test `DeveloperPrivateApiUnitTest.InstallDroppedFileUserScript` because I removed special handling of `.user.js` files from TS and `DeveloperPrivateInstallDroppedFileFunction` does not handle `.user.js` files any more.

    File chrome/browser/extensions/api/developer_private/developer_private_functions.cc
    Line 1055, Patchset 4: if (MatchesExtension(file, FILE_PATH_LITERAL(".user.js"))) {
    Devlin Cronin . resolved

    this method is only used by the chrome://extensions page, so we should update that to not call into here with .user.js files (updating [this](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/resources/extensions/drag_and_drop_handler.ts;l=71;drc=409a2f3667e632ee01450646335641b80e5ceab3) code)

    Anton Bershanskyi

    Thanks, I updated the TS file, as you suggested.

    File extensions/browser/crx_installer.h
    Line 290, Patchset 4: void ConvertUserScriptOnSharedFileThread();
    Devlin Cronin . resolved

    remove this declaration

    Anton Bershanskyi

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Devlin Cronin
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I91bc0849fd4fe0396468ab07e9501d6afa5f9c5b
      Gerrit-Change-Number: 7941590
      Gerrit-PatchSet: 7
      Gerrit-Owner: Anton Bershanskyi <bersh...@gmail.com>
      Gerrit-Reviewer: Anton Bershanskyi <bersh...@gmail.com>
      Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
      Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
      Gerrit-Comment-Date: Sat, 27 Jun 2026 09:12:51 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages