0

[Code Health] Cleanup AvoidEarlyExtensionScriptContextCreation feature

Fixed: 356624444
Change-Id: I5d0c82abcf885c1396a59c7dff5a50012a4d3f32
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6172442
Reviewed-by: David Bertoni <dbertoni@chromium.org>
Commit-Queue: Irina Fedorova <irfedorova@google.com>
Cr-Commit-Position: refs/heads/main@{#1407788}
This commit is contained in:
Irina
2025-01-17 01:37:27 -08:00
committed by Chromium LUCI CQ
parent 421580c010
commit f1ddcf9bda
4 changed files with 7 additions and 30 deletions

@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "extensions/common/extension_features.h"
#include "base/feature_list.h"
namespace extensions_features {
@ -57,10 +58,6 @@ BASE_FEATURE(kAllowWithholdingExtensionPermissionsOnInstall,
"AllowWithholdingExtensionPermissionsOnInstall",
base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kAvoidEarlyExtensionScriptContextCreation,
"AvoidEarlyExtensionScriptContextCreation",
base::FEATURE_ENABLED_BY_DEFAULT);
BASE_FEATURE(kCheckingNoExtensionIdInExtensionIpcs,
"EMF_NO_EXTENSION_ID_FOR_EXTENSION_SOURCE",
base::FEATURE_ENABLED_BY_DEFAULT);

@ -78,11 +78,6 @@ BASE_DECLARE_FEATURE(kApiEnterpriseReportingPrivateReportDataMaskingEvent);
// requested host permissions by default.
BASE_DECLARE_FEATURE(kAllowWithholdingExtensionPermissionsOnInstall);
// If enabled, calls RenderFrame::SetAllowsCrossBrowsingInstanceFrameLookup() in
// DidCreateScriptContext() instead of DidCommitProvisionalLoad() to avoid
// creating the script context too early which can be bad for performance.
BASE_DECLARE_FEATURE(kAvoidEarlyExtensionScriptContextCreation);
// When enabled, then bad_message::ReceivedBadMessage will be called when
// browser receives an IPC from a content script and the IPC that unexpectedly
// claims to act on behalf of a given extension id, (i.e. even if the browser

@ -406,19 +406,6 @@ void ExtensionFrameHelper::ReadyToCommitNavigation(
// TODO(devlin): Add constants for main world id, no extension group.
}
void ExtensionFrameHelper::DidCommitProvisionalLoad(
ui::PageTransition transition) {
if (base::FeatureList::IsEnabled(
extensions_features::kAvoidEarlyExtensionScriptContextCreation)) {
return;
}
// Grant cross browsing instance frame lookup if we are an extension. This
// should match the conditions in FindFrame.
content::RenderFrame* frame = render_frame();
if (GetExtensionFromFrame(frame))
frame->SetAllowsCrossBrowsingInstanceFrameLookup();
}
void ExtensionFrameHelper::DidCreateScriptContext(
v8::Local<v8::Context> context,
int32_t world_id) {
@ -591,13 +578,12 @@ void ExtensionFrameHelper::DidClearWindowObject() {
// Calling this multiple times in a page load is safe because
// SetAllowsCrossBrowsingInstanceFrameLookup() just sets a bool to true on the
// SecurityOrigin.
if (base::FeatureList::IsEnabled(
extensions_features::kAvoidEarlyExtensionScriptContextCreation)) {
// Grant cross browsing instance frame lookup if we are an extension. This
// should match the conditions in FindFrame.
content::RenderFrame* frame = render_frame();
if (GetExtensionFromFrame(frame))
frame->SetAllowsCrossBrowsingInstanceFrameLookup();
// Grant cross browsing instance frame lookup if we are an extension. This
// should match the conditions in FindFrame.
content::RenderFrame* frame = render_frame();
if (GetExtensionFromFrame(frame)) {
frame->SetAllowsCrossBrowsingInstanceFrameLookup();
}
}

@ -186,7 +186,6 @@ class ExtensionFrameHelper
void DidCreateNewDocument() override;
void ReadyToCommitNavigation(
blink::WebDocumentLoader* document_loader) override;
void DidCommitProvisionalLoad(ui::PageTransition transition) override;
void DidCreateScriptContext(v8::Local<v8::Context>,
int32_t world_id) override;
void WillReleaseScriptContext(v8::Local<v8::Context>,