[Extensions] Implement scripting.registercontentscripts [chromium/src : main]

37 views
Skip to first unread message

Kelvin Jiang (Gerrit)

unread,
Jun 2, 2021, 10:29:17 PM6/2/21
to Devlin, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org

Attention is currently required from: Devlin.

Kelvin Jiang would like Devlin to review this change.

View Change

[Extensions] Implement scripting.registercontentscripts

This CL implements scripting.registerContentScripts, which is restricted
to MV3. Currently, registered content scripts are session scoped only.

Unlike manifest content scripts, the extension must specify a distinct ID
for each dynamic script.

Since the RegisteredContentScript type in scripting.idl shares a lot of
common logic wrt parsing/validating files as manifest content scripts,
common methods have been extracted into content_script_utils.

Bug: 1168627
Change-Id: I0e842230917ce27052968719f3af71311d418ca2
---
M chrome/browser/extensions/api/scripting/scripting_api.cc
M chrome/browser/extensions/api/scripting/scripting_api.h
M chrome/browser/extensions/api/scripting/scripting_apitest.cc
M chrome/browser/extensions/content_script_tracker_browsertest.cc
M chrome/common/extensions/api/_api_features.json
M chrome/common/extensions/api/scripting.idl
A chrome/test/data/extensions/api_test/scripting/dynamic_scripts/manifest.json
A chrome/test/data/extensions/api_test/scripting/dynamic_scripts/script.js
A chrome/test/data/extensions/api_test/scripting/dynamic_scripts/worker.js
M extensions/browser/content_script_tracker.cc
M extensions/browser/extension_function_histogram_value.h
M extensions/browser/user_script_manager.cc
M extensions/browser/user_script_manager.h
M extensions/common/BUILD.gn
M extensions/common/manifest_handlers/content_scripts_handler.cc
M extensions/common/user_script.cc
M extensions/common/user_script.h
A extensions/common/utils/content_script_utils.cc
A extensions/common/utils/content_script_utils.h
M extensions/renderer/user_script_set.cc
M tools/metrics/histograms/enums.xml
21 files changed, 1,036 insertions(+), 198 deletions(-)


To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
Gerrit-Change-Number: 2892136
Gerrit-PatchSet: 11
Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Attention: Devlin <rdevlin...@chromium.org>
Gerrit-MessageType: newchange

Kelvin Jiang (Gerrit)

unread,
Jun 2, 2021, 10:29:24 PM6/2/21
to asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, Devlin, Chromium LUCI CQ, Tricium, Chromium Metrics Reviews, chromium...@chromium.org

Attention is currently required from: Devlin.

Patch set 11:Commit-Queue +1

View Change

    To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
    Gerrit-Change-Number: 2892136
    Gerrit-PatchSet: 11
    Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-Attention: Devlin <rdevlin...@chromium.org>
    Gerrit-Comment-Date: Thu, 03 Jun 2021 02:29:12 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Devlin (Gerrit)

    unread,
    Jun 3, 2021, 8:14:38 PM6/3/21
    to Kelvin Jiang, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, Devlin, Chromium LUCI CQ, Tricium, Chromium Metrics Reviews, chromium...@chromium.org

    Attention is currently required from: Kelvin Jiang.

    View Change

    16 comments:

    • Commit Message:

      • Patch Set #11, Line 12: Unlike manifest content scripts, the extension must specify a distinct ID

        nit: please wrap at 72 chars

    • Patchset:

      • Patch Set #11:

        Thanks, Kelvin! This looks really, really good!

        I took a high-level pass here to pick out some of the larger pieces that might require a bit of code shift (and also anything I was worried I'd forget later ; )). I'll take another pass next week.

    • File chrome/browser/extensions/api/scripting/scripting_api.cc:

    • File chrome/common/extensions/api/_api_features.json:

      • Patch Set #11, Line 741: "min_manifest_version": 3

        let's also restrict to channel: canary since the API will still be WIP after this CL (e.g., for adding extra testing, other methods, etc)

        That will also mean we need to add a ScopedCurrentChannel in the API test.

    • File chrome/common/extensions/api/scripting.idl:

      • Patch Set #11, Line 19: enum RunAt {

        can we instead use extensionTypes.RunAt, or does that cause issues?

      • Patch Set #11, Line 113: dictionary RegisteredContentScript {

        while these are in development, we should add [nodoc] to these types and methods

      • Patch Set #11, Line 124: exclude_matches

        nit: Since these are now JS objects, they should use jsNamingStyle

      • Patch Set #11, Line 142:

            // Whether the script should inject into an about:blank frame where the
        // parent or opener frame matches one of the patterns declared in matches.
        // Defaults to false.
        boolean? match_about_blank;

        Let's remove this one, since it's replaced by the one above

      • Patch Set #11, Line 146:

            // Applied after matches to include only those URLs that also match this
        // glob. Intended to emulate the
        // <a href="http://wiki.greasespot.net/Metadata_Block#.40include">@include
        // </a> Greasemonkey keyword.
        DOMString[]? include_globs;
        // Applied after matches to exclude URLs that match this glob. Intended to
        // emulate the
        // <a href="https://wiki.greasespot.net/Metadata_Block#.40exclude">@exclude
        // </a> Greasemonkey keyword.
        DOMString[]? exclude_globs;

        I know we chatted about whether to include these in this first version of the API. Did we decide they were necessary?

      • Patch Set #11, Line 203: RegisteredContentScript[] scripts,

        Probably should have caught this in the API doc, but is it worth wrapping this in a dictionary so that we can add additional properties later (such as scope for session vs persistent)?

    • File extensions/browser/content_script_tracker.cc:

      • Patch Set #11, Line 233:

          const UserScriptList& dynamic_scripts =
        manager == nullptr
        ? g_empty_script_list.Get().user_script_list
        : manager->GetLoadedDynamicExtensionScripts(extension.id());

        nit1: When do we expect manager to be null? (Add a comment if it can happen)
        nit2: Rather than the global empty list, I feel like this would be cleaner by just guarding with an if:

        if (any_of(manifest_scripts, match))
        return true;
        if (manager) {
        dynamic_scripts = manager->GetScripts();
        if (any_of(dynamic_scripts, match))
        return true;
        }
        return false;
    • File extensions/browser/user_script_manager.h:

      • Patch Set #11, Line 57: New

        Maybe s/New/Pending?

      • Patch Set #11, Line 87:

            // The IDs of scripts registered by the extension's API calls but have not
        // beeen loaded yet. When an registerContentScripts call is made, script IDs
        // are put into this set. They are removed from the set when the API call
        // encounters an error or if the scripts from that call have been loaded.
        std::set<std::string> pending_dynamic_script_ids;

        // The metadata of dynamic scripts from the extension that have been loaded.
        UserScriptList loaded_dynamic_scripts;
        std::unique_ptr<ExtensionUserScriptLoader> loader;

        Rather than storing all this extension-specific metadata in a separate struct in the USM, would it make sense to expose on the ExtensionUserScriptLoader? That's already per-extension and contains (through USL) a bunch of the "stored script"-style info. It also seems like that would keep this manager a bit cleaner as the "manager of each loader" rather than being a pseudo-loader itself.

        WDYT?

    • File extensions/common/utils/content_script_utils.h:

      • Patch Set #11, Line 22: const std::unique_ptr<bool>&

        rather than `const std::unique_ptr<T>&`, typically prefer `const T*` (if possibly null) or `const T&` (if definitely not null)

      • Patch Set #11, Line 22: void ParseMatchFlags(const std::unique_ptr<bool>& match_origin_as_fallback,

        add comments on the rest of these functions, too

    To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
    Gerrit-Change-Number: 2892136
    Gerrit-PatchSet: 11
    Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Comment-Date: Fri, 04 Jun 2021 00:14:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Kelvin Jiang (Gerrit)

    unread,
    Jun 7, 2021, 6:32:03 PM6/7/21
    to asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org

    Attention is currently required from: Kelvin Jiang.

    Kelvin Jiang uploaded patch set #12 to this change.

    View Change

    [Extensions] Implement scripting.registercontentscripts

    This CL implements scripting.registerContentScripts, which is restricted
    to MV3. Currently, registered content scripts are session scoped only.

    Unlike manifest content scripts, the extension must specify a distinct
    ID for each dynamic script.

    To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
    Gerrit-Change-Number: 2892136
    Gerrit-PatchSet: 12
    Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-MessageType: newpatchset

    Kelvin Jiang (Gerrit)

    unread,
    Jun 9, 2021, 9:31:00 PM6/9/21
    to asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, Devlin, Chromium LUCI CQ, Tricium, Chromium Metrics Reviews, chromium...@chromium.org

    Attention is currently required from: Devlin.

    Patch set 14:Commit-Queue +1

    View Change

    16 comments:

    • Commit Message:

      • Patch Set #11, Line 12: Unlike manifest content scripts, the extension must specify a distinct ID

        nit: please wrap at 72 chars

      • Done

    • File chrome/browser/extensions/api/scripting/scripting_api.cc:

      • then it shouldn't be a valid script. Going to add a test for this too

      • nit: since we AddRef() here, no need in having the WeakPtrFactory. […]

        Done

      • nit: since we AddRef() here, no need in having the WeakPtrFactory. […]

        Done

    • File chrome/common/extensions/api/_api_features.json:

      • let's also restrict to channel: canary since the API will still be WIP after this CL (e.g. […]

        oops I forgot to restrict this to channel: trunk

        The API test already restricts it to channel::UNKNOWN (which I think is trunk)

    • File chrome/common/extensions/api/scripting.idl:

      • can we instead use extensionTypes. […]

        we can (tested by making this change, then adding this property to the test)

      • Patch Set #11, Line 113: dictionary RegisteredContentScript {

        while these are in development, we should add [nodoc] to these types and methods

      • Done

      • Done

      • Patch Set #11, Line 142:

            // Whether the script should inject into an about:blank frame where the
        // parent or opener frame matches one of the patterns declared in matches.
        // Defaults to false.
        boolean? match_about_blank;

        Let's remove this one, since it's replaced by the one above

      • Done

      • I know we chatted about whether to include these in this first version of the API. […]

        We decided to not include them until running extplorer shows that they're used often enough to warrant including it in a follow up

      • Probably should have caught this in the API doc, but is it worth wrapping this in a dictionary so th […]

        I am leaning towards including additional properties (iirc there wouldn't be many) inside RegisteredContentScript because it would make the API look cleaner)

    • File extensions/browser/content_script_tracker.cc:

      • Patch Set #11, Line 233:

          const UserScriptList& dynamic_scripts =
        manager == nullptr
        ? g_empty_script_list.Get().user_script_list
        : manager->GetLoadedDynamicExtensionScripts(extension.id());

      • nit1: When do we expect manager to be null? (Add a comment if it can happen) […]

        Done

    • File extensions/browser/user_script_manager.h:

      • Done

      • Patch Set #11, Line 87:

            // The IDs of scripts registered by the extension's API calls but have not
        // beeen loaded yet. When an registerContentScripts call is made, script IDs
        // are put into this set. They are removed from the set when the API call
        // encounters an error or if the scripts from that call have been loaded.
        std::set<std::string> pending_dynamic_script_ids;

        // The metadata of dynamic scripts from the extension that have been loaded.
        UserScriptList loaded_dynamic_scripts;
        std::unique_ptr<ExtensionUserScriptLoader> loader;

      • Rather than storing all this extension-specific metadata in a separate struct in the USM, would it m […]

        I moved all the methods/state into the EUSL.

        Actually resulted in less LOC too/made USM easier to reason about, thanks

    • File extensions/common/utils/content_script_utils.h:

      • rather than `const std::unique_ptr<T>&`, typically prefer `const T*` (if possibly null) or `const T& […]

        Done

      • Patch Set #11, Line 22: void ParseMatchFlags(const std::unique_ptr<bool>& match_origin_as_fallback,

        add comments on the rest of these functions, too

      • Done

    To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
    Gerrit-Change-Number: 2892136
    Gerrit-PatchSet: 14
    Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-Attention: Devlin <rdevlin...@chromium.org>
    Gerrit-Comment-Date: Thu, 10 Jun 2021 01:30:52 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Devlin <rdevlin...@chromium.org>
    Gerrit-MessageType: comment

    Devlin (Gerrit)

    unread,
    Jun 11, 2021, 7:25:12 PM6/11/21
    to Kelvin Jiang, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, Devlin, Chromium LUCI CQ, Tricium, Chromium Metrics Reviews, chromium...@chromium.org

    Attention is currently required from: Kelvin Jiang.

    View Change

    33 comments:

    • Patchset:

      • Patch Set #14:

        Thanks, Kelvin! This is shaping up nicely.

        Lots of nits, but I think most should be very straightforward.

    • File chrome/browser/extensions/api/scripting/scripting_api.h:

    • File chrome/browser/extensions/api/scripting/scripting_api.cc:

      • Patch Set #14, Line 37: #include "extensions/common/api/extension_types.h"

        nit: out of place

      • Patch Set #14, Line 231: mojom::RunLocation ConvertRunLocation(api::extension_types::RunAt run_at) {

        We do this same thing in ExecuteCodeFunction. Let's pull it into a common area where we can share the code.

      • Patch Set #14, Line 246: *

        nit: pass by const& if it can't be null

      • Patch Set #14, Line 255: // id

        nit: I know that the user script parsing code does this, but it's not really necessary here (where the variables are very clear). We can probably remove these comments

      • Patch Set #14, Line 636: ->GetUserScriptLoaderForExtension(extension()->id())

        We use this again on line 684. Let's cache it in a local.

      • Patch Set #14, Line 659:

          const bool can_execute_script_everywhere =
        PermissionsData::CanExecuteScriptEverywhere(extension()->id(),
        extension()->location());
        const int valid_schemes =
        UserScript::ValidUserScriptSchemes(can_execute_script_everywhere);
        const bool all_urls_includes_chrome_urls =
        PermissionsData::AllUrlsIncludesChromeUrls(extension()->id());

        This is a bit of an "ugly" aspect of the permissions API, and is really only used for the legacy version of Chromevox. How about we leave this out for now (and assume that can_execute_everywhere is always false), and add a comment that this _could_ be added in later if needed?

      • Patch Set #14, Line 667:

          std::set<std::string> new_script_ids;
        for (size_t i = 0; i < scripts.size(); ++i) {
        // Parse/Create user script.
        std::unique_ptr<UserScript> user_script = ParseUserScript(
        extension(), scripts[i], i, can_execute_script_everywhere,
        valid_schemes, all_urls_includes_chrome_urls, &parse_error);
        if (!user_script)
        return RespondNow(Error(base::UTF16ToASCII(parse_error)));

        new_script_ids.insert(user_script->id());
        parsed_scripts->push_back(std::move(user_script));
        }

        Optional: We could push this into the loop above. It's slower in the case that there is an error in IDs, but we don't usually optimize for error cases. But, it's not any slower this way, so I don't have a strong preference.

        In either case, I'd slightly prefer we build new_script_ids up in the previous (and perhaps only) loop, and just check both for dupes:

        if (base::Contains(previous_script_ids, script.id) ||
        base::Contains(new_script_ids, script_id)) {
        return Error(...);
        }

        new_script_ids.insert(script.id);

      • Patch Set #14, Line 695: AddRef();

        Add a

        // Balanced in...

        comment (ditto for the Release()s)

    • File chrome/common/extensions/api/scripting.idl:

      • Patch Set #11, Line 203: RegisteredContentScript[] scripts,

        I am leaning towards including additional properties (iirc there wouldn't be many) inside Registered […]

        Ack

    • File chrome/common/extensions/api/scripting.idl:

      • Patch Set #14, Line 91: // Describes a content script to be injected into a web page registered through

        nit: wrap at 80 (also the rest of this file)

    • File chrome/test/data/extensions/api_test/scripting/dynamic_scripts/worker.js:

      • Patch Set #14, Line 18: if (message === 'SCRIPT_INJECTED') {

        Do we expect any other message? If not, let's

        chrome.test.assertEquals('SCRIPT_INJECTED', message);

      • Patch Set #14, Line 24: const results = await Promise.all([

        optional nit: this is fun (and is actually mildly more efficient), but I think it's a hair less readable than:

        await chrome.scripting.registerContentScripts(scripts);
        const config = await chrome.test.getConfig();

      • Patch Set #14, Line 32: await

        nit: no need for an await here. And it could _potentially_ lead to slightly weird behavior, since we might still be waiting on it after the message comes in (depending on injection timing)

      • Patch Set #14, Line 37: duplicateScripts1

        nit: test1, test2, test3 naming style isn't as descriptive, and forces the reader to comb into the test to figure out the differences. Let's instead add some more details here, e.g.

        duplicateScriptId_DuplicatesInSameCall
        duplicateScriptId_DuplicateInPendingRegistration
        duplicateScriptId_DuplicatePreviouslyRegistered

      • Patch Set #14, Line 38: const scriptId = 'script1';

        nit: let's maybe just add a quick comment:

        // This was registered in the previous test.

      • Patch Set #14, Line 41: scriptId

        nit: this would technically fail anyway, since the scriptId was already registered. Let's make scriptId something different in this test.

      • Patch Set #14, Line 63: chrome.test.assertEq(undefined, chrome.runtime.lastError);

        nit: let's still use a promise here, just without the await. (And then we can Promise.all() with the below, rather than "first and second callback finished")

      • Patch Set #14, Line 88: chrome.test.assertEq(undefined, result);

        nit: probably don't need this.

      • Patch Set #14, Line 139: // content scripts will only be injected once.

        Also permissions-related tests

    • File extensions/browser/content_script_tracker.cc:

    • File extensions/browser/extension_user_script_loader.h:

      • Patch Set #14, Line 51: the scripts to which the ids belong to

        nitty nit: extra "to" in here

        either

        "the scripts to which the ids belong"

        or

        "the scripts the ids belong to"

        (Technically, ending in a preposition, but I ascribe to Churchill's supposed comment on that...)

      • Patch Set #14, Line 55:

          // Removes `script_ids` from `pending_dynamic_script_ids_`. Should only be
        // called when an API call is about to return with an error before attempting
        // to load its scripts.
        void RemovePendingDynamicScriptIDs(std::set<std::string> script_ids);

        nit: Since this is only for the error case, how about calling it "LoadFailedForPendingScripts()" or similar?

      • Patch Set #14, Line 98:

      •  When an registerContentScripts call is made, script IDs
        // are put into this set.

      • nitty nit: UserScriptLoader shouldn't care about registerContentScripts()

    • File extensions/browser/user_script_manager.h:

    • File extensions/browser/user_script_manager.cc:

    • File extensions/common/user_script.h:

    • File extensions/common/user_script.cc:

    • File extensions/common/utils/content_script_utils.h:

      • Patch Set #14, Line 1: // Copyright 2021 The Chromium Authors. All rights reserved.

        Wild idea:

        What if we took the data from the params in RegisterContentScriptsFunction and constructed a content_scripts_api::ContentScript out of it? RegisterContentScriptsFunction is a strict subset, and they both convert to a UserScript at the end of the day. Then, we could just have a CreateUserScript() function like the one in content_scripts_handler.cc and use it for both.

        WDYT?

      • Patch Set #14, Line 15: #include "extensions/common/mojom/run_location.mojom-shared.h"

        Are all of these necessary?

      • Patch Set #14, Line 21: namespace extensions {

        Let's put these in an additional namespace, e.g. extensions::script_parsing

    To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
    Gerrit-Change-Number: 2892136
    Gerrit-PatchSet: 14
    Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Comment-Date: Fri, 11 Jun 2021 23:25:02 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Kelvin Jiang <kelvi...@chromium.org>

    Kelvin Jiang (Gerrit)

    unread,
    Jun 15, 2021, 8:08:14 PM6/15/21
    to asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, Devlin, Chromium LUCI CQ, Tricium, Chromium Metrics Reviews, chromium...@chromium.org

    Attention is currently required from: Devlin.

    Patch set 18:Commit-Queue +1

    View Change

    33 comments:

    • Patchset:

    • File chrome/browser/extensions/api/scripting/scripting_api.h:

      • nope, removed

      • Patch Set #14, Line 100: using ValidateContentScriptsResult =

        nit: Can we put this in the private section of the API function?

      • No because a helper function in the anonymous namespace returns this. (do you prefer this as-is vs moving helper function/this "using statement" to private)

    • File chrome/browser/extensions/api/scripting/scripting_api.cc:

      • oops

      • We do this same thing in ExecuteCodeFunction. […]

        Done

      • Done

      • nit: I know that the user script parsing code does this, but it's not really necessary here (where t […]

        Done

      • Patch Set #14, Line 636: ->GetUserScriptLoaderForExtension(extension()->id())

        We use this again on line 684. Let's cache it in a local.

      • Done

      • Patch Set #14, Line 659:

          const bool can_execute_script_everywhere =
        PermissionsData::CanExecuteScriptEverywhere(extension()->id(),
        extension()->location());
        const int valid_schemes =
        UserScript::ValidUserScriptSchemes(can_execute_script_everywhere);
        const bool all_urls_includes_chrome_urls =
        PermissionsData::AllUrlsIncludesChromeUrls(extension()->id());

      • This is a bit of an "ugly" aspect of the permissions API, and is really only used for the legacy ver […]

        Done

      • Patch Set #14, Line 667:

          std::set<std::string> new_script_ids;
        for (size_t i = 0; i < scripts.size(); ++i) {
        // Parse/Create user script.
        std::unique_ptr<UserScript> user_script = ParseUserScript(
        extension(), scripts[i], i, can_execute_script_everywhere,
        valid_schemes, all_urls_includes_chrome_urls, &parse_error);
        if (!user_script)
        return RespondNow(Error(base::UTF16ToASCII(parse_error)));

        new_script_ids.insert(user_script->id());
        parsed_scripts->push_back(std::move(user_script));
        }

      • Optional: We could push this into the loop above. […]

        done (building new script ids in first loop)

      • Add a […]

        Done

    • File chrome/common/extensions/api/scripting.idl:

      • Patch Set #14, Line 91: // Describes a content script to be injected into a web page registered through

        nit: wrap at 80 (also the rest of this file)

      • Done

    • File chrome/test/data/extensions/api_test/scripting/dynamic_scripts/worker.js:

      • Do we expect any other message? If not, let's […]

        Done

      • optional nit: this is fun (and is actually mildly more efficient), but I think it's a hair less read […]

        Done

      • nit: no need for an await here. […]

        Done

      • nit: test1, test2, test3 naming style isn't as descriptive, and forces the reader to comb into the t […]

        Done

      • nit: let's maybe just add a quick comment: […]

        noted, but since scriptId is different now for this test I don't think I need to mention this

      • nit: this would technically fail anyway, since the scriptId was already registered. […]

        Done

      • nit: let's still use a promise here, just without the await. (And then we can Promise. […]

        Done

      • nit: let's still use a promise here, just without the await. (And then we can Promise. […]

        Done

      • Done

      • Done

    • File extensions/browser/content_script_tracker.cc:

      • Done

    • File extensions/browser/extension_user_script_loader.h:

      • nitty nit: extra "to" in here […]

        done (second)

      • Patch Set #14, Line 55:

          // Removes `script_ids` from `pending_dynamic_script_ids_`. Should only be
        // called when an API call is about to return with an error before attempting
        // to load its scripts.
        void RemovePendingDynamicScriptIDs(std::set<std::string> script_ids);

      • nit: Since this is only for the error case, how about calling it "LoadFailedForPendingScripts()" or […]

        Pending scripts in this context can pertain to scripts that will be loaded, and scripts that are being loaded (but not complete).

        I think I'll use AbortLoadForPendingScripts() since it should describe both of those cases

      • Patch Set #14, Line 98:

         When an registerContentScripts call is made, script IDs
        // are put into this set.

        nitty nit: UserScriptLoader shouldn't care about registerContentScripts()

      • Done

    • File extensions/browser/user_script_manager.h:

      • Done

    • File extensions/browser/user_script_manager.cc:

      • Done

    • File extensions/common/user_script.h:

      • Done

    • File extensions/common/user_script.cc:

      • Let's also CHECK(!user_script_id_. […]

        Done

    • File extensions/common/utils/content_script_utils.h:

      • Wild idea: […]

        This sounds nifty but at some point, the content script in RegisterContentScripts may diverge from content_script_api::ContentScript (especially with the persist_across_sessions flag), and the required id.

        I would prefer keeping them as two similar but different types and converting both directly to a UserScript.

      • removed some

      • Let's put these in an additional namespace, e.g. […]

        Done

    To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
    Gerrit-Change-Number: 2892136
    Gerrit-PatchSet: 18
    Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-Attention: Devlin <rdevlin...@chromium.org>
    Gerrit-Comment-Date: Wed, 16 Jun 2021 00:08:01 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes

    Devlin (Gerrit)

    unread,
    Jun 16, 2021, 7:47:47 PM6/16/21
    to Kelvin Jiang, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, Devlin, Chromium LUCI CQ, Tricium, Chromium Metrics Reviews, chromium...@chromium.org

    Attention is currently required from: Kelvin Jiang.

    View Change

    15 comments:

    • Patchset:

    • File chrome/browser/extensions/api/scripting/scripting_api.cc:

      • Patch Set #18, Line 248: script_parsing::ParseMatchFlags(content_script.match_origin_as_fallback.get(),

        Let's actually just leave this out for now. I'll add it in as part of finishing up that work.

      • Patch Set #18, Line 653: /*can_execute_script_everywhere=*/false

        Let's pull this up into a constant in the anonymous namespace (along with your comment in the other function) and use it in both places:

        // ...
        constexpr bool kScriptsCanExecuteEverywhere = false;

      • Patch Set #18, Line 654: const bool all_urls_includes_chrome_urls =

        I think we can do the same for this one (since it also only applies to the legacy chromevox extension)

      • Patch Set #18, Line 681: OnContentScriptFilesValidated

        nit: `OnContentScriptFilesValidated()` (which makes codesearch parse them)

    • File chrome/common/extensions/api/scripting.idl:

    • File chrome/test/data/extensions/api_test/scripting/dynamic_scripts/worker.js:

      • Patch Set #18, Line 56:

            const results = await Promise.allSettled([
        chrome.scripting.registerContentScripts(scripts),
        chrome.scripting.registerContentScripts(scripts)
        ]);

        chrome.test.assertEq('fulfilled', results[0].status);
        chrome.test.assertEq('rejected', results[1].status);
        chrome.test.assertEq(
        `Duplicate script ID '${scriptId}'`, results[1].reason.message);

        This came out nicely : )

    • File extensions/browser/extension_user_script_loader.h:

      • Patch Set #18, Line 58: AbortLoadForPendingScripts

        Chatted offline. I'm not keen on AbortLoad(), because this doesn't actually abort the load from the USL's point of view at all. Let's actually just go back to RemovePending(). Sorry for the churn!

    • File extensions/browser/extension_user_script_loader.cc:

    • File extensions/common/manifest_handlers/content_scripts_handler.cc:

      • Patch Set #18, Line 93:

          script_parsing::ParseMatchFlags(content_script.match_origin_as_fallback.get(),
        content_script.match_about_blank.get(),
        result.get());

        and then let's just keep the logic for match_* here.

    • File extensions/common/utils/content_script_utils.h:

      • Patch Set #18, Line 62:

        using OnScriptFilesValidatedCallback =
        base::OnceCallback<void(std::unique_ptr<UserScriptList> scripts,
        const absl::optional<std::string>& error)>;

        Used?

    • File extensions/common/utils/content_script_utils.cc:

    To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
    Gerrit-Change-Number: 2892136
    Gerrit-PatchSet: 18
    Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
    Gerrit-Comment-Date: Wed, 16 Jun 2021 23:47:32 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Devlin (Gerrit)

    unread,
    Jun 16, 2021, 7:48:00 PM6/16/21
    to Kelvin Jiang, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, Devlin, Chromium LUCI CQ, Tricium, Chromium Metrics Reviews, chromium...@chromium.org

    Attention is currently required from: Kelvin Jiang.

    Patch set 18:Code-Review +1

    View Change

      To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
      Gerrit-Change-Number: 2892136
      Gerrit-PatchSet: 18
      Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
      Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
      Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-Attention: Kelvin Jiang <kelvi...@chromium.org>
      Gerrit-Comment-Date: Wed, 16 Jun 2021 23:47:51 +0000

      Kelvin Jiang (Gerrit)

      unread,
      Jun 23, 2021, 4:40:38 PM6/23/21
      to asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, Devlin, Chromium LUCI CQ, Tricium, Chromium Metrics Reviews, chromium...@chromium.org

      Patch set 19:Commit-Queue +2

      View Change

      13 comments:

      • Patchset:

      • File chrome/browser/extensions/api/scripting/scripting_api.cc:

        • Patch Set #18, Line 248: script_parsing::ParseMatchFlags(content_script.match_origin_as_fallback.get(),

          Let's actually just leave this out for now. I'll add it in as part of finishing up that work.

        • Done

        • Let's pull this up into a constant in the anonymous namespace (along with your comment in the other […]

          Done

        • I think we can do the same for this one (since it also only applies to the legacy chromevox extensio […]

          Done

        • Patch Set #18, Line 681: OnContentScriptFilesValidated

          nit: `OnContentScriptFilesValidated()` (which makes codesearch parse them)

        • Done

      • File chrome/common/extensions/api/scripting.idl:

        • Done

      • File extensions/browser/extension_user_script_loader.cc:

        • Patch Set #18, Line 271: std::set<std::string> script_ids) {

          nit: since we don't modify this object, let's make it const &

        • Done

        • Done

      • File extensions/common/manifest_handlers/content_scripts_handler.cc:

        • Patch Set #18, Line 93:

            script_parsing::ParseMatchFlags(content_script.match_origin_as_fallback.get(),
          content_script.match_about_blank.get(),
          result.get());

          and then let's just keep the logic for match_* here.

        • Done

      • File extensions/common/utils/content_script_utils.h:

        • Patch Set #18, Line 62:

          using OnScriptFilesValidatedCallback =
          base::OnceCallback<void(std::unique_ptr<UserScriptList> scripts,
          const absl::optional<std::string>& error)>;

          Used?

        • no

      • File extensions/common/utils/content_script_utils.cc:

        • Done

        • Done

        • Done

      To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
      Gerrit-Change-Number: 2892136
      Gerrit-PatchSet: 19
      Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
      Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
      Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-Comment-Date: Wed, 23 Jun 2021 20:40:29 +0000

      Chromium LUCI CQ (Gerrit)

      unread,
      Jun 23, 2021, 7:11:18 PM6/23/21
      to Kelvin Jiang, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, Devlin, Tricium, Chromium Metrics Reviews, chromium...@chromium.org

      Chromium LUCI CQ submitted this change.

      View Change

      Approvals: Devlin: Looks good to me Kelvin Jiang: Commit
      [Extensions] Implement scripting.registercontentscripts

      This CL implements scripting.registerContentScripts, which is restricted
      to MV3. Currently, registered content scripts are session scoped only.

      Unlike manifest content scripts, the extension must specify a distinct
      ID for each dynamic script.

      Since the RegisteredContentScript type in scripting.idl shares a lot of
      common logic wrt parsing/validating files as manifest content scripts,
      common methods have been extracted into content_script_utils.

      Bug: 1168627
      Change-Id: I0e842230917ce27052968719f3af71311d418ca2
      Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2892136
      Commit-Queue: Kelvin Jiang <kelvi...@chromium.org>
      Reviewed-by: Devlin <rdevlin...@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#895367}

      ---
      M chrome/browser/extensions/api/scripting/scripting_api.cc
      M chrome/browser/extensions/api/scripting/scripting_api.h
      M chrome/browser/extensions/api/scripting/scripting_apitest.cc
      M chrome/browser/extensions/content_script_tracker_browsertest.cc
      M chrome/common/extensions/api/_api_features.json
      M chrome/common/extensions/api/scripting.idl
      A chrome/test/data/extensions/api_test/scripting/dynamic_scripts/manifest.json
      A chrome/test/data/extensions/api_test/scripting/dynamic_scripts/script.js
      A chrome/test/data/extensions/api_test/scripting/dynamic_scripts/worker.js
      M extensions/browser/BUILD.gn
      M extensions/browser/api/execute_code_function.cc
      A extensions/browser/api/extension_types_utils.cc
      A extensions/browser/api/extension_types_utils.h
      M extensions/browser/content_script_tracker.cc
      M extensions/browser/extension_function_histogram_value.h
      M extensions/browser/extension_user_script_loader.cc
      M extensions/browser/extension_user_script_loader.h
      M extensions/browser/user_script_manager.cc

      M extensions/common/BUILD.gn
      M extensions/common/manifest_handlers/content_scripts_handler.cc
      M extensions/common/user_script.cc
      M extensions/common/user_script.h
      A extensions/common/utils/content_script_utils.cc
      A extensions/common/utils/content_script_utils.h
      M extensions/renderer/user_script_set.cc
      M tools/metrics/histograms/enums.xml
      26 files changed, 945 insertions(+), 178 deletions(-)


      18 is the latest approved patch-set. The change was submitted with unreviewed changes in the following files: The name of the file: chrome/browser/extensions/api/scripting/scripting_api.cc Insertions: 21, Deletions: 20. ``` @@ +51:61 @@ + // TODO(crbug.com/1168627): The can_execute_script_everywhere flag is currently + // only used by the legacy version Chromevox extension. We can assume it will + // always be false here, but it may be added back if needed. + constexpr bool kScriptsCanExecuteEverywhere = false; + + // The all_urls_includes_chrome_urls flag is only true for the legacy ChromeVox + // extension, which does not call this API. Therefore we can assume it to be + // always false. + constexpr bool kAllUrlsIncludesChromeUrls = false; + @@ -234:235 @@ - bool all_urls_includes_chrome_urls, @@ -247:253 @@ - script_parsing::ParseMatchFlags(content_script.match_origin_as_fallback.get(), - /*match_about_blank=*/nullptr, result.get()); - - // TODO(crbug.com/1168627): The `can_execute_script_everywhere` flag is - // currently only used by the legacy version Chromevox extension. We can - // assume it will always be false here, but it may be added back if needed. @@ -256:258, +259:261 @@ - /*can_execute_script_everywhere=*/false, valid_schemes, - all_urls_includes_chrome_urls, result.get(), error, + kScriptsCanExecuteEverywhere, valid_schemes, + kAllUrlsIncludesChromeUrls, result.get(), error, @@ +394:397 @@ + std::vector<mojom::JSSourcePtr> sources; + sources.push_back( + mojom::JSSource::New(std::move(code_to_execute), std::move(script_url))); @@ -393:396, +399:402 @@ - mojom::CodeInjection::NewJs(mojom::JSInjection::New( - std::move(code_to_execute), std::move(script_url), - /*wants_result=*/true, user_gesture())), + mojom::CodeInjection::NewJs(mojom::JSInjection::New(std::move(sources), + /*wants_result=*/true, + user_gesture())), @@ +517:521 @@ + + std::vector<mojom::CSSSourcePtr> sources; + sources.push_back(mojom::CSSSource::New(std::move(code_to_execute), + std::move(injection_key))); @@ -514:516, +524:525 @@ - std::move(code_to_execute), std::move(injection_key), - ConvertStyleOriginToCSSOrigin(injection_.origin), + std::move(sources), ConvertStyleOriginToCSSOrigin(injection_.origin), @@ +593:597 @@ + + std::vector<mojom::CSSSourcePtr> sources; + sources.push_back( + mojom::CSSSource::New(std::move(code), std::move(injection_key))); @@ -587:589, +600:601 @@ - std::move(code), std::move(injection_key), - ConvertStyleOriginToCSSOrigin(injection.origin), + std::move(sources), ConvertStyleOriginToCSSOrigin(injection.origin), @@ -651:655, +663:665 @@ - const int valid_schemes = UserScript::ValidUserScriptSchemes( - /*can_execute_script_everywhere=*/false); - const bool all_urls_includes_chrome_urls = - PermissionsData::AllUrlsIncludesChromeUrls(extension()->id()); + const int valid_schemes = + UserScript::ValidUserScriptSchemes(kScriptsCanExecuteEverywhere); @@ -658:661, +668:670 @@ - std::unique_ptr<UserScript> user_script = - ParseUserScript(*extension(), scripts[i], i, valid_schemes, - all_urls_includes_chrome_urls, &parse_error); + std::unique_ptr<UserScript> user_script = ParseUserScript( + *extension(), scripts[i], i, valid_schemes, &parse_error); @@ -680:681, +689:691 @@ - // Balanced in OnContentScriptFilesValidated or OnContentScriptsRegistered. + // Balanced in `OnContentScriptFilesValidated()` or + // `OnContentScriptsRegistered()`. @@ -699:700, +709:710 @@ - loader->AbortLoadForPendingScripts(std::move(ids_to_remove)); + loader->RemovePendingDynamicScriptIDs(std::move(ids_to_remove)); @@ -701:702, +711:712 @@ - Release(); // Matches the AddRef() in Run(). + Release(); // Matches the `AddRef()` in `Run()`. @@ -718:719, +728:729 @@ - Release(); // Matches the AddRef() in Run(). + Release(); // Matches the `AddRef()` in `Run()`. ``` The name of the file: chrome/common/extensions/api/scripting.idl Insertions: 2, Deletions: 2. ``` @@ -131:132, +131:132 @@ - callback ModifyContentScriptsCallback = void(); + callback RegisterContentScriptsCallback = void(); @@ -171:172, +171:172 @@ - optional ModifyContentScriptsCallback callback); + optional RegisterContentScriptsCallback callback); ``` The name of the file: extensions/browser/BUILD.gn Insertions: 34, Deletions: 0. ``` @@ +57:60 @@ + "api/api_resource.cc", + "api/api_resource.h", + "api/api_resource_manager.h", @@ +131:165 @@ + "api/device_permissions_manager.cc", + "api/device_permissions_manager.h", + "api/device_permissions_prompt.cc", + "api/device_permissions_prompt.h", + "api/execute_code_function.cc", + "api/execute_code_function.h", + "api/extension_types_utils.cc", + "api/extension_types_utils.h", + "api/extensions_api_client.cc", + "api/extensions_api_client.h", + "api/guest_view/app_view/app_view_guest_internal_api.cc", + "api/guest_view/app_view/app_view_guest_internal_api.h", + "api/guest_view/guest_view_internal_api.cc", + "api/guest_view/guest_view_internal_api.h", + "api/guest_view/web_view/web_view_internal_api.cc", + "api/guest_view/web_view/web_view_internal_api.h", + "api/hid/hid_api.cc", + "api/hid/hid_api.h", + "api/hid/hid_connection_resource.cc", + "api/hid/hid_connection_resource.h", + "api/hid/hid_device_manager.cc", + "api/hid/hid_device_manager.h", + "api/system_display/display_info_provider.cc", + "api/system_display/display_info_provider.h", + "api/system_display/system_display_api.cc", + "api/system_display/system_display_api.h", + "api/usb/usb_api.cc", + "api/usb/usb_api.h", + "api/usb/usb_device_manager.cc", + "api/usb/usb_device_manager.h", + "api/usb/usb_device_resource.cc", + "api/usb/usb_device_resource.h", + "api/web_contents_capture_client.cc", + "api/web_contents_capture_client.h", @@ +551:552 @@ + "//extensions/browser/api/virtual_keyboard_private:virtual_keyboard_delegate", @@ +593:594 @@ + "//services/device/public/cpp/usb:usb", ``` The name of the file: extensions/browser/api/BUILD.gn Insertions: 0, Deletions: 16. ``` @@ -14:17 @@ - "api_resource.cc", - "api_resource.h", - "api_resource_manager.h", @@ -19:35 @@ - "device_permissions_manager.cc", - "device_permissions_manager.h", - "device_permissions_prompt.cc", - "device_permissions_prompt.h", - "execute_code_function.cc", - "execute_code_function.h", - "extension_types_utils.cc", - "extension_types_utils.h", - "extensions_api_client.cc", - "extensions_api_client.h", - "guest_view/app_view/app_view_guest_internal_api.cc", - "guest_view/app_view/app_view_guest_internal_api.h", - "guest_view/guest_view_internal_api.cc", - "guest_view/guest_view_internal_api.h", - "guest_view/web_view/web_view_internal_api.cc", - "guest_view/web_view/web_view_internal_api.h", @@ -36:44, +17:19 @@ - # TODO(crbug.com/1206265): anything under hid/, storage/, system_display/ - # and usb/ should be moved out of this target. - "hid/hid_api.cc", - "hid/hid_api.h", - "hid/hid_connection_resource.cc", - "hid/hid_connection_resource.h", - "hid/hid_device_manager.cc", - "hid/hid_device_manager.h", + # TODO(crbug.com/1206265): anything under storage/ should be moved out of + # this target. @@ -63:80 @@ - "system_display/display_info_provider.cc", - "system_display/display_info_provider.h", - "system_display/system_display_api.cc", - "system_display/system_display_api.h", - "usb/usb_api.cc", - "usb/usb_api.h", - "usb/usb_device_manager.cc", - "usb/usb_device_manager.h", - "usb/usb_device_resource.cc", - "usb/usb_device_resource.h", - "web_contents_capture_client.cc", - "web_contents_capture_client.h", - ] - - configs += [ - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - "//build/config/compiler:no_size_t_to_int_warning", @@ -86:87 @@ - "//extensions/browser:browser_sources", @@ -90:91 @@ - "//services/device/public/cpp/usb:usb", @@ -96:98 @@ - "//components/guest_view/browser:browser", - "//components/guest_view/common:common", @@ -99:101 @@ - "//content/public/browser", - "//content/public/common", @@ -102:105 @@ - "//extensions/browser/api/virtual_keyboard_private:virtual_keyboard_delegate", - "//extensions/browser/guest_view/web_view/web_ui:web_ui", - "//extensions/common", @@ -109:110 @@ - "//services/device/public/cpp/usb", @@ -111:112 @@ - "//services/device/public/mojom:usb", ``` The name of the file: extensions/browser/extension_function_histogram_value.h Insertions: 2, Deletions: 1. ``` @@ -1618:1619, +1618:1620 @@ - SCRIPTING_REGISTERCONTENTSCRIPTS = 1556, + ACCESSIBILITY_PRIVATE_GETLOCALIZEDDOMKEYSTRINGFORKEYCODE = 1556, + SCRIPTING_REGISTERCONTENTSCRIPTS = 1557, ``` The name of the file: extensions/browser/extension_user_script_loader.cc Insertions: 3, Deletions: 3. ``` @@ -269:272, +269:272 @@ - void ExtensionUserScriptLoader::AbortLoadForPendingScripts( - std::set<std::string> script_ids) { - for (auto id : script_ids) + void ExtensionUserScriptLoader::RemovePendingDynamicScriptIDs( + const std::set<std::string>& script_ids) { + for (const auto& id : script_ids) ``` The name of the file: extensions/browser/extension_user_script_loader.h Insertions: 1, Deletions: 1. ``` @@ -57:58, +57:58 @@ - void AbortLoadForPendingScripts(std::set<std::string> script_ids); + void RemovePendingDynamicScriptIDs(const std::set<std::string>& script_ids); ``` The name of the file: extensions/common/manifest_handlers/content_scripts_handler.cc Insertions: 21, Deletions: 3. ``` @@ -92:95, +92:113 @@ - script_parsing::ParseMatchFlags(content_script.match_origin_as_fallback.get(), - content_script.match_about_blank.get(), - result.get()); + // match_origin_as_fallback + bool has_match_origin_as_fallback = false; + if (content_script.match_origin_as_fallback && + base::FeatureList::IsEnabled( + extensions_features::kContentScriptsMatchOriginAsFallback)) { + has_match_origin_as_fallback = true; + result->set_match_origin_as_fallback( + *content_script.match_origin_as_fallback + ? MatchOriginAsFallbackBehavior::kAlways + : MatchOriginAsFallbackBehavior::kNever); + } + + // match_about_blank + // Note: match_about_blank is ignored if |match_origin_as_fallback| was + // specified. + if (!has_match_origin_as_fallback && content_script.match_about_blank) { + result->set_match_origin_as_fallback( + *content_script.match_about_blank + ? MatchOriginAsFallbackBehavior::kMatchForAboutSchemeAndClimbTree + : MatchOriginAsFallbackBehavior::kNever); + } ``` The name of the file: extensions/common/utils/content_script_utils.cc Insertions: 2, Deletions: 30. ``` @@ +38:39 @@ + @@ +60:61 @@ + @@ -61:87 @@ - // static - void ParseMatchFlags(const bool* match_origin_as_fallback, - const bool* match_about_blank, - UserScript* result) { - // match_origin_as_fallback - bool has_match_origin_as_fallback = false; - if (match_origin_as_fallback && - base::FeatureList::IsEnabled( - extensions_features::kContentScriptsMatchOriginAsFallback)) { - has_match_origin_as_fallback = true; - result->set_match_origin_as_fallback( - *match_origin_as_fallback ? MatchOriginAsFallbackBehavior::kAlways - : MatchOriginAsFallbackBehavior::kNever); - } - - // match_about_blank - // Note: match_about_blank is ignored if |match_origin_as_fallback| was - // specified. - if (!has_match_origin_as_fallback && match_about_blank) { - result->set_match_origin_as_fallback( - *match_about_blank - ? MatchOriginAsFallbackBehavior::kMatchForAboutSchemeAndClimbTree - : MatchOriginAsFallbackBehavior::kNever); - } - } - @@ -97:98 @@ - // matches @@ -142:143 @@ - // exclude_matches @@ -170:171 @@ - // js @@ -181:182 @@ - // css ``` The name of the file: extensions/common/utils/content_script_utils.h Insertions: 0, Deletions: 10. ``` @@ -21:27 @@ - // Parses the `match_origin_as_fallback` and `match_about_blank` flags, and - // updates `result`. - void ParseMatchFlags(const bool* match_origin_as_fallback, - const bool* match_about_blank, - UserScript* result); - @@ -61:65 @@ - using OnScriptFilesValidatedCallback = - base::OnceCallback<void(std::unique_ptr<UserScriptList> scripts, - const absl::optional<std::string>& error)>; - ``` The name of the file: tools/metrics/histograms/enums.xml Insertions: 3, Deletions: 1. ``` @@ +2450:2455 @@ + <enum name="AndroidWebViewSafeModeResult"> + <int value="0" label="Success"/> + <int value="1" label="Unknown error"/> + </enum> + @@ +5618:5624 @@ + <enum name="AutofillErrorDialogType"> + <int value="0" label="VIRTUAL_CARD_TEMPORARY_ERROR"/> + <int value="1" label="VIRTUAL_CARD_PERMANENT_ERROR"/> + <int value="2" label="VIRTUAL_CARD_NOT_ELIGIBLE_ERROR"/> + </enum> + @@ +6002:6011 @@ + <int value="35" label="Virtual card suggestion selected"/> + <int value="36" label="Virtual card suggestion selected (once)"/> + <int value="37" label="Virtual card suggestion filled"/> + <int value="38" label="Virtual card suggestion filled (once)"/> + <int value="39" + label="About to be submitted with virtual card suggestion filled (once)"/> + <int value="40" label="Submitted with virtual card suggestion filled (once)"/> + <int value="41" label="Suggestions shown and included a virtual card"/> + <int value="42" label="Suggestions shown and included a virtual card (once)"/> @@ -6888:6889, +6908:6909 @@ - experimental config doesn't permit it to be BFCached."/> + experimental config doesn't permit it to be BFCached. (removed)"/> @@ +7120:7122 @@ + <int value="16" + label="Trace finalization started with a local output location"/> @@ +13758:13759 @@ + <int value="79" label="Javascript JIT"/> @@ +18248:18249 @@ + <int value="3" label="Template Launched"/> @@ +18267:18268 @@ + <int value="8" label="User switch by launching a template"/> @@ +24913:24916 @@ + <int value="867" label="DefaultJavaScriptJitSetting"/> + <int value="868" label="JavaScriptJitAllowedForSites"/> + <int value="869" label="JavaScriptJitBlockedForSites"/> @@ -27781:27782, +27809:27812 @@ - <int value="1556" label="SCRIPTING_REGISTERCONTENTSCRIPTS"/> + <int value="1556" + label="ACCESSIBILITY_PRIVATE_GETLOCALIZEDDOMKEYSTRINGFORKEYCODE"/> + <int value="1557" label="SCRIPTING_REGISTERCONTENTSCRIPTS"/> @@ +32992:33002 @@ + <int value="3938" label="XRFrameGetJointPose"/> + <int value="3939" label="XRFrameFillJointRadii"/> + <int value="3940" label="XRFrameFillPoses"/> + <int value="3941" label="WindowOpenNewPopupBehaviorMismatch"/> + <int value="3942" label="ExplicitPointerCaptureClickTargetDiff"/> + <int value="3943" label="ControlledNonBlobURLWorkerWillBeUncontrolled"/> + <int value="3944" label="MediaMetaThemeColor"/> + <int value="3945" label="ClientHintsUABitness"/> + <int value="3946" label="DifferentPerspectiveCBOrParent"/> + <int value="3947" label="WebkitImageSet"/> @@ +33108:33109 @@ + <int value="87" label="ClientHintUABitness"/> @@ +33157:33159 @@ + <int value="17" label="Chrome Labs"/> + <int value="18" label="Bento Bar"/> @@ +33349:33370 @@ + <int value="30" + label="Tapped the 'Following' option inside the Feed's 'Manage' + interstitial."/> + <int value="31" + label="User tapped to follow a web feed on the management surface."/> + <int value="32" + label="User tapped to unfollow a web feed on the management surface."/> + <int value="33" label="User tapped to follow using the follow accelerator."/> + <int value="34" + label="User tapped to follow using the snackbar 'try again' option."/> + <int value="35" + label="User tapped to follow using the snackbar, after successfully + unfollowing."/> + <int value="36" + label="User tapped to unfollow using the snackbar 'try again' option."/> + <int value="37" + label="After following an active web feed, the user tapped to go to + feed using the post-follow help dialog."/> + <int value="38" + label="After following an active web feed, the user tapped to dismiss + the post-follow help dialog."/> @@ +34873:34877 @@ + <int value="5" label="Close sync screen on advance sync settings"/> + <int value="6" label="Show sign in screen"/> + <int value="7" label="Close sign in screen with sign in"/> + <int value="8" label="Close sign in screen without sign in"/> @@ +39117:39119 @@ + <int value="-1910305783" + label="Navigation.StartToCommit.SameProcess.NewNavigation"/> @@ +39132:39133 @@ + <int value="-1433928548" label="WebCore.FindInPage.TaskDuration"/> @@ +39140:39142 @@ + <int value="-1277093818" + label="Net.URLLoaderThrottleExecutionTime.WillStartRequest"/> @@ +39148:39151 @@ + <int value="-919977005" label="DevTools.DeveloperResourceLoaded"/> + <int value="-855312845" + label="Net.URLLoaderThrottleExecutionTime.WillProcessResponse"/> @@ +39153:39155 @@ + <int value="-763978419" + label="DocumentEventTiming.BeforeUnloadDialogDuration.ByNavigation"/> @@ +39160:39162 @@ + <int value="-436781330" + label="Net.URLLoaderThrottleExecutionTime.BeforeWillProcessResponse"/> @@ +39166:39167 @@ + <int value="-343220158" label="Compositing.Renderer.LayersUpdateTime"/> @@ +39171:39172 @@ + <int value="19727358" label="DataUse.BytesReceived2.Delegate"/> @@ +39196:39198 @@ + <int value="759446272" + label="RendererScheduler.QueueingDurationPerQueueType.Input"/> @@ +39201:39202 @@ + <int value="1096524200" label="DevTools.IssueCreated"/> @@ +39204:39205 @@ + <int value="1193017729" label="Compositing.ResourcePoolMemoryUsage.Renderer"/> @@ +39207:39208 @@ + <int value="1295093746" label="Net.SSL_Connection_Latency_TLS13Experiment"/> @@ +39210:39212 @@ + <int value="1386149670" label="Navigation.StartToCommit.NewNavigation"/> + <int value="1488162221" label="Blink.UseCounter.File.Features"/> @@ +39219:39220 @@ + <int value="1721222685" label="Blink.UseCounter.MainFrame.Features"/> @@ -43671:43672, +43761:43762 @@ - <int value="13" label="Remove language from 'Translate' list"/> + <int value="13" label="Remove language from 'Always Translate' list"/> @@ +43766:43774 @@ + <enum name="LanguageSettingsAppLanguagePromptAction"> + <int value="0" label="Dismissed via cancel button"/> + <int value="1" label="Dismissed via system back"/> + <int value="2" label="Ok button changed language"/> + <int value="3" label="Ok button same language"/> + <int value="4" label="Other"/> + </enum> + @@ +44728:44737 @@ + <enum name="LinuxWaylandShellName"> + <int value="0" label="zaura_shell"/> + <int value="1" label="gtk_shell1"/> + <int value="2" label="org_kde_plasma_shell"/> + <int value="3" label="xdg_wm_base"/> + <int value="4" label="xdg_shell_v6"/> + <int value="5" label="zwlr_layer_shell_v1"/> + </enum> + @@ +45110:45111 @@ + <int value="-2141575276" label="FileHandlingIcons:enabled"/> @@ +45790:45792 @@ + <int value="-1589720671" + label="DebugHistoryInterventionNoUserActivation:disabled"/> @@ +46082:46083 @@ + <int value="-1369613781" label="FileHandlingIcons:disabled"/> @@ +46167:46168 @@ + <int value="-1303417000" label="UseStorkSmdsServerAddress:enabled"/> @@ +46213:46214 @@ + <int value="-1265627803" label="WebAppEnableManifestId:enabled"/> @@ +46408:46409 @@ + <int value="-1119552494" label="SyncTrustedVaultPassphraseRecovery:disabled"/> @@ +46809:46810 @@ + <int value="-772040705" label="ChromeWhatsNewInMainMenuNewBadge:disabled"/> @@ +46956:46957 @@ + <int value="-650388312" label="ClipboardHistoryScreenshotNudge:enabled"/> @@ +47038:47039 @@ + <int value="-580897686" label="SharedHighlightingAmp:enabled"/> @@ +47095:47096 @@ + <int value="-523155003" label="PhoneHubCameraRoll:disabled"/> @@ +47136:47137 @@ + <int value="-492972850" label="SettingsAppNotificationSettings:disabled"/> @@ +47203:47204 @@ + <int value="-428556995" label="DesktopPWAsTabStripSettings:enabled"/> @@ +47361:47362 @@ + <int value="-291221380" label="SmartLockUIRevamp:disabled"/> @@ +47405:47406 @@ + <int value="-255157394" label="ButtonARCNetworkDiagnostics:enabled"/> @@ +47440:47442 @@ + <int value="-216189310" + label="DebugHistoryInterventionNoUserActivation:enabled"/> @@ +47662:47663 @@ + <int value="-27287076" label="DesktopPWAsTabStripSettings:disabled"/> @@ +47724:47725 @@ + <int value="24332306" label="ButtonARCNetworkDiagnostics:disabled"/> @@ +47735:47736 @@ + <int value="33588676" label="TranslateAssistContent:enabled"/> @@ +47881:47882 @@ + <int value="158490417" label="PhoneHubCameraRoll:enabled"/> @@ +47927:47928 @@ + <int value="202966815" label="SettingsAppNotificationSettings:enabled"/> @@ +47948:47949 @@ + <int value="223573347" label="BentoBar:disabled"/> @@ +48061:48062 @@ + <int value="325489620" label="WebAppEnableManifestId:disabled"/> @@ +48099:48100 @@ + <int value="353898777" label="ClipboardHistoryScreenshotNudge:disabled"/> @@ +48138:48139 @@ + <int value="382478170" label="SemanticColorDebugOverride:disabled"/> @@ +48176:48177 @@ + <int value="414780410" label="SyncTrustedVaultPassphraseRecovery:enabled"/> @@ +48290:48291 @@ + <int value="508272289" label="SharedHighlightingAmp:disabled"/> @@ +48420:48421 @@ + <int value="624783596" label="SamePartyCookiesConsideredFirstParty:enabled"/> @@ +48703:48704 @@ + <int value="854391022" label="SmartLockUIRevamp:enabled"/> @@ +48960:48961 @@ + <int value="1090442943" label="SemanticColorDebugOverride:enabled"/> @@ +49009:49010 @@ + <int value="1122820469" label="ArcImageCopyPasteCompat:enabled"/> @@ +49047:49049 @@ + <int value="1154722867" label="TranslateAssistContent:disabled"/> + <int value="1154790184" label="ScanAppMultiPageScan:enabled"/> @@ +49163:49164 @@ + <int value="1251663392" label="ArcImageCopyPasteCompat:disabled"/> @@ +49171:49172 @@ + <int value="1257663962" label="CommercePriceTracking:disabled"/> @@ +49252:49253 @@ + <int value="1316142697" label="canvas-2d-layers"/> @@ +49273:49275 @@ + <int value="1332891404" + label="SamePartyCookiesConsideredFirstParty:disabled"/> @@ +49386:49387 @@ + <int value="1420007919" label="SyncTrustedVaultPassphrasePromo:disabled"/> @@ +49393:49395 @@ + <int value="1429031731" + label="CrossOriginEmbedderPolicyCredentialless:enabled"/> @@ +49548:49549 @@ + <int value="1569982806" label="BentoBar:enabled"/> @@ +49630:49631 @@ + <int value="1635755615" label="ScanAppMultiPageScan:disabled"/> @@ +49680:49681 @@ + <int value="1678259296" label="ChromeWhatsNewInMainMenuNewBadge:enabled"/> @@ +49832:49834 @@ + <int value="1814039202" + label="CrossOriginEmbedderPolicyCredentialless:disabled"/> @@ +50128:50129 @@ + <int value="2043794900" label="CommercePriceTracking:enabled"/> @@ +50183:50184 @@ + <int value="2092538671" label="UseStorkSmdsServerAddress:disabled"/> @@ +50223:50224 @@ + <int value="2129814401" label="SyncTrustedVaultPassphrasePromo:enabled"/> @@ +53229:53230 @@ + <int value="9" label="SendTabToSelf"/> @@ +59635:59642 @@ + <enum name="OptimizationGuideReadCacheResult"> + <int value="0" label="Unknown"/> + <int value="1" label="Success"/> + <int value="2" label="Invalid protobuf"/> + <int value="3" label="Base64 decoding error"/> + </enum> + @@ +59838:59841 @@ + <int value="609" label="Search: Quick Answers Definition"/> + <int value="610" label="Search: Quick Answers Translation"/> + <int value="611" label="Search: Quick Answers Unit Conversion"/> @@ -59862:59863, +60030:60032 @@ - <int value="705" label="On Startup"/> + <int value="705" label="On Startup (Deprecated)"/> + <int value="706" label="App Notifications"/> @@ +64097:64101 @@ + <int value="12" label="kSmallAnimation"/> + <int value="13" label="kMediumAnimation"/> + <int value="14" label="kSmallMainThreadAnimation"/> + <int value="15" label="kMediumMainThreadAnimation"/> @@ +64545:64546 @@ + <int value="17" label="kNavigationNotCommitted"/> @@ +65949:65950 @@ + <int value="19" label="kProfileCreationFlow"/> @@ +71197:71203 @@ + <enum name="ScheduledTaskInvokedReason"> + <int value="0" label="Stopped"/> + <int value="1" label="Rescheduled"/> + <int value="2" label="Ready"/> + </enum> + @@ -77030:77031, +77211:77213 @@ - <int value="7" label="Survey already exists"/> + <int value="7" label="Survey already exists [removed]"/> + <int value="8" label="First time user"/> @@ +77566:77567 @@ + <int value="7" label="Sync trusted vault recoverability degraded"/> @@ +85021:85022 @@ + <int value="-2061366287" label="chrome://dev-ui-loader/"/> @@ +85026:85027 @@ + <int value="-2020874093" label="chrome://lock-reauth/"/> @@ +85028:85029 @@ + <int value="-1949142440" label="chrome://smb-credentials-dialog/"/> @@ +85035:85036 @@ + <int value="-1737358104" label="chrome://account-migration-welcome/"/> @@ +85039:85040 @@ + <int value="-1697612520" label="chrome://print-management/"/> @@ +85043:85044 @@ + <int value="-1649429396" label="chrome://chrome-signin/edu-coexistence/"/> @@ +85046:85047 @@ + <int value="-1634933990" label="chrome://web-footer-experiment/"/> @@ +85049:85050 @@ + <int value="-1493762713" label="chrome://settings/cookies/"/> @@ +85053:85054 @@ + <int value="-1401057585" label="chrome://account-manager-error/"/> @@ +85060:85061 @@ + <int value="-1259871417" label="chrome://browser-switch/"/> @@ +85063:85065 @@ + <int value="-1203248739" label="chrome://scanning/"/> + <int value="-1198437953" label="chrome://download-shelf.top-chrome/"/> @@ +85068:85069 @@ + <int value="-1087461470" label="chrome://management/"/> @@ +85075:85076 @@ + <int value="-940484840" label="chrome://arc-power-control/"/> @@ +85091:85092 @@ + <int value="-652517395" label="chrome://signin-reauth/"/> @@ +85097:85099 @@ + <int value="-623121238" label="chrome://arc-graphics-tracing/"/> + <int value="-614294009" label="chrome://crostini-credits/"/> @@ +85101:85102 @@ + <int value="-548156607" label="chrome://feedback/"/> @@ +85108:85110 @@ + <int value="-443189279" label="chrome://enterprise-profile-welcome/"/> + <int value="-394586044" label="chrome://confirm-password-change/"/> @@ +85121:85122 @@ + <int value="-12304525" label="chrome://tab-strip/"/> @@ +85131:85132 @@ + <int value="84832110" label="chrome://fileicon/"/> @@ +85137:85138 @@ + <int value="259900466" label="chrome://signin-dice-web-intercept/"/> @@ +85141:85142 @@ + <int value="361250371" label="chrome://nearby/"/> @@ +85143:85146 @@ + <int value="399773145" label="chrome://commander/"/> + <int value="436626245" label="chrome://settings/content/cookies/"/> + <int value="454041716" label="chrome://new-tab-page-third-party/"/> @@ +85147:85148 @@ + <int value="507734656" label="chrome://profile-customization/"/> @@ +85151:85152 @@ + <int value="584098160" label="chrome://profile-picker/"/> @@ +85153:85154 @@ + <int value="634002171" label="chrome://projector-selfie-cam/"/> @@ +85156:85157 @@ + <int value="662045902" label="chrome://smb-share-dialog/"/> @@ +85159:85161 @@ + <int value="748142712" label="chrome://crostini-upgrader/"/> + <int value="749881882" label="chrome://webuijserror/"/> @@ +85165:85166 @@ + <int value="864711974" label="chrome://emoji-picker/"/> @@ +85172:85173 @@ + <int value="1050328415" label="chrome://diagnostics/"/> @@ +85177:85179 @@ + <int value="1134924982" label="chrome://app-icon/"/> + <int value="1145000455" label="chrome://arc-overview-tracing/"/> @@ +85184:85185 @@ + <int value="1272316136" label="chrome://image/"/> @@ +85191:85192 @@ + <int value="1356087814" label="chrome://add-supervision/"/> @@ +85194:85195 @@ + <int value="1397728473" label="chrome://crostini-installer/"/> @@ +85197:85198 @@ + <int value="1411665301" label="chrome://lock-network/"/> @@ +85206:85208 @@ + <int value="1531448147" + label="chrome://urgent-password-expiry-notification/"/> @@ +85217:85218 @@ + <int value="1673299360" label="chrome://tab-search.top-chrome/"/> @@ +85224:85225 @@ + <int value="1834776370" label="chrome://password-change/"/> @@ +85227:85228 @@ + <int value="1928106753" label="chrome://app-disabled/"/> @@ +85229:85230 @@ + <int value="1963964324" label="chrome://read-later.top-chrome/"/> @@ +85234:85235 @@ + <int value="2120829362" label="chrome://account-manager-welcome/"/> @@ +87613:87614 @@ + <int value="54" label="Show Chrome What's New"/> ```

      To view, visit change 2892136. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I0e842230917ce27052968719f3af71311d418ca2
      Gerrit-Change-Number: 2892136
      Gerrit-PatchSet: 20
      Gerrit-Owner: Kelvin Jiang <kelvi...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Devlin <rdevlin...@chromium.org>
      Gerrit-Reviewer: Kelvin Jiang <kelvi...@chromium.org>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-MessageType: merged
      Reply all
      Reply to author
      Forward
      0 new messages