[AUTO][FILECONTROL] - version 128.0.6613.40

This commit is contained in:
uazo
2024-08-15 02:39:02 +00:00
committed by github-actions[bot]
parent 888b4cfc7e
commit 06ca3a807c
135 changed files with 5074 additions and 4030 deletions
+1 -1
View File
@@ -1 +1 @@
127.0.6533.120
128.0.6613.40
@@ -6,6 +6,7 @@
#include <cstddef>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
@@ -82,6 +83,7 @@
#include "components/url_matcher/url_matcher.h"
#include "components/url_matcher/url_util.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
@@ -462,6 +464,7 @@ void AwContentBrowserClient::AllowCertificateError(
base::OnceClosure AwContentBrowserClient::SelectClientCertificate(
content::BrowserContext* browser_context,
int process_id,
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList client_certs,
@@ -891,11 +894,17 @@ bool AwContentBrowserClient::HandleExternalProtocol(
// We don't need to care for |security_options| as the factories constructed
// below are used only for navigation.
// We also don't care about retrieving cookies in this case because these will
// be schemes unrelated to the regular network stack so it doesn't make sense
// to look for cookies. Providing a nullopt for the cookie manager lets
// the AwProxyingURLLoaderFactory know to skip that work.
if (content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
// Manages its own lifetime.
new android_webview::AwProxyingURLLoaderFactory(
frame_tree_node_id, std::move(receiver), mojo::NullRemote(),
true /* intercept_only */, std::nullopt /* security_options */,
std::nullopt /* cookie_manager */, nullptr /* cookie_access_policy */,
std::nullopt /* isolation_info*/, frame_tree_node_id,
std::move(receiver), mojo::NullRemote(), true /* intercept_only */,
std::nullopt /* security_options */,
nullptr /* xrw_allowlist_matcher */, std::move(browser_context_handle),
std::nullopt /* navigation_id */);
} else {
@@ -908,7 +917,10 @@ bool AwContentBrowserClient::HandleExternalProtocol(
browser_context_handle) {
// Manages its own lifetime.
new android_webview::AwProxyingURLLoaderFactory(
frame_tree_node_id, std::move(receiver), mojo::NullRemote(),
std::nullopt /* cookie_manager */,
nullptr /* cookie_access_policy */,
std::nullopt /* isolation_info*/, frame_tree_node_id,
std::move(receiver), mojo::NullRemote(),
true /* intercept_only */,
std::nullopt /* security_options */,
nullptr /* xrw_allowlist_matcher */,
@@ -1046,6 +1058,17 @@ void AwContentBrowserClient::WillCreateURLLoaderFactory(
scoped_refptr<AwBrowserContextIoThreadHandle> browser_context_handle =
base::MakeRefCounted<AwBrowserContextIoThreadHandle>(
static_cast<AwBrowserContext*>(browser_context));
mojo::PendingRemote<network::mojom::CookieManager> cookie_manager;
browser_context->GetDefaultStoragePartition()
->GetNetworkContext()
->GetCookieManager(cookie_manager.InitWithNewPipeAndPassReceiver());
AwBrowserContext* aw_browser_context =
static_cast<AwBrowserContext*>(browser_context);
AwCookieAccessPolicy* cookie_access_policy =
aw_browser_context->GetCookieManager()->cookie_access_policy();
if (frame) {
auto security_options =
std::make_optional<AwProxyingURLLoaderFactory::SecurityOptions>();
@@ -1075,21 +1098,21 @@ void AwContentBrowserClient::WillCreateURLLoaderFactory(
content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(&AwProxyingURLLoaderFactory::CreateProxy,
frame->GetFrameTreeNodeId(), std::move(proxied_receiver),
std::move(target_factory_remote), security_options,
std::move(xrw_allowlist_matcher),
std::move(browser_context_handle), navigation_id));
base::BindOnce(
&AwProxyingURLLoaderFactory::CreateProxy, std::move(cookie_manager),
cookie_access_policy, isolation_info, frame->GetFrameTreeNodeId(),
std::move(proxied_receiver), std::move(target_factory_remote),
security_options, std::move(xrw_allowlist_matcher),
std::move(browser_context_handle), navigation_id));
} else {
// A service worker and worker subresources set nullptr to |frame|, and
// work without seeing the AllowUniversalAccessFromFileURLs setting. So,
// we don't pass a valid |security_options| here.
AwBrowserContext* aw_browser_context =
static_cast<AwBrowserContext*>(browser_context);
content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(
&AwProxyingURLLoaderFactory::CreateProxy,
&AwProxyingURLLoaderFactory::CreateProxy, std::move(cookie_manager),
cookie_access_policy, isolation_info,
content::RenderFrameHost::kNoFrameTreeNodeId,
std::move(proxied_receiver), std::move(target_factory_remote),
std::nullopt /* security_options */,
@@ -1191,6 +1214,14 @@ void AwContentBrowserClient::LogWebFeatureForCurrentPage(
render_frame_host, feature);
}
void AwContentBrowserClient::LogWebDXFeatureForCurrentPage(
content::RenderFrameHost* render_frame_host,
blink::mojom::WebDXFeature feature) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
page_load_metrics::MetricsWebContentsObserver::RecordFeatureUsage(
render_frame_host, feature);
}
content::ContentBrowserClient::PrivateNetworkRequestPolicyOverride
AwContentBrowserClient::ShouldOverridePrivateNetworkRequestPolicy(
content::BrowserContext* browser_context,
@@ -6,8 +6,11 @@
#include "android_webview/common/aw_switches.h"
#include "base/base_paths_android.h"
#include "base/check.h"
#include "base/feature_list.h"
#include "base/memory/raw_ref.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/path_service.h"
#include "components/history/core/browser/features.h"
@@ -37,6 +40,12 @@ class AwFeatureOverrides {
AwFeatureOverrides& operator=(const AwFeatureOverrides& other) = delete;
~AwFeatureOverrides() {
for (const auto& field_trial_override : field_trial_overrides_) {
feature_list_->RegisterFieldTrialOverride(
field_trial_override.feature->name,
field_trial_override.override_state,
field_trial_override.field_trial);
}
feature_list_->RegisterExtraFeatureOverrides(std::move(overrides_));
}
@@ -54,9 +63,29 @@ class AwFeatureOverrides {
base::FeatureList::OverrideState::OVERRIDE_DISABLE_FEATURE);
}
// Enable or disable a feature with a field trial. This can be used for
// setting feature parameters.
void OverrideFeatureWithFieldTrial(
const base::Feature& feature,
base::FeatureList::OverrideState override_state,
base::FieldTrial* field_trial) {
field_trial_overrides_.emplace_back(FieldTrialOverride{
.feature = raw_ref(feature),
.override_state = override_state,
.field_trial = field_trial,
});
}
private:
struct FieldTrialOverride {
raw_ref<const base::Feature> feature;
base::FeatureList::OverrideState override_state;
raw_ptr<base::FieldTrial> field_trial;
};
base::raw_ref<base::FeatureList> feature_list_;
std::vector<base::FeatureList::FeatureOverrideInfo> overrides_;
std::vector<FieldTrialOverride> field_trial_overrides_;
};
} // namespace
@@ -83,14 +112,6 @@ void AwFieldTrials::RegisterFeatureOverrides(base::FeatureList* feature_list) {
aw_feature_overrides.DisableFeature(
net::features::kThirdPartyStoragePartitioning);
if (!base::FeatureList::IsEnabled(
mojo::features::kMojoFixAssociatedHandleLeak)) {
// Disable support for partitioning blob URLs if the bug fix that prevents
// blob URL creation from hanging under certain conditions isn't enabled.
aw_feature_overrides.DisableFeature(
net::features::kSupportPartitionedBlobUrl);
}
// Disable the passthrough on WebView.
aw_feature_overrides.DisableFeature(
::features::kDefaultPassthroughCommandDecoder);
@@ -105,6 +126,10 @@ void AwFieldTrials::RegisterFeatureOverrides(base::FeatureList* feature_list) {
// Disable fenced frames on WebView.
aw_feature_overrides.DisableFeature(blink::features::kFencedFrames);
// Disable FLEDGE on WebView.
aw_feature_overrides.DisableFeature(blink::features::kAdInterestGroupAPI);
aw_feature_overrides.DisableFeature(blink::features::kFledge);
// Disable low latency overlay for WebView. There is currently no plan to
// enable these optimizations in WebView though they are not fundamentally
// impossible.
@@ -205,9 +230,26 @@ void AwFieldTrials::RegisterFeatureOverrides(base::FeatureList* feature_list) {
aw_feature_overrides.DisableFeature(
safe_browsing::kSafeBrowsingNewGmsApiForBrowseUrlDatabaseCheck);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDebugBlindauth)) {
aw_feature_overrides.EnableFeature(net::features::kEnableIpProtectionProxy);
// PaintHolding for OOPIFs. This should be a no-op since WebView doesn't use
// site isolation but field trial testing doesn't indicate that. Revisit when
// enabling site isolation. See crbug.com/356170748.
aw_feature_overrides.DisableFeature(blink::features::kPaintHoldingForIframes);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugBsa)) {
// Feature parameters can only be set via a field trial.
const char kTrialName[] = "StudyDebugBsa";
const char kGroupName[] = "GroupDebugBsa";
base::FieldTrial* field_trial =
base::FieldTrialList::CreateFieldTrial(kTrialName, kGroupName);
// If field_trial is null, there was some unexpected name conflict.
CHECK(field_trial);
base::FieldTrialParams params;
params.emplace(net::features::kIpPrivacyTokenServer.name,
"https://staging-phosphor-pa.sandbox.googleapis.com");
base::AssociateFieldTrialParams(kTrialName, kGroupName, params);
aw_feature_overrides.OverrideFeatureWithFieldTrial(
net::features::kEnableIpProtectionProxy,
base::FeatureList::OverrideState::OVERRIDE_ENABLE_FEATURE, field_trial);
aw_feature_overrides.EnableFeature(network::features::kMaskedDomainList);
}
@@ -215,4 +257,17 @@ void AwFieldTrials::RegisterFeatureOverrides(base::FeatureList* feature_list) {
// WebView.
// TODO(b/344852824): Enable the feature for WebView
aw_feature_overrides.DisableFeature(::features::kDIPS);
// Async Safe Browsing check will be rolled out together with
// kHashPrefixRealTimeLookups on WebView.
aw_feature_overrides.DisableFeature(
safe_browsing::kSafeBrowsingAsyncRealTimeCheck);
// WebView does not currently support the Permissions API (crbug.com/490120)
aw_feature_overrides.DisableFeature(::features::kWebPermissionsApi);
// TODO(crbug.com/356827071): Enable the feature for WebView.
// Disable PlzDedicatedWorker as a workaround for crbug.com/356827071.
// Otherwise, importScripts fails on WebView.
aw_feature_overrides.DisableFeature(blink::features::kPlzDedicatedWorker);
}
@@ -585,7 +585,7 @@ by a child template that "extends" this file.
android:excludeFromRecents="true"
android:autoRemoveFromRecents="true"
android:windowSoftInputMode="stateHidden|adjustPan"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode"
{% endblock %}>
</activity>
<activity android:name="org.chromium.chrome.browser.firstrun.TabbedModeFirstRunActivity"
@@ -603,24 +603,24 @@ by a child template that "extends" this file.
android:theme="@style/Theme.AppCompat.NoActionBar">
</activity>
{% endif %}
<activity android:name="org.chromium.chrome.browser.signin.SigninAndHistoryOptInActivity"
android:theme="@style/Theme.Chromium.SigninAndHistoryOptInActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize"
<activity android:name="org.chromium.chrome.browser.signin.SigninAndHistorySyncActivity"
android:theme="@style/Theme.Chromium.SigninAndHistorySyncActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode"
android:exported="false">
</activity>
<activity android:name="org.chromium.chrome.browser.signin.SyncConsentActivity"
android:theme="@style/Theme.Chromium.DialogWhenLarge"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode"
android:exported="false">
</activity>
<activity android:name="org.chromium.chrome.browser.device_lock.DeviceLockActivity"
android:theme="@style/Theme.Chromium.DialogWhenLarge"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode"
android:exported="false">
</activity>
<activity android:name="org.chromium.chrome.browser.settings.SettingsActivity"
android:theme="@style/Theme.Chromium.Settings"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode"
android:label="@string/settings"
android:exported="false">
</activity>
@@ -636,21 +636,21 @@ by a child template that "extends" this file.
android:theme="@style/Theme.Chromium.Activity.Fullscreen"
android:exported="false"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize">
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode">
</activity>
<activity android:name="org.chromium.chrome.browser.app.bookmarks.BookmarkEditActivity"
android:theme="@style/Theme.Chromium.DialogWhenLarge"
android:windowSoftInputMode="stateHidden"
android:exported="false"
android:label="@string/edit_bookmark"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize">
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode">
</activity>
<activity android:name="org.chromium.chrome.browser.app.bookmarks.BookmarkFolderPickerActivity"
android:theme="@style/Theme.Chromium.DialogWhenLarge"
android:windowSoftInputMode="stateAlwaysHidden"
android:label="@string/bookmark_choose_folder"
android:exported="false"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize">
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode">
</activity>
<!-- Activities for downloads. -->
@@ -665,7 +665,7 @@ by a child template that "extends" this file.
android:theme="@style/Theme.Chromium.Activity.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
android:exported="false"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize">
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode">
</activity>
<!-- Activities for feed. -->
@@ -673,13 +673,13 @@ by a child template that "extends" this file.
android:theme="@style/Theme.Chromium.Settings"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
android:exported="false"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize">
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode">
</activity>
<activity android:name="org.chromium.chrome.browser.app.feed.followmanagement.FollowManagementActivity"
android:theme="@style/Theme.Chromium.Settings"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
android:exported="false"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize">
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode">
<intent-filter>
<action android:name="org.chromium.chrome.browser.app.feed.followmanagement.FollowManagementActivity.ACTIVATE" />
<category android:name="android.intent.category.DEFAULT" />
@@ -691,7 +691,7 @@ by a child template that "extends" this file.
android:theme="@style/Theme.Chromium.Activity.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
android:exported="false"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize">
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode">
</activity>
<!-- Activities for history. -->
@@ -699,7 +699,7 @@ by a child template that "extends" this file.
android:theme="@style/Theme.Chromium.Activity.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
android:exported="false"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize">
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode">
</activity>
<!--
@@ -972,7 +972,7 @@ by a child template that "extends" this file.
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:windowSoftInputMode="adjustResize"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize|uiMode"
android:hardwareAccelerated="false" />
<!-- GcmTaskService for registration for Invalidations. Not actually implemented anymore. -->
@@ -1320,6 +1320,13 @@ by a child template that "extends" this file.
android:grantUriPermissions="true">
</provider>
<!-- Provider for incognito pdf page. -->
<provider android:name="org.chromium.chrome.browser.pdf.PdfContentProvider"
android:authorities="{{ manifest_package }}.PdfContentProvider"
android:exported="false"
android:grantUriPermissions="true">
</provider>
<!-- Disables at startup init of Emoji2. See http://crbug.com/1205141 -->
<provider
android:authorities="{{ manifest_package }}.androidx-startup"
@@ -12,6 +12,8 @@
#include <vector>
#include "base/barrier_closure.h"
#include "base/containers/flat_set.h"
#include "base/containers/to_vector.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
@@ -21,6 +23,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/task/bind_post_task.h"
#include "base/task/thread_pool.h"
@@ -74,6 +77,7 @@
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/share/share_history.h"
#include "chrome/browser/share/share_ranking.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/browser/sync/sync_service_factory.h"
@@ -93,6 +97,7 @@
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/browsing_data/content/browsing_data_helper.h"
#include "components/content_settings/core/browser/content_settings_registry.h"
#include "components/content_settings/core/browser/content_settings_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
@@ -114,6 +119,7 @@
#include "components/open_from_clipboard/clipboard_recent_content.h"
#include "components/password_manager/core/browser/features/password_features.h"
#include "components/password_manager/core/browser/features/password_manager_features_util.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/password_store/password_store_interface.h"
#include "components/password_manager/core/browser/password_store/smart_bubble_stats_store.h"
#include "components/payments/content/payment_manifest_web_data_service.h"
@@ -125,6 +131,12 @@
#include "components/reading_list/core/reading_list_model.h"
#include "components/safe_browsing/core/browser/verdict_cache_manager.h"
#include "components/search_engines/template_url_service.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/base/gaia_id_hash.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/accounts_in_cookie_jar_info.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_utils.h"
#include "components/sync/service/sync_service.h"
#include "components/sync/service/sync_user_settings.h"
#include "components/tpcd/metadata/browser/manager.h"
@@ -172,6 +184,7 @@
#endif // BUILDFLAG(ENABLE_FEED_V2)
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/user_education/browser_feature_promo_storage_service.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_provider.h"
@@ -509,7 +522,7 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
CreateTaskCompletionClosure(TracingDataType::kAutofillOrigins));
autofill::PersonalDataManager* data_manager =
autofill::PersonalDataManagerFactory::GetForProfile(profile_);
autofill::PersonalDataManagerFactory::GetForBrowserContext(profile_);
if (data_manager)
data_manager->Refresh();
}
@@ -610,6 +623,13 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
bookmark_model->ClearLastUsedTimeInRange(delete_begin, delete_end);
}
#if !BUILDFLAG(IS_ANDROID)
// Clear any stored User Education session data. Note that we can't clear a
// specific date range, as this is used for longitudinal metrics reporting,
// so selectively deleting entries would make the telemetry invalid.
BrowserFeaturePromoStorageService::ClearUsageHistory(profile_);
#endif
// Cleared for DATA_TYPE_HISTORY, DATA_TYPE_COOKIES and DATA_TYPE_PASSWORDS.
browsing_data::RemoveFederatedSiteSettingsData(delete_begin_, delete_end_,
website_settings_filter,
@@ -969,6 +989,12 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
browsing_data::RemoveFederatedSiteSettingsData(delete_begin_, delete_end_,
website_settings_filter,
host_content_settings_map_);
// Record that a password removal action happened for the profile store.
AddPasswordRemovalReason(
profile_->GetPrefs(), password_manager::IsAccountStore(false),
password_manager::metrics_util::PasswordManagerCredentialRemovalReason::
kClearBrowsingData);
}
if (remove_mask & constants::DATA_TYPE_ACCOUNT_PASSWORDS) {
@@ -993,6 +1019,12 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
CreateTaskCompletionClosure(TracingDataType::kAccountPasswords),
std::move(sync_completion));
}
// Record that a password removal action happened for the account store.
AddPasswordRemovalReason(
profile_->GetPrefs(), password_manager::IsAccountStore(true),
password_manager::metrics_util::PasswordManagerCredentialRemovalReason::
kClearBrowsingData);
}
CHECK(deferred_disable_passwords_auto_signin_cb_.is_null(),
@@ -1052,7 +1084,7 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
CreateTaskCompletionClosure(TracingDataType::kAutofillData));
autofill::PersonalDataManager* data_manager =
autofill::PersonalDataManagerFactory::GetForProfile(profile_);
autofill::PersonalDataManagerFactory::GetForBrowserContext(profile_);
if (data_manager)
data_manager->Refresh();
}
@@ -1427,6 +1459,29 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
NOTIMPLEMENTED();
#endif // BUILDFLAG(IS_ANDROID)
}
//////////////////////////////////////////////////////////////////////////////
// DATA_TYPE_RELATED_WEBSITE_SETS_PERMISSIONS
if (remove_mask & content::BrowsingDataRemover::
DATA_TYPE_RELATED_WEBSITE_SETS_PERMISSIONS) {
for (ContentSettingsType type_to_clear :
{ContentSettingsType::STORAGE_ACCESS,
ContentSettingsType::TOP_LEVEL_STORAGE_ACCESS}) {
host_content_settings_map_->ClearSettingsForOneTypeWithPredicate(
type_to_clear, [&](const ContentSettingPatternSource& setting) {
return content_settings::IsGrantedByRelatedWebsiteSets(
type_to_clear, setting.metadata) &&
base::ranges::any_of(
filter_builder->GetOrigins(),
[&](const url::Origin& origin) -> bool {
return setting.primary_pattern.Matches(
origin.GetURL()) ||
setting.secondary_pattern.Matches(
origin.GetURL());
});
});
}
}
}
void ChromeBrowsingDataRemoverDelegate::OnTaskStarted(
@@ -1490,13 +1545,20 @@ void ChromeBrowsingDataRemoverDelegate::OnTaskComplete(
// are refreshed the next time, typically on the next browser restart.
if (should_clear_sync_account_settings_) {
should_clear_sync_account_settings_ = false;
syncer::SyncService* sync_service =
SyncServiceFactory::GetForProfile(profile_);
if (sync_service) {
sync_service->GetUserSettings()->KeepAccountSettingsPrefsOnlyForUsers({});
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile_);
base::flat_set<std::string> gaia_ids =
signin::GetAllGaiaIdsForKeyedPreferences(
identity_manager,
signin::AccountsInCookieJarInfo() /* empty_cookies */);
if (syncer::SyncService* sync_service =
SyncServiceFactory::GetForProfile(profile_);
sync_service) {
sync_service->GetUserSettings()->KeepAccountSettingsPrefsOnlyForUsers(
base::ToVector(gaia_ids, &signin::GaiaIdHash::FromGaiaId));
}
password_manager::features_util::KeepAccountStorageSettingsOnlyForUsers(
profile_->GetPrefs(), {});
profile_->GetPrefs(), std::move(gaia_ids).extract());
}
#endif // !BUILDFLAG(IS_ANDROID)
@@ -13,7 +13,6 @@
#include "build/chromeos_buildflags.h"
#include "chrome/browser/accessibility/accessibility_labels_service.h"
#include "chrome/browser/accessibility/accessibility_labels_service_factory.h"
#include "chrome/browser/ai/ai_manager_impl.h"
#include "chrome/browser/ash/drive/file_system_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/buildflags.h"
@@ -36,8 +35,8 @@
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/translate/translate_frame_binder.h"
#include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
#include "chrome/browser/ui/views/side_panel/companion/companion_utils.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/side_panel/companion/companion_utils.h"
#include "chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_ui.h"
#include "chrome/browser/ui/webui/data_sharing_internals/data_sharing_internals_ui.h"
#include "chrome/browser/ui/webui/engagement/site_engagement_ui.h"
@@ -80,7 +79,6 @@
#include "components/no_state_prefetch/browser/no_state_prefetch_contents.h"
#include "components/no_state_prefetch/browser/no_state_prefetch_processor_impl.h"
#include "components/performance_manager/embedder/binders.h"
#include "components/performance_manager/public/features.h"
#include "components/performance_manager/public/performance_manager.h"
#include "components/prefs/pref_service.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
@@ -108,6 +106,7 @@
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/features_generated.h"
#include "third_party/blink/public/mojom/credentialmanagement/credential_manager.mojom.h"
#include "third_party/blink/public/mojom/facilitated_payments/payment_link_handler.mojom.h"
#include "third_party/blink/public/mojom/lcp_critical_path_predictor/lcp_critical_path_predictor.mojom.h"
#include "third_party/blink/public/mojom/loader/navigation_predictor.mojom.h"
#include "third_party/blink/public/mojom/on_device_translation/translation_manager.mojom.h"
@@ -146,6 +145,7 @@
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/android/dom_distiller/distiller_ui_handle_android.h"
#include "chrome/browser/facilitated_payments/payment_link_handler_factory.h"
#include "chrome/browser/offline_pages/android/offline_page_auto_fetcher.h"
#include "chrome/browser/ui/webui/feed_internals/feed_internals.mojom.h"
#include "chrome/browser/ui/webui/feed_internals/feed_internals_ui.h"
@@ -160,10 +160,7 @@
#include "chrome/browser/new_tab_page/modules/feed/feed.mojom.h"
#include "chrome/browser/new_tab_page/modules/file_suggestion/file_suggestion.mojom.h"
#include "chrome/browser/new_tab_page/modules/history_clusters/history_clusters.mojom.h"
#include "chrome/browser/new_tab_page/modules/photos/photos.mojom.h"
#include "chrome/browser/new_tab_page/modules/recipes/recipes.mojom.h"
#include "chrome/browser/new_tab_page/modules/v2/calendar/google_calendar.mojom.h"
#include "chrome/browser/new_tab_page/modules/v2/history_clusters/history_clusters_v2.mojom.h"
#include "chrome/browser/new_tab_page/modules/v2/most_relevant_tab_resumption/most_relevant_tab_resumption.mojom.h"
#include "chrome/browser/new_tab_page/modules/v2/tab_resumption/tab_resumption.mojom.h"
#include "chrome/browser/new_tab_page/new_tab_page_util.h"
@@ -195,6 +192,7 @@
#include "chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.h"
#include "chrome/browser/ui/webui/omnibox_popup/omnibox_popup_ui.h"
#include "chrome/browser/ui/webui/password_manager/password_manager_ui.h"
#include "chrome/browser/ui/webui/privacy_sandbox/related_website_sets/related_website_sets.mojom.h"
#include "chrome/browser/ui/webui/search_engine_choice/search_engine_choice.mojom.h" // nogncheck crbug.com/1125897
#include "chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui.h"
#include "chrome/browser/ui/webui/settings/settings_ui.h"
@@ -204,7 +202,6 @@
#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.h"
#include "chrome/browser/ui/webui/side_panel/customize_chrome/wallpaper_search/wallpaper_search.mojom.h"
#include "chrome/browser/ui/webui/side_panel/history_clusters/history_clusters_side_panel_ui.h"
#include "chrome/browser/ui/webui/side_panel/performance_controls/performance_side_panel_ui.h"
#include "chrome/browser/ui/webui/side_panel/read_anything/read_anything_untrusted_ui.h"
#include "chrome/browser/ui/webui/side_panel/reading_list/reading_list.mojom.h"
#include "chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.h"
@@ -218,7 +215,6 @@
#include "ui/webui/resources/cr_components/color_change_listener/color_change_listener.mojom.h"
#include "ui/webui/resources/cr_components/commerce/shopping_service.mojom.h" // nogncheck crbug.com/1125897
#include "ui/webui/resources/cr_components/customize_color_scheme_mode/customize_color_scheme_mode.mojom.h"
#include "ui/webui/resources/cr_components/customize_themes/customize_themes.mojom.h"
#include "ui/webui/resources/cr_components/help_bubble/help_bubble.mojom.h"
#include "ui/webui/resources/cr_components/history_clusters/history_clusters.mojom.h"
#include "ui/webui/resources/cr_components/history_embeddings/history_embeddings.mojom.h"
@@ -253,7 +249,6 @@
#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/ui/webui/signin/profile_customization_ui.h"
#include "chrome/browser/ui/webui/signin/profile_picker_ui.h"
#include "ui/webui/resources/cr_components/customize_themes/customize_themes.mojom.h"
#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(IS_CHROMEOS_ASH)
@@ -261,6 +256,8 @@
#include "ash/public/mojom/hid_preserving_bluetooth_state_controller.mojom.h"
#include "ash/webui/annotator/mojom/untrusted_annotator.mojom.h"
#include "ash/webui/annotator/untrusted_annotator_ui.h"
#include "ash/webui/boca_ui/boca_ui.h"
#include "ash/webui/boca_ui/mojom/boca.mojom.h"
#include "ash/webui/camera_app_ui/camera_app_helper.mojom.h"
#include "ash/webui/camera_app_ui/camera_app_ui.h"
#include "ash/webui/color_internals/color_internals_ui.h"
@@ -310,6 +307,7 @@
#include "ash/webui/projector_app/untrusted_projector_ui.h"
#include "ash/webui/recorder_app_ui/mojom/recorder_app.mojom.h"
#include "ash/webui/recorder_app_ui/recorder_app_ui.h"
#include "ash/webui/sanitize_ui/sanitize_ui.h"
#include "ash/webui/scanning/mojom/scanning.mojom.h"
#include "ash/webui/scanning/scanning_ui.h"
#include "ash/webui/shimless_rma/shimless_rma.h"
@@ -493,6 +491,7 @@
#endif
#if BUILDFLAG(CHROME_ROOT_STORE_CERT_MANAGEMENT_UI)
#include "chrome/browser/ui/webui/certificate_manager/certificate_manager_ui.h"
#include "ui/webui/resources/cr_components/certificate_manager/certificate_manager_v2.mojom.h"
#endif // BUILDFLAG(CHROME_ROOT_STORE_CERT_MANAGEMENT_UI)
@@ -536,8 +535,8 @@ void BindCommerceHintObserver(
content::RenderFrameHost* const frame_host,
mojo::PendingReceiver<cart::mojom::CommerceHintObserver> receiver) {
// This is specifically restricting this to main frames, whether they are the
// main frame of the tab or a <portal> element, while preventing this from
// working in subframes and fenced frames.
// main frame of the tab, while preventing this from working in subframes and
// fenced frames.
if (frame_host->GetParent() || frame_host->IsFencedFrameRoot()) {
mojo::ReportBadMessage(
"Unexpected the message from subframe or fenced frame.");
@@ -1104,6 +1103,13 @@ void PopulateChromeFrameBinders(
map->Add<blink::mojom::TranslationManager>(
base::BindRepeating(&TranslationManagerImpl::Create));
}
#if BUILDFLAG(IS_ANDROID)
if (base::FeatureList::IsEnabled(blink::features::kPaymentLinkDetection)) {
map->Add<payments::facilitated::mojom::PaymentLinkHandler>(
base::BindRepeating(&CreatePaymentLinkHandler));
}
#endif
}
void PopulateChromeWebUIFrameBinders(
@@ -1209,15 +1215,14 @@ void PopulateChromeWebUIFrameBinders(
ash::cloud_upload::CloudUploadUI, ash::office_fallback::OfficeFallbackUI,
ash::multidevice_setup::MultiDeviceSetupDialogUI, ash::ParentAccessUI,
ash::EmojiUI, ash::RemoteMaintenanceCurtainUI,
ash::app_install::AppInstallDialogUI,
ash::app_install::AppInstallDialogUI, ash::SanitizeDialogUI,
ash::printing::print_preview::PrintPreviewCrosUI,
ash::extended_updates::ExtendedUpdatesUI,
#endif
NewTabPageUI, OmniboxPopupUI, BookmarksSidePanelUI, CustomizeChromeUI,
InternalsUI, ReadingListUI, TabSearchUI, WebuiGalleryUI,
HistoryClustersSidePanelUI, PerformanceSidePanelUI,
ShoppingInsightsSidePanelUI, media_router::AccessCodeCastUI,
commerce::ProductSpecificationsUI>(map);
HistoryClustersSidePanelUI, ShoppingInsightsSidePanelUI,
media_router::AccessCodeCastUI, commerce::ProductSpecificationsUI>(map);
RegisterWebUIControllerInterfaceBinder<
new_tab_page::mojom::PageHandlerFactory, NewTabPageUI>(map);
@@ -1240,7 +1245,7 @@ void PopulateChromeWebUIFrameBinders(
history_clusters::mojom::PageHandler, HistoryUI>(map);
}
}
if (history_embeddings::IsHistoryEmbeddingEnabled()) {
if (history_embeddings::IsHistoryEmbeddingsEnabled()) {
RegisterWebUIControllerInterfaceBinder<
history_embeddings::mojom::PageHandler, HistoryUI>(map);
}
@@ -1281,71 +1286,37 @@ void PopulateChromeWebUIFrameBinders(
#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
>(map);
RegisterWebUIControllerInterfaceBinder<
customize_themes::mojom::CustomizeThemesHandlerFactory, NewTabPageUI
#if !BUILDFLAG(IS_CHROMEOS_ASH)
,
ProfileCustomizationUI, settings::SettingsUI
#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
>(map);
#if BUILDFLAG(CHROME_ROOT_STORE_CERT_MANAGEMENT_UI)
RegisterWebUIControllerInterfaceBinder<
certificate_manager_v2::mojom::CertificateManagerPageHandlerFactory,
settings::SettingsUI>(map);
CertificateManagerUI>(map);
#endif // BUILDFLAG(CHROME_ROOT_STORE_CERT_MANAGEMENT_UI)
RegisterWebUIControllerInterfaceBinder<
help_bubble::mojom::HelpBubbleHandlerFactory, InternalsUI,
settings::SettingsUI, ReadingListUI, NewTabPageUI, CustomizeChromeUI,
PasswordManagerUI>(map);
PasswordManagerUI, HistoryUI
#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID)
,
ProfilePickerUI
#endif //! BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID)
>(map);
#if !defined(OFFICIAL_BUILD)
RegisterWebUIControllerInterfaceBinder<foo::mojom::FooHandler, NewTabPageUI>(
map);
#endif // !defined(OFFICIAL_BUILD)
if (IsCartModuleEnabled()) {
RegisterWebUIControllerInterfaceBinder<chrome_cart::mojom::CartHandler,
NewTabPageUI, CustomizeChromeUI>(
map);
} else if (IsCartModuleEnabled()) {
RegisterWebUIControllerInterfaceBinder<chrome_cart::mojom::CartHandler,
NewTabPageUI>(map);
}
if (IsDriveModuleEnabled()) {
RegisterWebUIControllerInterfaceBinder<
file_suggestion::mojom::FileSuggestionHandler, NewTabPageUI>(map);
}
if (base::FeatureList::IsEnabled(ntp_features::kNtpPhotosModule)) {
RegisterWebUIControllerInterfaceBinder<photos::mojom::PhotosHandler,
NewTabPageUI>(map);
}
if (IsRecipeTasksModuleEnabled()) {
RegisterWebUIControllerInterfaceBinder<recipes::mojom::RecipesHandler,
NewTabPageUI>(map);
}
if (base::FeatureList::IsEnabled(ntp_features::kNtpFeedModule)) {
RegisterWebUIControllerInterfaceBinder<ntp::feed::mojom::FeedHandler,
NewTabPageUI>(map);
}
if (base::FeatureList::IsEnabled(ntp_features::kNtpHistoryClustersModule) ||
base::FeatureList::IsEnabled(
ntp_features::kNtpHistoryClustersModuleLoad)) {
if (base::FeatureList::IsEnabled(ntp_features::kNtpModulesRedesigned)) {
RegisterWebUIControllerInterfaceBinder<
ntp::history_clusters_v2::mojom::PageHandler, NewTabPageUI>(map);
} else {
RegisterWebUIControllerInterfaceBinder<
ntp::history_clusters::mojom::PageHandler, NewTabPageUI>(map);
}
}
if (base::FeatureList::IsEnabled(ntp_features::kNtpTabResumptionModule)) {
RegisterWebUIControllerInterfaceBinder<
ntp::tab_resumption::mojom::PageHandler, NewTabPageUI>(map);
@@ -1382,13 +1353,6 @@ void PopulateChromeWebUIFrameBinders(
BookmarksSidePanelUI, commerce::ProductSpecificationsUI,
ShoppingInsightsSidePanelUI, HistoryUI>(map);
if (base::FeatureList::IsEnabled(
performance_manager::features::kPerformanceControlsSidePanel)) {
RegisterWebUIControllerInterfaceBinder<
side_panel::mojom::PerformancePageHandlerFactory,
PerformanceSidePanelUI>(map);
}
RegisterWebUIControllerInterfaceBinder<
side_panel::mojom::CustomizeChromePageHandlerFactory, CustomizeChromeUI>(
map);
@@ -1412,12 +1376,6 @@ void PopulateChromeWebUIFrameBinders(
read_anything::mojom::UntrustedPageHandlerFactory,
ReadAnythingUntrustedUI>(map);
if (base::FeatureList::IsEnabled(
data_sharing::features::kDataSharingFeature)) {
RegisterWebUIControllerInterfaceBinder<
data_sharing::mojom::PageHandlerFactory, DataSharingUI>(map);
}
RegisterWebUIControllerInterfaceBinder<tab_search::mojom::PageHandlerFactory,
TabSearchUI>(map);
RegisterWebUIControllerInterfaceBinder<
@@ -1784,11 +1742,9 @@ void PopulateChromeWebUIFrameBinders(
RegisterWebUIControllerInterfaceBinder<
ash::screens_factory::mojom::ScreensFactory, ash::OobeUI>(map);
if (ash::app_install::AppInstallDialog::IsEnabled()) {
RegisterWebUIControllerInterfaceBinder<
ash::app_install::mojom::PageHandlerFactory,
ash::app_install::AppInstallDialogUI>(map);
}
RegisterWebUIControllerInterfaceBinder<
ash::app_install::mojom::PageHandlerFactory,
ash::app_install::AppInstallDialogUI>(map);
RegisterWebUIControllerInterfaceBinder<
new_window_proxy::mojom::NewWindowProxy, ash::EmojiUI>(map);
@@ -1869,6 +1825,14 @@ void PopulateChromeWebUIFrameBinders(
privacy_sandbox_internals::PrivacySandboxInternalsUI>(map);
}
#if !BUILDFLAG(IS_ANDROID)
if (base::FeatureList::IsEnabled(privacy_sandbox::kRelatedWebsiteSetsDevUI)) {
RegisterWebUIControllerInterfaceBinder<
related_website_sets::mojom::RelatedWebsiteSetsPageHandler,
privacy_sandbox_internals::PrivacySandboxInternalsUI>(map);
}
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (ash::features::IsFocusModeEnabled()) {
RegisterWebUIControllerInterfaceBinder<
@@ -1920,8 +1884,13 @@ void PopulateChromeWebUIFrameInterfaceBrokers(
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// --- Section 2: chrome-untrusted:// WebUIs:
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (ash::features::IsBocaEnabled()) {
registry.ForWebUI<ash::BocaUI>()
.Add<ash::boca::mojom::BocaPageHandlerFactory>()
.Add<color_change_listener::mojom::PageHandler>();
}
if (chromeos::features::IsOrcaEnabled()) {
registry.ForWebUI<ash::MakoUntrustedUI>()
.Add<ash::orca::mojom::EditorClient>();
@@ -1969,13 +1938,18 @@ void PopulateChromeWebUIFrameInterfaceBrokers(
registry.ForWebUI<CompanionSidePanelUntrustedUI>()
.Add<side_panel::mojom::CompanionPageHandlerFactory>();
}
if (features::IsReadAnythingWebUIToolbarEnabled()) {
registry.ForWebUI<ReadAnythingUntrustedUI>()
.Add<color_change_listener::mojom::PageHandler>();
}
registry.ForWebUI<ReadAnythingUntrustedUI>()
.Add<color_change_listener::mojom::PageHandler>();
if (base::FeatureList::IsEnabled(features::kHaTSWebUI)) {
registry.ForWebUI<HatsUI>().Add<hats::mojom::PageHandlerFactory>();
}
if (base::FeatureList::IsEnabled(
data_sharing::features::kDataSharingFeature)) {
registry.ForWebUI<DataSharingUI>()
.Add<data_sharing::mojom::PageHandlerFactory>();
}
#endif // !BUILDFLAG(IS_ANDROID)
}
@@ -47,7 +47,7 @@
#include "build/chromeos_buildflags.h"
#include "build/config/chromebox_for_meetings/buildflags.h" // PLATFORM_CFM
#include "chrome/browser/after_startup_task_utils.h"
#include "chrome/browser/ai/ai_manager_impl.h"
#include "chrome/browser/ai/ai_manager_keyed_service_factory.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/bluetooth/chrome_bluetooth_delegate_impl_client.h"
#include "chrome/browser/browser_about_handler.h"
@@ -140,6 +140,7 @@
#include "chrome/browser/profiling_host/chrome_browser_main_extra_parts_profiling.h"
#include "chrome/browser/renderer_host/chrome_navigation_ui_data.h"
#include "chrome/browser/renderer_preferences_util.h"
#include "chrome/browser/request_header_integrity/buildflags.h"
#include "chrome/browser/safe_browsing/chrome_ping_manager_factory.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h"
#include "chrome/browser/safe_browsing/delayed_warning_navigation_throttle.h"
@@ -205,6 +206,7 @@
#include "chrome/common/logging_chrome.h"
#include "chrome/common/ppapi_utils.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/profiler/main_thread_stack_sampling_profiler.h"
#include "chrome/common/profiler/process_type.h"
#include "chrome/common/profiler/thread_profiler_configuration.h"
#include "chrome/common/renderer_configuration.mojom.h"
@@ -240,8 +242,8 @@
#include "components/error_page/common/error_page_switches.h"
#include "components/error_page/common/localized_error.h"
#include "components/error_page/content/browser/net_error_auto_reloader.h"
#include "components/fingerprinting_protection_filter/browser/fingerprinting_protection_filter_features.h"
#include "components/fingerprinting_protection_filter/browser/throttle_manager.h"
#include "components/fingerprinting_protection_filter/common/fingerprinting_protection_filter_features.h"
#include "components/google/core/common/google_switches.h"
#include "components/heap_profiling/in_process/heap_profiler_controller.h"
#include "components/history/content/browser/visited_link_navigation_throttle.h"
@@ -329,6 +331,7 @@
#include "content/public/browser/legacy_tech_cookie_issue_details.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/overlay_window.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/browser/render_frame_host.h"
@@ -348,6 +351,7 @@
#include "content/public/common/content_descriptors.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_utils.h"
#include "content/public/common/window_container_type.mojom-shared.h"
#include "device/vr/buildflags/buildflags.h"
#include "extensions/browser/browser_frame_context_data.h"
@@ -370,6 +374,7 @@
#include "sandbox/policy/features.h"
#include "sandbox/policy/mojom/sandbox.mojom.h"
#include "sandbox/policy/switches.h"
#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
@@ -377,7 +382,9 @@
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/self_deleting_url_loader_factory.h"
#include "services/network/public/cpp/web_sandbox_flags.h"
#include "services/network/public/mojom/cert_verifier_service.mojom.h"
#include "services/network/public/mojom/network_service.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/public/mojom/web_transport.mojom.h"
#include "services/video_effects/public/mojom/video_effects_processor.mojom-forward.h"
#include "third_party/blink/public/common/features.h"
@@ -387,6 +394,7 @@
#include "third_party/blink/public/common/permissions_policy/permissions_policy.h"
#include "third_party/blink/public/common/switches.h"
#include "third_party/blink/public/mojom/browsing_topics/browsing_topics.mojom.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom.h"
#include "third_party/blink/public/public_buildflags.h"
#include "third_party/widevine/cdm/buildflags.h"
#include "ui/base/clipboard/clipboard_format_type.h"
@@ -484,12 +492,11 @@
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/android/tab_web_contents_delegate_android.h"
#include "chrome/browser/chrome_browser_main_android.h"
#include "chrome/browser/digital_credentials/digital_identity_provider_android.h"
#include "chrome/browser/download/android/available_offline_content_provider.h"
#include "chrome/browser/download/android/intercept_oma_download_navigation_throttle.h"
#include "chrome/browser/flags/android/chrome_feature_list.h"
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#include "chrome/browser/ui/webid/digital_identity_safety_interstitial_bridge_android.h"
#include "chrome/browser/webid/digital_identity_provider_android.h"
#include "chrome/common/chrome_descriptors.h"
#include "components/browser_ui/accessibility/android/font_size_prefs_android.h"
#include "components/crash/content/browser/child_exit_observer_android.h"
@@ -510,11 +517,12 @@
#endif
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/digital_credentials/digital_identity_provider_desktop.h"
#include "chrome/browser/preloading/preview/preview_navigation_throttle.h"
#include "chrome/browser/web_applications/isolated_web_apps/chrome_content_browser_client_isolated_web_apps_part.h"
#include "chrome/browser/web_applications/locks/app_lock.h"
#include "chrome/browser/web_applications/proto/web_app_install_state.pb.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/browser/webid/digital_identity_provider_desktop.h"
#include "third_party/blink/public/mojom/installedapp/related_application.mojom.h"
#endif // !BUILDFLAG(IS_ANDROID)
@@ -545,8 +553,10 @@
#include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/direct_sockets/chrome_direct_sockets_delegate.h"
#include "chrome/browser/enterprise/connectors/connectors_service.h"
#include "chrome/browser/headless/chrome_browser_main_extra_parts_headless.h"
#include "chrome/browser/media/unified_autoplay_config.h"
#include "chrome/browser/media_effects/media_effects_manager_binder.h"
#include "chrome/browser/metrics/usage_scenario/chrome_responsiveness_calculator_delegate.h"
#include "chrome/browser/new_tab_page/new_tab_page_util.h"
#include "chrome/browser/page_info/about_this_site_side_panel_throttle.h"
@@ -576,10 +586,8 @@
#include "chrome/grit/chrome_unscaled_resources.h" // nogncheck crbug.com/1125897
#include "components/commerce/core/commerce_feature_list.h"
#include "components/lens/lens_features.h"
#include "components/media_effects/media_effects_manager_binder.h"
#include "components/password_manager/content/common/web_ui_constants.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "chrome/browser/enterprise/connectors/connectors_service.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom.h"
#endif // !BUILDFLAG(IS_ANDROID)
@@ -682,6 +690,9 @@
#include "components/pdf/browser/pdf_navigation_throttle.h"
#include "components/pdf/browser/pdf_url_loader_request_interceptor.h"
#include "components/pdf/common/constants.h"
#if BUILDFLAG(IS_WIN)
#include "pdf/pdf_features.h"
#endif // BUILDFLAG(IS_WIN)
#endif // BUILDFLAG(ENABLE_PDF)
@@ -689,6 +700,10 @@
#include "chrome/browser/media/cast_remoting_connector.h"
#endif
#if BUILDFLAG(ENABLE_REQUEST_HEADER_INTEGRITY)
#include "chrome/browser/request_header_integrity/request_header_integrity_url_loader_throttle.h" // nogncheck crbug.com/1125897
#endif
#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
#endif
@@ -765,6 +780,11 @@
#include "services/device/public/cpp/geolocation/geolocation_system_permission_manager.h"
#endif // BUILDFLAG(OS_LEVEL_GEOLOCATION_PERMISSION_SUPPORTED)
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/feed/feed_service_factory.h"
#include "components/feed/feed_feature_list.h"
#endif // BUILDFLAG(IS_ANDROID)
using blink::mojom::EffectiveConnectionType;
using blink::web_pref::WebPreferences;
using content::BrowserThread;
@@ -985,7 +1005,16 @@ blink::mojom::AutoplayPolicy GetAutoplayPolicyForWebContents(
// allow autoplay within the iframe. Only allow a nesting of single depth.
result = blink::mojom::AutoplayPolicy::kNoUserGestureRequired;
}
#endif // !BUILDFLAG(IS_ANDROID)
#else // !BUILDFLAG(IS_ANDROID)
// TWAs don't require a user gesture for unmuted autoplay.
if (base::FeatureList::IsEnabled(features::kAllowUnmutedAutoplayForTWA)) {
if (auto* delegate = TabAndroid::FromWebContents(web_contents)) {
if (delegate->IsTrustedWebActivity()) {
result = blink::mojom::AutoplayPolicy::kNoUserGestureRequired;
}
}
}
#endif // BUILDFLAG(IS_ANDROID)
return result;
}
@@ -1028,7 +1057,7 @@ bool URLHasExtensionPermission(extensions::ProcessMap* process_map,
// Returns true if |extension_id| is allowed to run as an Isolated Context,
// giving it access to additional APIs.
bool IsExtensionIdAllowedToUseIsolatedContext(std::string_view extension_id) {
static constexpr auto kAllowedIsolatedContextExtensionIds =
constexpr auto kAllowedIsolatedContextExtensionIds =
base::MakeFixedFlatSet<std::string_view>({
"algkcnfjnajfhgimadimbjhmpaeohhln", // Secure Shell Extension (dev)
"iodihamcpbpeioajjeobimgagajmlibd", // Secure Shell Extension
@@ -1077,12 +1106,8 @@ void LaunchURL(
network::mojom::WebSandboxFlags sandbox_flags,
bool has_user_gesture,
const std::optional<url::Origin>& initiating_origin,
content::WeakDocumentPtr initiator_document
#if BUILDFLAG(IS_ANDROID)
,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory
#endif
) {
content::WeakDocumentPtr initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
// If there is no longer a WebContents, the request may have raced with tab
// closing. Don't fire the external request. (It may have been a prerender.)
content::WebContents* web_contents = web_contents_getter.Run();
@@ -1480,6 +1505,15 @@ bool DetermineIfDevtoolsUserForProcessPerSite() {
return is_devtools_user;
}
net::handles::NetworkHandle GetBoundNetworkFromRenderFrameHost(
content::RenderFrameHost* frame) {
auto* web_contents = WebContents::FromRenderFrameHost(frame);
if (!web_contents) {
return net::handles::kInvalidNetworkHandle;
}
return web_contents->GetTargetNetwork();
}
} // namespace
// static
@@ -1594,8 +1628,6 @@ void ChromeContentBrowserClient::RegisterProfilePrefs(
static_cast<int>(
embedder_support::UserAgentReductionEnterprisePolicyState::kDefault));
registry->RegisterBooleanPref(prefs::kOriginAgentClusterDefaultEnabled, true);
registry->RegisterBooleanPref(
policy::policy_prefs::kIsolatedAppsDeveloperModeAllowed, true);
registry->RegisterBooleanPref(
prefs::kStrictMimetypeCheckForWorkerScriptsEnabled, true);
@@ -1618,6 +1650,8 @@ void ChromeContentBrowserClient::RegisterProfilePrefs(
registry->RegisterBooleanPref(
policy::policy_prefs::kKeyboardFocusableScrollersEnabled, true);
registry->RegisterBooleanPref(
policy::policy_prefs::kStandardizedBrowserZoomEnabled, true);
registry->RegisterBooleanPref(
policy::policy_prefs::
@@ -1653,6 +1687,75 @@ void ChromeContentBrowserClient::SetApplicationLocale(
FROM_HERE, base::BindOnce(&SetApplicationLocaleOnIOThread, locale));
}
void ChromeContentBrowserClient::MaybeProxyNetworkBoundRequest(
content::BrowserContext* browser_context,
net::handles::NetworkHandle bound_network,
network::URLLoaderFactoryBuilder& factory_builder,
network::mojom::URLLoaderFactoryOverridePtr* factory_override,
const net::IsolationInfo& isolation_info) {
if (bound_network == net::handles::kInvalidNetworkHandle) {
return;
}
// We support one network-bound NetworkContext at most. If a new one is
// needed, make sure to clean up the previous one first.
if (bound_network != target_network_for_network_bound_network_context_) {
network_bound_network_context_ =
mojo::Remote<network::mojom::NetworkContext>();
network::mojom::NetworkContextParamsPtr context_params =
network::mojom::NetworkContextParams::New();
context_params->bound_network = bound_network;
context_params->cert_verifier_params = content::GetCertVerifierParams(
cert_verifier::mojom::CertVerifierCreationParams::New());
ConfigureNetworkContextParams(
browser_context, true, base::FilePath(), context_params.get(),
cert_verifier::mojom::CertVerifierCreationParams::New().get());
content::CreateNetworkContextInNetworkService(
network_bound_network_context_.BindNewPipeAndPassReceiver(),
std::move(context_params));
target_network_for_network_bound_network_context_ = bound_network;
}
// TLDR; if `factory_override` != nullptr, this is being called for the
// creation of a 2-layer URLLoaderFactory (see
// network.mojom.URLLoaderFactoryOverride documentation). In this case, we
// want to substitute the internal (defined by
// factory_override->overriding_factory, with a URLLoaderFactory that targets
// `bound_network`. If `factory_override` == nullptr, this is a single-layer
// URLLoaderFactory. In this case, we want the last URLLoaderFactory in the
// `factory_builder` chain to be a URLLoaderFactory that targets
// `bound_network`.
mojo::PendingReceiver<network::mojom::URLLoaderFactory> proxied_receiver;
mojo::PendingRemote<network::mojom::URLLoaderFactory> bypassed_remote;
if (!factory_override) {
// Hijack the receiver end returned by network::URLLoaderFactoryBuilder.
// This will be then redirected to a network-bound URLLoaderFactory.
std::tie(proxied_receiver, bypassed_remote) = factory_builder.Append();
} else {
// Hijack the remote end stored in network::mojom::URLLoaderFactoryOverride.
// This will be then redirected to a network-bound URLLoaderFactory.
*factory_override = network::mojom::URLLoaderFactoryOverride::New();
proxied_receiver =
(*factory_override)
->overriding_factory.InitWithNewPipeAndPassReceiver();
(*factory_override)->overridden_factory_receiver =
bypassed_remote.InitWithNewPipeAndPassReceiver();
(*factory_override)->skip_cors_enabled_scheme_check = true;
}
// Create a network-bound URLLoaderFactory and redirect the receiver end of
// the hijacked remote to this.
network::mojom::URLLoaderFactoryParamsPtr params =
network::mojom::URLLoaderFactoryParams::New();
params->process_id = network::mojom::kBrowserProcessId;
params->is_trusted = true;
params->isolation_info = isolation_info;
// Disable CORS wrapping, this is already handled by the caller.
params->disable_web_security = true;
network_bound_network_context_->CreateURLLoaderFactory(
std::move(proxied_receiver), std::move(params));
}
std::unique_ptr<content::BrowserMainParts>
ChromeContentBrowserClient::CreateBrowserMainParts(bool is_integration_test) {
std::unique_ptr<ChromeBrowserMainParts> main_parts;
@@ -1789,6 +1892,10 @@ bool ChromeContentBrowserClient::IsShuttingDown() {
return browser_shutdown::HasShutdownStarted();
}
void ChromeContentBrowserClient::ThreadPoolWillTerminate() {
sampling_profiler_.reset();
}
content::StoragePartitionConfig
ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
content::BrowserContext* browser_context,
@@ -1992,18 +2099,21 @@ bool ChromeContentBrowserClient::ShouldAllowProcessPerSiteForMultipleMainFrames(
return true;
}
bool ChromeContentBrowserClient::ShouldUseSpareRenderProcessHost(
std::optional<
content::ContentBrowserClient::SpareProcessRefusedByEmbedderReason>
ChromeContentBrowserClient::ShouldUseSpareRenderProcessHost(
content::BrowserContext* browser_context,
const GURL& site_url) {
Profile* profile = Profile::FromBrowserContext(browser_context);
if (!profile)
return false;
if (!profile) {
return SpareProcessRefusedByEmbedderReason::NoProfile;
}
// Returning false here will ensure existing Top Chrome WebUI renderers are
// considered for process reuse over the spare renderer.
if (IsTopChromeWebUIURL(site_url) &&
!ShouldUseSpareRenderProcessHostForTopChromePage(profile)) {
return false;
return SpareProcessRefusedByEmbedderReason::TopFrameChromeWebUI;
}
#if !BUILDFLAG(IS_ANDROID)
@@ -2011,16 +2121,21 @@ bool ChromeContentBrowserClient::ShouldUseSpareRenderProcessHost(
// passing switches::kInstantProcess to the renderer process when it
// launches. A spare process is launched earlier, before it is known which
// navigation will use it, so it lacks this flag.
if (search::ShouldAssignURLToInstantRenderer(site_url, profile))
return false;
if (search::ShouldAssignURLToInstantRenderer(site_url, profile)) {
// The NTP page chrome://new-tab-page and chrome://new-tab-page-third-party
// are using WebUI and will not use instant renderer.
// The only usecase is chrome-search:// URLs.
return SpareProcessRefusedByEmbedderReason::InstantRendererForNewTabPage;
}
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
return ChromeContentBrowserClientExtensionsPart::
ShouldUseSpareRenderProcessHost(profile, site_url);
#else
return true;
if (!ChromeContentBrowserClientExtensionsPart::
ShouldUseSpareRenderProcessHost(profile, site_url)) {
return SpareProcessRefusedByEmbedderReason::ExtensionProcess;
}
#endif
return std::nullopt;
}
bool ChromeContentBrowserClient::DoesSiteRequireDedicatedProcess(
@@ -2036,6 +2151,22 @@ bool ChromeContentBrowserClient::DoesSiteRequireDedicatedProcess(
return false;
}
bool ChromeContentBrowserClient::
ShouldAllowCrossProcessSandboxedFrameForPrecursor(
content::BrowserContext* browser_context,
const GURL& precursor,
const GURL& url) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
#if BUILDFLAG(ENABLE_EXTENSIONS)
if (!ChromeContentBrowserClientExtensionsPart::
ShouldAllowCrossProcessSandboxedFrameForPrecursor(browser_context,
precursor, url)) {
return false;
}
#endif
return true;
}
bool ChromeContentBrowserClient::DoesWebUIUrlRequireProcessLock(
const GURL& url) {
// Note: This method can be called from multiple threads. It is not safe to
@@ -2688,6 +2819,11 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
command_line->AppendSwitch(
blink::switches::kKeyboardFocusableScrollersOptOut);
}
if (!prefs->GetBoolean(
policy::policy_prefs::kStandardizedBrowserZoomEnabled)) {
command_line->AppendSwitch(
blink::switches::kDisableStandardizedBrowserZoom);
}
if (prefs->GetBoolean(
policy::policy_prefs::kCSSCustomStateDeprecatedSyntaxEnabled)) {
command_line->AppendSwitch(
@@ -2816,6 +2952,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
extensions::switches::kExtensionsOnChromeURLs,
extensions::switches::kSetExtensionThrottleTestParams, // For tests only.
extensions::switches::kAllowlistedExtensionID,
extensions::switches::kExtensionTestApiOnWebPages, // For tests only.
#endif
switches::kAllowInsecureLocalhost,
switches::kAppsGalleryURL,
@@ -2931,6 +3068,13 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kChangeStackGuardOnForkEnabled);
}
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#if BUILDFLAG(IS_ANDROID)
// Communicating to renderer for starting the reader for web feed.
if (feed::IsWebFeedEnabledForLocale(feed::FeedServiceFactory::GetCountry())) {
command_line->AppendSwitch(feed::switches::kEnableRssLinkReader);
}
#endif
}
std::string
@@ -3682,9 +3826,8 @@ bool ChromeContentBrowserClient::ShouldDenyRequestOnCertificateError(
namespace {
bool IsForcedColorsEnabledForWebContent(content::WebContents* contents,
const ui::NativeTheme* native_theme) {
if (!native_theme->InForcedColorsMode() || !contents) {
bool ShouldDisableForcedColorsForWebContent(content::WebContents* contents) {
if (!contents) {
return false;
}
@@ -3696,7 +3839,7 @@ bool IsForcedColorsEnabledForWebContent(content::WebContents* contents,
prefs->GetList(prefs::kPageColorsBlockList);
if (forced_colors_blocklist.empty()) {
return true;
return false;
}
GURL url = contents->GetLastCommittedURL();
@@ -3712,11 +3855,17 @@ bool IsForcedColorsEnabledForWebContent(content::WebContents* contents,
}
if (pattern.Matches(url)) {
return false;
return true;
}
}
return true;
return false;
}
bool IsForcedColorsEnabledForWebContent(content::WebContents* contents,
const ui::NativeTheme* native_theme) {
return native_theme->InForcedColorsMode() &&
!ShouldDisableForcedColorsForWebContent(contents);
}
#if !BUILDFLAG(IS_ANDROID)
@@ -3789,7 +3938,7 @@ bool UpdatePreferredColorScheme(WebPreferences* web_prefs,
if (force_light) {
web_prefs->preferred_color_scheme =
blink::mojom::PreferredColorScheme::kLight;
} else if (url.SchemeIs(content::kChromeUIScheme)) {
} else if (content::HasWebUIScheme(url)) {
// If color scheme is not forced, WebUI should track the color mode of the
// ColorProvider associated with `web_contents`.
web_prefs->preferred_color_scheme =
@@ -3837,6 +3986,7 @@ bool ShouldPromptOnMultipleMatchingCertificates(const Profile* profile) {
base::OnceClosure ChromeContentBrowserClient::SelectClientCertificate(
content::BrowserContext* browser_context,
int process_id,
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList client_certs,
@@ -3926,12 +4076,38 @@ base::OnceClosure ChromeContentBrowserClient::SelectClientCertificate(
// At this point, we're going to either a) continue without a valid
// certificate (if we're not allowed to prompt) or b) show the picker for the
// user to select a valid cert. Only do this if the requestor has a valid
// WebContents. In the case of a), we want to preserve consistency (so that
// requests always fail or succeed across different platforms and contexts),
// and for b), we don't want to pop up UI for background requests like
// service workers (where there's no visual context to the user).
// user to select a valid cert. b) requires an associated WebContents; we
// don't want to show a picker with no context. In the case of a), we don't
// need a WebContents to display a picker. However, we don't always know
// whether a) or b) will happen on all platforms. In particular, on Android,
// the process to check for a cert will *also* show the picker. Thus, we
// typically just early-out here unless we're ready to show a cert picker.
if (!web_contents) {
// There's one exception to the above. In the case of extensions, we allow
// the request to continue without a certificate if there are no client
// certs. This allows extension service workers to behave in the same way
// as extension offscreen documents and legacy extension background pages.
// Those cases would lead to the SSLClientCertificateSelector, which would
// automatically continue if the associated certificate list was empty.
// See https://crbug.com/333954429.
// Note: the !IS_ANDROID here is currently moot, but is important in case
// this ever changes. On Android, `matching_certificates` and
// `nonmatching_certificates` are always empty at this stage, even when
// there are matching certificates available in the OS, so this would
// result in always proceeding with no certificate for any request from an
// extension service worker. That decision would be remembered across the
// entire profile, potentially locking the user out of the origin.
#if BUILDFLAG(ENABLE_EXTENSIONS) && !BUILDFLAG(IS_ANDROID)
if (matching_certificates.empty() && nonmatching_certificates.empty()) {
extensions::ProcessMap* process_map =
extensions::ProcessMap::Get(profile);
if (process_map && process_map->Contains(process_id)) {
delegate->ContinueWithCertificate(nullptr, nullptr);
return base::OnceClosure();
}
}
#endif
// Return without calling anything on `delegate`. This results in the
// `delegate` being deleted, which implicitly calls to cancel the request.
return base::OnceClosure();
@@ -4283,8 +4459,11 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
const webapps::AppId& app_id = browser->app_controller()->app_id();
const web_app::WebAppRegistrar& registrar =
web_app_provider->registrar_unsafe();
if (registrar.IsLocallyInstalled(app_id))
if (registrar.IsInstallState(
app_id, {web_app::proto::INSTALLED_WITH_OS_INTEGRATION,
web_app::proto::INSTALLED_WITHOUT_OS_INTEGRATION})) {
web_prefs->web_app_scope = registrar.GetAppScope(app_id);
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
auto* system_app = browser->app_controller()->system_app();
@@ -4337,6 +4516,7 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
web_prefs->require_transient_activation_for_show_file_or_directory_picker =
IsFileOrDirectoryPickerWithoutGestureAllowed(web_contents);
#endif // !BUILDFLAG(IS_ANDROID)
// TODO(crbug.com/40941384): Remove this pref and solely rely on permissions.
web_prefs->require_transient_activation_for_html_fullscreen =
IsTransientActivationRequiredForHtmlFullscreen(
web_contents->GetPrimaryMainFrame());
@@ -4365,6 +4545,9 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
web_prefs->in_forced_colors =
IsForcedColorsEnabledForWebContent(web_contents, GetWebTheme());
web_prefs->is_forced_colors_disabled =
ShouldDisableForcedColorsForWebContent(web_contents);
UpdatePreferredColorScheme(
web_prefs,
web_contents->GetPrimaryMainFrame()->GetSiteInstance()->GetSiteURL(),
@@ -4445,6 +4628,7 @@ bool ChromeContentBrowserClient::OverrideWebPreferencesAfterNavigation(
web_prefs->require_transient_activation_for_show_file_or_directory_picker =
require_transient_activation_for_show_file_or_directory_picker;
#endif // !BUILDFLAG(IS_ANDROID)
// TODO(crbug.com/40941384): Remove this pref and solely rely on permissions.
const bool require_transient_activation_for_html_fullscreen =
IsTransientActivationRequiredForHtmlFullscreen(
web_contents->GetPrimaryMainFrame());
@@ -4464,6 +4648,12 @@ bool ChromeContentBrowserClient::OverrideWebPreferencesAfterNavigation(
prefs_changed |= (web_prefs->in_forced_colors != in_forced_colors);
web_prefs->in_forced_colors = in_forced_colors;
const bool is_forced_colors_disabled =
ShouldDisableForcedColorsForWebContent(web_contents);
prefs_changed |=
(web_prefs->is_forced_colors_disabled != is_forced_colors_disabled);
web_prefs->is_forced_colors_disabled = is_forced_colors_disabled;
prefs_changed |=
UpdatePreferredColorScheme(web_prefs, web_contents->GetLastCommittedURL(),
web_contents, GetWebTheme());
@@ -4849,12 +5039,26 @@ std::wstring ChromeContentBrowserClient::GetAppContainerSidForSandboxType(
}
}
bool ChromeContentBrowserClient::IsRendererAppContainerDisabled() {
bool ChromeContentBrowserClient::IsAppContainerDisabled(
sandbox::mojom::Sandbox sandbox_type) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
constexpr auto kSandboxPolicyPrefMapping =
base::MakeFixedFlatMap<sandbox::mojom::Sandbox, std::string_view>({
{sandbox::mojom::Sandbox::kRenderer,
prefs::kRendererAppContainerEnabled},
{sandbox::mojom::Sandbox::kPrintCompositor,
prefs::kPrintingLPACSandboxEnabled},
});
auto iter = kSandboxPolicyPrefMapping.find(sandbox_type);
if (iter == kSandboxPolicyPrefMapping.end()) {
return false;
}
PrefService* local_state = g_browser_process->local_state();
const PrefService::Preference* pref =
local_state->FindPreference(prefs::kRendererAppContainerEnabled);
local_state->FindPreference(iter->second);
// App Container is disabled if managed pref is set to false.
if (pref && pref->IsManaged() && !pref->GetValue()->GetBool())
return true;
@@ -4978,6 +5182,15 @@ bool ChromeContentBrowserClient::IsRendererCodeIntegrityEnabled() {
local_state->GetBoolean(prefs::kRendererCodeIntegrityEnabled);
}
bool ChromeContentBrowserClient::IsPdfFontProxyEnabled() {
#if BUILDFLAG(ENABLE_PDF)
return base::FeatureList::IsEnabled(
chrome_pdf::features::kWinPdfUseFontProxy);
#else
return false;
#endif
}
// Note: Only use sparingly to add Chrome specific sandbox functionality here.
// Other code should reside in the content layer. Changes to this function
// should be reviewed by the security team.
@@ -4999,8 +5212,8 @@ bool ChromeContentBrowserClient::ShouldEnableAudioProcessHighPriority() {
bool ChromeContentBrowserClient::ShouldUseSkiaFontManager(
const GURL& site_url) {
return (base::FeatureList::IsEnabled(features::kSkiaFontService) &&
IsTopChromeWebUIURL(site_url));
return IsTopChromeWebUIURL(site_url) &&
base::FeatureList::IsEnabled(features::kSkiaFontService);
}
#endif // BUILDFLAG(IS_WIN)
@@ -5851,6 +6064,12 @@ ChromeContentBrowserClient::CreateURLLoaderThrottles(
wc_getter.Run()));
#endif
#if BUILDFLAG(ENABLE_REQUEST_HEADER_INTEGRITY)
result.push_back(
std::make_unique<
request_header_integrity::RequestHeaderIntegrityURLLoaderThrottle>());
#endif
if (chrome_navigation_ui_data &&
chrome_navigation_ui_data->is_no_state_prefetching()) {
result.push_back(
@@ -6395,6 +6614,14 @@ void ChromeContentBrowserClient::WillCreateURLLoaderFactory(
->is_captive_portal_window();
}
#endif
// WARNING: This must be the last interceptor in the chain as the proxying
// URLLoaderFactory installed by this needs to be the one actually sending
// packets over the network (to effectively target `bound_network`).
MaybeProxyNetworkBoundRequest(browser_context,
GetBoundNetworkFromRenderFrameHost(frame),
factory_builder, factory_override,
isolation_info);
}
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
@@ -6402,6 +6629,7 @@ ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors(
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id,
int64_t navigation_id,
bool force_no_https_upgrade,
scoped_refptr<base::SequencedTaskRunner> navigation_response_task_runner) {
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
interceptors;
@@ -6424,11 +6652,13 @@ ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors(
interceptors.push_back(std::make_unique<SearchPrefetchURLLoaderInterceptor>(
frame_tree_node_id, navigation_id, navigation_response_task_runner));
auto https_upgrades_interceptor =
HttpsUpgradesInterceptor::MaybeCreateInterceptor(frame_tree_node_id,
navigation_ui_data);
if (https_upgrades_interceptor) {
interceptors.push_back(std::move(https_upgrades_interceptor));
if (!force_no_https_upgrade) {
auto https_upgrades_interceptor =
HttpsUpgradesInterceptor::MaybeCreateInterceptor(frame_tree_node_id,
navigation_ui_data);
if (https_upgrades_interceptor) {
interceptors.push_back(std::move(https_upgrades_interceptor));
}
}
return interceptors;
@@ -6500,73 +6730,6 @@ void ChromeContentBrowserClient::WillCreateWebTransport(
mojo::PendingRemote<network::mojom::WebTransportHandshakeClient>
handshake_client,
WillCreateWebTransportCallback callback) {
#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
content::RenderFrameHost* frame =
content::RenderFrameHost::FromID(process_id, frame_routing_id);
if (frame) {
int frame_tree_node_id = frame->GetFrameTreeNodeId();
content::WebContents* web_contents =
content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);
DCHECK(web_contents);
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
DCHECK(profile);
auto checker = std::make_unique<safe_browsing::WebApiHandshakeChecker>(
base::BindOnce(
&ChromeContentBrowserClient::GetSafeBrowsingUrlCheckerDelegate,
base::Unretained(this),
safe_browsing::IsSafeBrowsingEnabled(*profile->GetPrefs()),
/*should_check_on_sb_disabled=*/false,
safe_browsing::GetURLAllowlistByPolicy(profile->GetPrefs())),
base::BindRepeating(&content::WebContents::FromFrameTreeNodeId,
frame_tree_node_id),
frame_tree_node_id);
auto* raw_checker = checker.get();
raw_checker->Check(
url,
base::BindOnce(
&ChromeContentBrowserClient::SafeBrowsingWebApiHandshakeChecked,
weak_factory_.GetWeakPtr(), std::move(checker), process_id,
frame_routing_id, url, initiator_origin,
std::move(handshake_client), std::move(callback)));
return;
}
#endif
MaybeInterceptWebTransport(process_id, frame_routing_id, url,
initiator_origin, std::move(handshake_client),
std::move(callback));
}
void ChromeContentBrowserClient::SafeBrowsingWebApiHandshakeChecked(
std::unique_ptr<safe_browsing::WebApiHandshakeChecker> checker,
int process_id,
int frame_routing_id,
const GURL& url,
const url::Origin& initiator_origin,
mojo::PendingRemote<network::mojom::WebTransportHandshakeClient>
handshake_client,
WillCreateWebTransportCallback callback,
safe_browsing::WebApiHandshakeChecker::CheckResult result) {
if (result == safe_browsing::WebApiHandshakeChecker::CheckResult::kProceed) {
MaybeInterceptWebTransport(process_id, frame_routing_id, url,
initiator_origin, std::move(handshake_client),
std::move(callback));
} else {
std::move(callback).Run(std::move(handshake_client),
network::mojom::WebTransportError::New(
net::ERR_ABORTED, quic::QUIC_INTERNAL_ERROR,
"SafeBrowsing check failed", false));
}
}
void ChromeContentBrowserClient::MaybeInterceptWebTransport(
int process_id,
int frame_routing_id,
const GURL& url,
const url::Origin& initiator_origin,
mojo::PendingRemote<network::mojom::WebTransportHandshakeClient>
handshake_client,
WillCreateWebTransportCallback callback) {
#if BUILDFLAG(ENABLE_EXTENSIONS)
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// TODO(crbug.com/40195467): Add a unit test which calls
@@ -6921,6 +7084,8 @@ bool ChromeContentBrowserClient::HandleExternalProtocol(
const std::optional<url::Origin>& initiating_origin,
content::RenderFrameHost* initiator_document,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
#if BUILDFLAG(ENABLE_EXTENSIONS)
// External protocols are disabled for guests. An exception is made for the
// "mailto" protocol, so that pages that utilize it work properly in a
@@ -6945,26 +7110,11 @@ bool ChromeContentBrowserClient::HandleExternalProtocol(
? initiator_document->GetWeakDocumentPtr()
: content::WeakDocumentPtr();
#if BUILDFLAG(IS_ANDROID)
// For Android this is always called on the UI thread.
CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
// Called synchronously so we can populate the |out_factory| param.
// On Android, populate the `out_factory` param.
LaunchURL(weak_factory_.GetWeakPtr(), url, std::move(web_contents_getter),
page_transition, is_primary_main_frame, is_in_fenced_frame_tree,
sandbox_flags, has_user_gesture, initiating_origin,
std::move(weak_initiator_document), out_factory);
#else
// TODO(crbug.com/40248796): Figure out why this was initially made async,
// and, if possible, unify with the sync path above.
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(&LaunchURL, weak_factory_.GetWeakPtr(), url,
std::move(web_contents_getter), page_transition,
is_primary_main_frame, is_in_fenced_frame_tree,
sandbox_flags, has_user_gesture, initiating_origin,
std::move(weak_initiator_document)));
#endif
return true;
}
@@ -7318,6 +7468,14 @@ void ChromeContentBrowserClient::LogWebFeatureForCurrentPage(
render_frame_host, feature);
}
void ChromeContentBrowserClient::LogWebDXFeatureForCurrentPage(
content::RenderFrameHost* render_frame_host,
blink::mojom::WebDXFeature feature) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
page_load_metrics::MetricsWebContentsObserver::RecordFeatureUsage(
render_frame_host, feature);
}
std::string ChromeContentBrowserClient::GetProduct() {
return std::string(version_info::GetProductNameAndVersionForUserAgent());
}
@@ -7873,36 +8031,6 @@ ChromeContentBrowserClient::CreateIdentityRequestDialogController(
return std::make_unique<IdentityDialogController>(web_contents);
}
#if BUILDFLAG(IS_ANDROID)
namespace {
void RunDigitalIdentityCallback(
std::unique_ptr<DigitalIdentitySafetyInterstitialBridgeAndroid> bridge,
content::ContentBrowserClient::DigitalIdentityInterstitialCallback callback,
content::DigitalIdentityProvider::RequestStatusForMetrics
status_for_metrics) {
std::move(callback).Run(status_for_metrics);
}
} // anonymous namespace
content::ContentBrowserClient::DigitalIdentityInterstitialAbortCallback
ChromeContentBrowserClient::ShowDigitalIdentityInterstitialIfNeeded(
content::WebContents& web_contents,
const url::Origin& origin,
bool is_only_requesting_age,
DigitalIdentityInterstitialCallback callback) {
auto bridge =
std::make_unique<DigitalIdentitySafetyInterstitialBridgeAndroid>();
auto* bridge_ptr = bridge.get();
// Callback takes ownership of |bridge|.
return bridge_ptr->ShowInterstitialIfNeeded(
web_contents, origin, is_only_requesting_age,
base::BindOnce(&RunDigitalIdentityCallback, std::move(bridge),
std::move(callback)));
}
#endif
std::unique_ptr<content::DigitalIdentityProvider>
ChromeContentBrowserClient::CreateDigitalIdentityProvider() {
#if BUILDFLAG(IS_ANDROID)
@@ -8204,8 +8332,11 @@ bool ChromeContentBrowserClient::
bool ChromeContentBrowserClient::IsTransientActivationRequiredForHtmlFullscreen(
content::RenderFrameHost* render_frame_host) {
// TODO(crbug.com/40941384): Remove this code and solely rely on permissions.
if (base::FeatureList::IsEnabled(
features::kAutomaticFullscreenContentSetting)) {
features::kAutomaticFullscreenContentSetting) &&
!base::FeatureList::IsEnabled(
blink::features::kAutomaticFullscreenPermissionsQuery)) {
const GURL& url = render_frame_host->GetLastCommittedURL();
const HostContentSettingsMap* const content_settings =
HostContentSettingsMapFactory::GetForProfile(
@@ -8446,9 +8577,11 @@ bool ChromeContentBrowserClient::ShouldSuppressAXLoadComplete(
}
void ChromeContentBrowserClient::BindAIManager(
content::RenderFrameHost* rfh,
content::BrowserContext* browser_context,
mojo::PendingReceiver<blink::mojom::AIManager> receiver) {
AIManagerImpl::Create(rfh, std::move(receiver));
auto* ai_manager =
AIManagerKeyedServiceFactory::GetAIManagerKeyedService(browser_context);
ai_manager->AddReceiver(std::move(receiver));
}
#if !BUILDFLAG(IS_ANDROID)
@@ -8486,7 +8619,9 @@ void ChromeContentBrowserClient::QueryInstalledWebAppsByManifestId(
.Set("manifest_id", manifest_id.spec())
.Set("frame_url", frame_url.spec()));
if (!lock.registrar().IsLocallyInstalled(app_id)) {
if (!lock.registrar().IsInstallState(
app_id, {web_app::proto::INSTALLED_WITHOUT_OS_INTEGRATION,
web_app::proto::INSTALLED_WITH_OS_INTEGRATION})) {
debug_value.Set("did_find_application", false);
return std::nullopt;
}
@@ -8519,3 +8654,8 @@ void ChromeContentBrowserClient::QueryInstalledWebAppsByManifestId(
std::move(callback), std::move(arg_for_shutdown));
}
#endif // !BUILDFLAG(IS_ANDROID)
void ChromeContentBrowserClient::SetSamplingProfiler(
std::unique_ptr<MainThreadStackSamplingProfiler> sampling_profiler) {
sampling_profiler_ = std::move(sampling_profiler);
}
File diff suppressed because it is too large Load Diff
@@ -133,7 +133,7 @@
#include "components/download/content/public/download_navigation_observer.h"
#include "components/enterprise/buildflags/buildflags.h"
#include "components/feed/buildflags.h"
#include "components/fingerprinting_protection_filter/browser/fingerprinting_protection_filter_features.h"
#include "components/fingerprinting_protection_filter/common/fingerprinting_protection_filter_features.h"
#include "components/history/content/browser/web_contents_top_sites_observer.h"
#include "components/history/core/browser/top_sites.h"
#include "components/infobars/content/content_infobar_manager.h"
@@ -155,7 +155,6 @@
#include "components/safe_browsing/content/browser/safe_browsing_tab_observer.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/search/ntp_features.h"
#include "components/search_engines/search_engine_choice/search_engine_choice_utils.h"
#include "components/site_engagement/content/site_engagement_helper.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "components/tracing/common/tracing_switches.h"
@@ -180,6 +179,7 @@
#include "chrome/browser/android/policy/policy_auditor_bridge.h"
#include "chrome/browser/banners/android/chrome_app_banner_manager_android.h"
#include "chrome/browser/content_settings/request_desktop_site_web_contents_observer_android.h"
#include "chrome/browser/dips/dips_navigation_flow_detector.h"
#include "chrome/browser/facilitated_payments/ui/chrome_facilitated_payments_client.h"
#include "chrome/browser/fast_checkout/fast_checkout_tab_helper.h"
#include "chrome/browser/flags/android/chrome_feature_list.h"
@@ -204,8 +204,6 @@
#include "chrome/browser/ui/search_engine_choice/search_engine_choice_tab_helper.h"
#include "chrome/browser/ui/views/side_panel/companion/companion_tab_helper.h"
#include "chrome/browser/ui/views/side_panel/companion/exps_registration_success_observer.h"
#include "chrome/browser/ui/views/side_panel/customize_chrome/customize_chrome_tab_helper.h"
#include "chrome/browser/ui/views/side_panel/customize_chrome/customize_chrome_utils.h"
#include "chrome/browser/ui/views/side_panel/history_clusters/history_clusters_tab_helper.h"
#include "chrome/browser/ui/views/side_panel/read_anything/read_anything_tab_helper.h"
#include "chrome/browser/ui/sync/browser_synced_tab_delegate.h"
@@ -584,6 +582,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
// --- Section 2: Platform-specific tab helpers ---
#if BUILDFLAG(IS_ANDROID)
DipsNavigationFlowDetector::MaybeCreateForWebContents(web_contents);
webapps::MLInstallabilityPromoter::CreateForWebContents(web_contents);
{
// Remove after fixing https://crbug/905919
@@ -641,8 +640,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
PrivacySandboxPromptHelper::CreateForWebContents(web_contents);
}
if (search_engines::IsChoiceScreenFlagEnabled(
search_engines::ChoicePromo::kDialog)) {
if (SearchEngineChoiceTabHelper::IsHelperNeeded()) {
SearchEngineChoiceTabHelper::CreateForWebContents(web_contents);
}
@@ -767,10 +765,6 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
}
#endif
#if !BUILDFLAG(IS_ANDROID)
CustomizeChromeTabHelper::CreateForWebContents(web_contents);
#endif
// --- Section 3: Feature tab helpers behind BUILDFLAGs ---
// NOT for "if enabled"; put those in section 1.
@@ -318,8 +318,11 @@ namespace autofillPrivate {
static void saveAddress(AddressEntry address);
// Gets the list of all countries.
// |forAccountAddressProfile|: whether the address profile opened in the
// editor originates in the user's profile.
// |callback|: Callback which will be called with the countries.
static void getCountryList(
boolean forAccountAddressProfile,
GetCountryListCallback callback);
// Gets the address components for a given country code.
@@ -718,6 +718,8 @@ namespace autotestPrivate {
long jankCount;
// Display throughput percentage at fixed intervals.
long[] throughput;
// The durations of the janks during this animation in millisecond.
double[] jankDurations;
};
// Callback invoked to report the smoothness after StopSmoothnessTracking is
@@ -153,6 +153,7 @@ namespace developerPrivate {
boolean reloading;
boolean custodianApprovalRequired;
boolean parentDisabledPermissions;
boolean unsupportedManifestVersion;
};
dictionary OptionsPage {
@@ -279,10 +280,9 @@ namespace developerPrivate {
boolean showSafeBrowsingAllowlistWarning;
SafetyCheckWarningReason? safetyCheckWarningReason;
boolean showAccessRequestsInToolbar;
boolean acknowledgeSafetyCheckWarning;
boolean? pinnedToToolbar;
boolean isAffectedByMV2Deprecation;
boolean didAcknowledgeMV2DeprecationWarning;
boolean didAcknowledgeMV2DeprecationNotice;
};
dictionary ProfileInfo {
@@ -291,7 +291,7 @@ namespace developerPrivate {
boolean isDeveloperModeControlledByPolicy;
boolean isIncognitoAvailable;
boolean isChildAccount;
boolean isMv2DeprecationWarningDismissed;
boolean isMv2DeprecationNoticeDismissed;
};
// DEPRECATED: Prefer ExtensionInfo.
@@ -345,13 +345,12 @@ namespace developerPrivate {
boolean? showAccessRequestsInToolbar;
SafetyCheckWarningReason? acknowledgeSafetyCheckWarningReason;
boolean? acknowledgeSafetyCheckWarning;
boolean? acknowledgeMv2DeprecationWarning;
boolean? pinnedToToolbar;
};
dictionary ProfileConfigurationUpdate {
boolean? inDeveloperMode;
boolean? isMv2DeprecationWarningDismissed;
boolean? isMv2DeprecationNoticeDismissed;
};
dictionary ExtensionCommandUpdate {
@@ -872,6 +871,9 @@ namespace developerPrivate {
// if one is active.
static void dismissSafetyHubExtensionsMenuNotification();
// Triggers the dismissal of the mv2 deprecation notice for `extensionId`.
static void dismissMv2DeprecationNoticeForExtension(DOMString extensionId);
[nocompile, deprecated="Use openDevTools"]
static void inspect(InspectOptions options,
optional VoidCallback callback);
@@ -431,7 +431,7 @@ namespace downloads {
// size * size pixels. The default and largest size for the icon is 32x32
// pixels. The only supported sizes are 16 and 32. It is an error to specify
// any other size.
[legalValues=(16,32)] long? size;
long? size;
};
// Encapsulates a change in the download UI.
@@ -365,6 +365,8 @@ namespace passwordsPrivate {
callback PasswordManagerPinChangedCallback = void(boolean success);
callback DisconnectCloudAuthenticatorCallback = void(boolean success);
callback IsConnectedToCloudAuthenticatorCallback = void(boolean connected);
callback DeleteAllPasswordManagerDataCallback = void(boolean success);
callback AuthenticationResultCallback = void(boolean result);
interface Functions {
// Function that logs that the Passwords page was accessed from the Chrome
@@ -550,8 +552,11 @@ namespace passwordsPrivate {
// Switches Biometric authentication before filling state after
// successful authentication.
// |callback|: The callback that gets invoked with the authentication
// result.
[platforms = ("win", "mac")] static void
switchBiometricAuthBeforeFillingState();
switchBiometricAuthBeforeFillingState(
AuthenticationResultCallback callback);
// Shows a dialog for creating a shortcut for the Password Manager page.
static void showAddShortcutDialog();
@@ -575,6 +580,12 @@ namespace passwordsPrivate {
// the cloud authenticator.
static void isConnectedToCloudAuthenticator(
IsConnectedToCloudAuthenticatorCallback callback);
// Deletes all password manager data (passwords, passkeys, etc.)
// |callback|: The callback that gets invoked with true on successful
// deletion and false on failure (e.g. not all data was deleted).
static void deleteAllPasswordManagerData(
DeleteAllPasswordManagerDataCallback callback);
};
interface Events {
@@ -106,12 +106,12 @@ namespace settingsPrivate {
GetPrefCallback callback);
// Gets the default page zoom factor. Possible values are currently between
// 0.25 and 5. For a full list, see zoom::kPresetZoomFactors.
// 0.25 and 5. For a full list, see zoom::kPresetBrowserZoomFactors.
static void getDefaultZoom(
GetDefaultZoomCallback callback);
// Sets the page zoom factor. Must be less than 0.001 different than a value
// in zoom::kPresetZoomFactors.
// in zoom::kPresetBrowserZoomFactors.
static void setDefaultZoom(
double zoom,
optional SetDefaultZoomCallback callback);
@@ -6,6 +6,7 @@
#include <functional>
#include <memory>
#include <optional>
#include <string_view>
#include <utility>
@@ -14,7 +15,6 @@
#include "base/debug/crash_logging.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics_action.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
@@ -108,8 +108,8 @@
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/content/renderer/threat_dom_details.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "components/subresource_filter/content/renderer/safe_browsing_unverified_ruleset_dealer.h"
#include "components/subresource_filter/content/renderer/subresource_filter_agent.h"
#include "components/subresource_filter/content/renderer/unverified_ruleset_dealer.h"
#include "components/subresource_filter/core/common/common_features.h"
#include "components/variations/net/variations_http_headers.h"
#include "components/variations/variations_switches.h"
@@ -118,6 +118,7 @@
#include "components/web_cache/renderer/web_cache_impl.h"
#include "components/webapps/renderer/web_page_metadata_agent.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/page_visibility_state.h"
#include "content/public/common/url_constants.h"
@@ -126,7 +127,6 @@
#include "content/public/renderer/render_frame_visitor.h"
#include "extensions/buildflags/buildflags.h"
#include "extensions/renderer/extensions_renderer_api_provider.h"
#include "extensions/renderer/worker_script_context_set.h"
#include "ipc/ipc_sync_channel.h"
#include "media/base/media_switches.h"
#include "media/media_buildflags.h"
@@ -456,8 +456,8 @@ void ChromeContentRendererClient::RenderThreadStarted() {
InitSpellCheck();
#endif
subresource_filter_ruleset_dealer_ = std::make_unique<
subresource_filter::SafeBrowsingUnverifiedRulesetDealer>();
subresource_filter_ruleset_dealer_ =
std::make_unique<subresource_filter::UnverifiedRulesetDealer>();
phishing_model_setter_ =
std::make_unique<safe_browsing::PhishingModelSetterImpl>();
@@ -725,7 +725,7 @@ void ChromeContentRendererClient::RenderFrameCreated(
// Owned by |render_frame|.
new page_load_metrics::MetricsRenderFrameObserver(render_frame);
// There is no render thread, thus no SafeBrowsingUnverifiedRulesetDealer in
// There is no render thread, thus no UnverifiedRulesetDealer in
// ChromeRenderViewTests.
if (subresource_filter_ruleset_dealer_) {
auto* subresource_filter_agent =
@@ -762,8 +762,9 @@ void ChromeContentRendererClient::RenderFrameCreated(
#endif // BUILDFLAG(HAS_SPELLCHECK_PANEL)
#endif
#if BUILDFLAG(ENABLE_FEED_V2)
if (render_frame->IsMainFrame() &&
feed::IsWebFeedEnabledForLocale(country_codes::GetCurrentCountryCode())) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(feed::switches::kEnableRssLinkReader) &&
render_frame->IsMainFrame()) {
new feed::RssLinkReader(render_frame, registry);
}
#endif
@@ -866,6 +867,25 @@ bool ChromeContentRendererClient::IsPluginHandledExternally(
#endif // BUILDFLAG(ENABLE_EXTENSIONS) && BUILDFLAG(ENABLE_PLUGINS)
}
bool ChromeContentRendererClient::IsDomStorageDisabled() const {
if (!base::FeatureList::IsEnabled(features::kPdfEnforcements)) {
return false;
}
#if BUILDFLAG(ENABLE_PDF) && BUILDFLAG(ENABLE_EXTENSIONS)
// PDF renderers shouldn't need to access DOM storage interfaces. Note that
// it's still possible to access localStorage or sessionStorage in a PDF
// document's context via DevTools; returning false here ensures that these
// objects are just seen as null by JavaScript (similarly to what happens for
// opaque origins). This avoids a renderer kill by the browser process which
// isn't expecting PDF renderer processes to ever use DOM storage
// interfaces. See https://crbug.com/357014503.
return pdf::IsPdfRenderer();
#else
return false;
#endif
}
v8::Local<v8::Object> ChromeContentRendererClient::GetScriptableObject(
const blink::WebElement& plugin_element,
v8::Isolate* isolate) {
@@ -1412,17 +1432,8 @@ bool ChromeContentRendererClient::AllowPopup() {
bool ChromeContentRendererClient::ShouldNotifyServiceWorkerOnWebSocketActivity(
v8::Local<v8::Context> context) {
#if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::ScriptContext* script_context =
ChromeExtensionsRendererClient::GetInstance()
->extension_dispatcher()
->GetWorkerScriptContextSet()
->GetContextByV8Context(context);
// Only notify on web socket activity if the service worker is the background
// service worker for an extension.
return script_context &&
ChromeExtensionsRendererClient::GetInstance()
->ExtensionAPIEnabledForServiceWorkerScript(
script_context->service_worker_scope(), script_context->url());
return extensions::Dispatcher::ShouldNotifyServiceWorkerOnWebSocketActivity(
context);
#else
return false;
#endif
@@ -1445,7 +1456,8 @@ ChromeContentRendererClient::GetProtocolHandlerSecurityLevel(
void ChromeContentRendererClient::WillSendRequest(
WebLocalFrame* frame,
ui::PageTransition transition_type,
const blink::WebURL& url,
const blink::WebURL& upstream_url,
const blink::WebURL& target_url,
const net::SiteForCookies& site_for_cookies,
const url::Origin* initiator_origin,
GURL* new_url) {
@@ -1453,22 +1465,24 @@ void ChromeContentRendererClient::WillSendRequest(
// Check whether the request should be allowed. If not allowed, we reset the
// URL to something invalid to prevent the request and cause an error.
ChromeExtensionsRendererClient::GetInstance()->WillSendRequest(
frame, transition_type, url, site_for_cookies, initiator_origin, new_url);
frame, transition_type, upstream_url, target_url, site_for_cookies,
initiator_origin, new_url);
if (!new_url->is_empty())
return;
#endif
if (!url.ProtocolIs(chrome::kChromeSearchScheme))
if (!target_url.ProtocolIs(chrome::kChromeSearchScheme)) {
return;
}
#if !BUILDFLAG(IS_ANDROID)
SearchBox* search_box =
SearchBox::Get(content::RenderFrame::FromWebFrame(frame->LocalRoot()));
if (search_box) {
// Note: this GURL copy could be avoided if host() were added to WebURL.
GURL gurl(url);
GURL gurl(target_url);
if (gurl.host_piece() == chrome::kChromeUIFaviconHost)
search_box->GenerateImageURLFromTransientURL(url, new_url);
search_box->GenerateImageURLFromTransientURL(target_url, new_url);
}
#endif // !BUILDFLAG(IS_ANDROID)
}
@@ -1484,6 +1498,14 @@ uint64_t ChromeContentRendererClient::VisitedLinkHash(
canonical_url);
}
uint64_t ChromeContentRendererClient::PartitionedVisitedLinkFingerprint(
std::string_view canonical_link_url,
const net::SchemefulSite& top_level_site,
const url::Origin& frame_origin) {
return chrome_observer_->visited_link_reader()->ComputePartitionedFingerprint(
canonical_link_url, top_level_site, frame_origin);
}
bool ChromeContentRendererClient::IsLinkVisited(uint64_t link_hash) {
return chrome_observer_->visited_link_reader()->IsVisited(link_hash);
}
@@ -1491,6 +1513,8 @@ bool ChromeContentRendererClient::IsLinkVisited(uint64_t link_hash) {
void ChromeContentRendererClient::AddOrUpdateVisitedLinkSalt(
const url::Origin& origin,
uint64_t salt) {
base::UmaHistogramBoolean(
"Blink.History.VisitedLinks.IsSaltFromNavigationThrottle", true);
return chrome_observer_->visited_link_reader()->AddOrUpdateSalt(origin, salt);
}
@@ -1681,10 +1705,7 @@ void ChromeContentRendererClient::
blink::WebRuntimeFeatures::EnableWebUSBOnServiceWorkers(true);
}
#if !BUILDFLAG(IS_ANDROID)
if (base::FeatureList::IsEnabled(
features::kEnableWebHidOnExtensionServiceWorker)) {
blink::WebRuntimeFeatures::EnableWebHIDOnServiceWorkers(true);
}
blink::WebRuntimeFeatures::EnableWebHIDOnServiceWorkers(true);
#endif // !BUILDFLAG(IS_ANDROID)
}
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
@@ -1791,20 +1812,23 @@ blink::WebFrame* ChromeContentRendererClient::FindFrame(
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
}
bool ChromeContentRendererClient::IsSafeRedirectTarget(const GURL& from_url,
const GURL& to_url) {
bool ChromeContentRendererClient::IsSafeRedirectTarget(const GURL& upstream_url,
const GURL& target_url) {
#if BUILDFLAG(ENABLE_EXTENSIONS)
if (to_url.SchemeIs(extensions::kExtensionScheme)) {
if (target_url.SchemeIs(extensions::kExtensionScheme)) {
const extensions::Extension* extension =
extensions::RendererExtensionRegistry::Get()->GetByID(to_url.host());
if (!extension)
extensions::RendererExtensionRegistry::Get()->GetByID(
target_url.host());
if (!extension) {
return false;
}
// TODO(solomonkinard): Use initiator_origin and add tests.
if (extensions::WebAccessibleResourcesInfo::IsResourceWebAccessible(
extension, to_url.path(), nullptr)) {
if (extensions::WebAccessibleResourcesInfo::IsResourceWebAccessibleRedirect(
extension, target_url, /*initiator_origin=*/std::nullopt,
upstream_url)) {
return true;
}
return extension->guid() == from_url.host();
return extension->guid() == upstream_url.host();
}
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
return true;
@@ -16,7 +16,7 @@
#include <utility>
#include <vector>
#include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_buildflags.h"
#include "base/allocator/partition_allocator/src/partition_alloc/buildflags.h"
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
@@ -45,6 +45,7 @@
#include "base/system/sys_info.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "base/trace_event/optional_trace_event.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
@@ -52,6 +53,8 @@
#include "cc/input/browser_controls_offset_tags_info.h"
#include "components/attribution_reporting/features.h"
#include "components/download/public/common/download_stats.h"
#include "components/input/cursor_manager.h"
#include "components/input/render_widget_host_input_event_router.h"
#include "components/url_formatter/url_formatter.h"
#include "components/viz/common/features.h"
#include "components/viz/host/host_frame_sink_manager.h"
@@ -61,6 +64,7 @@
#include "content/browser/attribution_reporting/attribution_manager.h"
#include "content/browser/attribution_reporting/attribution_os_level_manager.h"
#include "content/browser/bad_message.h"
#include "content/browser/browser_context_impl.h"
#include "content/browser/browser_main_loop.h"
#include "content/browser/browser_plugin/browser_plugin_embedder.h"
#include "content/browser/browser_plugin/browser_plugin_guest.h"
@@ -83,6 +87,7 @@
#include "content/browser/media/media_web_contents_observer.h"
#include "content/browser/permissions/permission_controller_impl.h"
#include "content/browser/permissions/permission_util.h"
#include "content/browser/preloading/prefetch/prefetch_service.h"
#include "content/browser/preloading/preloading.h"
#include "content/browser/preloading/prerender/prerender_final_status.h"
#include "content/browser/preloading/prerender/prerender_host_registry.h"
@@ -120,8 +125,6 @@
#include "content/browser/webui/web_ui_impl.h"
#include "content/common/content_switches_internal.h"
#include "content/common/features.h"
#include "content/common/input/cursor_manager.h"
#include "content/common/input/render_widget_host_input_event_router.h"
#include "content/public/browser/ax_inspect_factory.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_plugin_guest_manager.h"
@@ -163,6 +166,7 @@
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "ppapi/buildflags/buildflags.h"
#include "services/device/public/mojom/wake_lock.mojom.h"
#include "services/network/public/cpp/request_destination.h"
#include "services/network/public/cpp/web_sandbox_flags.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "third_party/abseil-cpp/absl/cleanup/cleanup.h"
@@ -235,11 +239,6 @@
#include "ui/wm/core/window_util.h"
#endif
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && PA_BUILDFLAG(USE_STARSCAN)
#include "base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan.h"
#include "content/browser/starscan_load_observer.h"
#endif
#if !BUILDFLAG(IS_ANDROID)
#include "content/public/browser/document_picture_in_picture_window_controller.h"
#include "content/public/browser/picture_in_picture_window_controller.h"
@@ -510,13 +509,28 @@ FullscreenContentsSet(BrowserContext* browser_context) {
bool IsWindowManagementGranted(RenderFrameHost* host) {
content::PermissionController* permission_controller =
host->GetBrowserContext()->GetPermissionController();
DCHECK(permission_controller);
CHECK(permission_controller);
return permission_controller->GetPermissionStatusForCurrentDocument(
blink::PermissionType::WINDOW_MANAGEMENT, host) ==
blink::mojom::PermissionStatus::GRANTED;
}
// Returns true if `host` has the Automatic Fullscreen permission granted.
bool IsAutomaticFullscreenGranted(RenderFrameHost* host) {
if (!base::FeatureList::IsEnabled(
blink::features::kAutomaticFullscreenPermissionsQuery)) {
return false;
}
content::PermissionController* permission_controller =
host->GetBrowserContext()->GetPermissionController();
CHECK(permission_controller);
return permission_controller->GetPermissionStatusForCurrentDocument(
blink::PermissionType::AUTOMATIC_FULLSCREEN, host) ==
blink::mojom::PermissionStatus::GRANTED;
}
// Adjust the requested `rect` for opening or placing a window and return the id
// of the display where the window will be placed. The bounds may not extend
// outside a single screen's work area, and the `host` requires permission to
@@ -633,7 +647,7 @@ using RenderWidgetHostAtPointCallback =
std::optional<gfx::PointF>)>;
void RunCallback(RenderWidgetHostAtPointCallback callback,
base::WeakPtr<RenderWidgetHostViewInput> view,
base::WeakPtr<input::RenderWidgetHostViewInput> view,
std::optional<gfx::PointF> point) {
auto* target = static_cast<RenderWidgetHostViewBase*>(view.get());
if (!callback.is_null()) {
@@ -790,6 +804,10 @@ std::optional<double> WebContentsImpl::AdjustedChildZoom(
return std::nullopt;
}
bool WebContentsImpl::IsPopup() const {
return is_popup_;
}
void WebContents::SetScreenOrientationDelegate(
ScreenOrientationDelegate* delegate) {
ScreenOrientationProvider::SetDelegate(delegate);
@@ -912,18 +930,6 @@ WebContentsImpl::WebContentsTreeNode::WebContentsTreeNode(
WebContentsImpl::WebContentsTreeNode::~WebContentsTreeNode() = default;
std::unique_ptr<WebContents>
WebContentsImpl::WebContentsTreeNode::DisconnectFromOuterWebContents() {
OPTIONAL_TRACE_EVENT0("content",
"WebContentsTreeNode::DisconnectFromOuterWebContents");
std::unique_ptr<WebContents> inner_contents =
outer_web_contents_->node_.DetachInnerWebContents(current_web_contents_);
OuterContentsFrameTreeNode()->RemoveObserver(this);
outer_contents_frame_tree_node_id_ = FrameTreeNode::kFrameTreeNodeInvalidId;
outer_web_contents_ = nullptr;
return inner_contents;
}
void WebContentsImpl::WebContentsTreeNode::AttachInnerWebContents(
std::unique_ptr<WebContents> inner_web_contents,
RenderFrameHostImpl* render_frame_host) {
@@ -1186,9 +1192,9 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context)
last_active_time_(base::TimeTicks::Now()),
closed_by_user_gesture_(false),
minimum_zoom_percent_(
static_cast<int>(blink::kMinimumPageZoomFactor * 100)),
static_cast<int>(blink::kMinimumBrowserZoomFactor * 100)),
maximum_zoom_percent_(
static_cast<int>(blink::kMaximumPageZoomFactor * 100)),
static_cast<int>(blink::kMaximumBrowserZoomFactor * 100)),
zoom_scroll_remainder_(0),
force_disable_overscroll_content_(false),
last_dialog_suppressed_(false),
@@ -1230,15 +1236,6 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context)
if (base::FeatureList::IsEnabled(blink::features::kSharedStorageAPI)) {
SharedStorageBudgetCharger::CreateForWebContents(this);
}
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && PA_BUILDFLAG(USE_STARSCAN)
// TODO(crbug.com/40190798): Remove or move to another place after finishing
// the PCScan experiment.
if (partition_alloc::internal::PCScan::IsInitialized()) {
star_scan_load_observer_ = std::make_unique<StarScanLoadObserver>(this);
}
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_BUILDFLAG(USE_STARSCAN)
}
WebContentsImpl::~WebContentsImpl() {
@@ -1326,6 +1323,34 @@ WebContentsImpl::~WebContentsImpl() {
// prerendering. Shutdown them by destructing PrerenderHostRegistry.
prerender_host_registry_.reset();
// For historical reasons, it is the requestor's responsibility to reset
// `PrefetchContainer`s that were created by the requestor (= `this`) but have
// not yet started prefetching (Otherwise, they will stay alive forever in
// `PrefetchService`).
// TODO(crbug.com/40946257): Refactor to handle this case better.
if (base::FeatureList::IsEnabled(
features::kPrefetchBrowserInitiatedTriggers)) {
PrefetchService* prefetch_service =
BrowserContextImpl::From(GetBrowserContext())->GetPrefetchService();
if (prefetch_service) {
for (const auto& prefetch_container : prefetch_containers_) {
if (prefetch_container) {
switch (prefetch_container->GetLoadState()) {
case PrefetchContainer::LoadState::kNotStarted:
case PrefetchContainer::LoadState::kEligible:
case PrefetchContainer::LoadState::kFailedIneligible:
case PrefetchContainer::LoadState::kFailedHeldback:
prefetch_service->ResetPrefetch(prefetch_container);
break;
case PrefetchContainer::LoadState::kStarted:
break;
}
}
}
}
prefetch_containers_.clear();
}
#if BUILDFLAG(ENABLE_PPAPI)
// Call this before WebContentsDestroyed() is broadcasted since
// AudioFocusManager will be destroyed after that.
@@ -1414,6 +1439,16 @@ std::unique_ptr<WebContentsImpl> WebContentsImpl::CreateWithOpener(
params.guest_delegate->GetOwnerWebContents());
}
// To support multi-network feature in chrome (e.g. want to open a tab over
// a specific network such as Wi-Fi while the current default network is
// cellular connection), a feasible solution would be to associate the target
// network handle to WebContents on creation time and MUST set it before
// WebContents initialization, otherwise the renderer might create a
// URLLoaderFactory that won't load the resources from the target network
// handle during WebContents initialization below, as a result, it will end
// up with a URLLoaderFactory that has not been bound to the target network.
new_contents->target_network_ = params.target_network;
new_contents->Init(params, frame_policy);
if (outer_web_contents) {
outer_web_contents->InnerWebContentsCreated(new_contents.get());
@@ -2043,7 +2078,8 @@ class AXTreeSnapshotCombiner : public base::RefCounted<AXTreeSnapshotCombiner> {
void WebContentsImpl::RequestAXTreeSnapshot(AXTreeSnapshotCallback callback,
ui::AXMode ax_mode,
size_t max_nodes,
base::TimeDelta timeout) {
base::TimeDelta timeout,
AXTreeSnapshotPolicy policy) {
OPTIONAL_TRACE_EVENT1("content", "WebContentsImpl::RequestAXTreeSnapshot",
"mode", ax_mode.ToString());
// Send a request to each of the frames in parallel. Each one will return
@@ -2057,9 +2093,24 @@ void WebContentsImpl::RequestAXTreeSnapshot(AXTreeSnapshotCallback callback,
auto combiner = base::MakeRefCounted<AXTreeSnapshotCombiner>(
std::move(callback), std::move(params));
GetPrimaryMainFrame()->ForEachRenderFrameHost(
[&combiner](RenderFrameHostImpl* rfh) {
GetPrimaryMainFrame()->ForEachRenderFrameHostWithAction(
[this, &combiner, policy](RenderFrameHostImpl* rfh) {
switch (policy) {
case AXTreeSnapshotPolicy::kAll:
break;
case AXTreeSnapshotPolicy::kSameOriginDirectDescendants:
if (GetPrimaryMainFrame()->GetSiteInstance() !=
rfh->GetSiteInstance() ||
rfh->IsFencedFrameRoot() ||
!GetPrimaryMainFrame()
->GetLastCommittedOrigin()
.IsSameOriginWith(rfh->GetLastCommittedOrigin())) {
return FrameIterationAction::kSkipChildren;
}
break;
}
combiner->AXTreeSnapshotOnFrame(rfh);
return FrameIterationAction::kContinue;
});
}
@@ -2177,6 +2228,13 @@ void WebContentsImpl::SetUserAgentOverride(
should_override_user_agent_in_new_tabs_ = override_in_new_tabs;
// Update any in-flight load requests with overrides for new tabs.
if (delayed_load_url_params_.get()) {
delayed_load_url_params_->override_user_agent =
override_in_new_tabs ? NavigationController::UA_OVERRIDE_TRUE
: NavigationController::UA_OVERRIDE_FALSE;
}
renderer_preferences_.user_agent_override = ua_override;
// Send the new override string to all renderers in the current page.
@@ -2874,6 +2932,11 @@ void WebContentsImpl::AttachInnerWebContents(
DCHECK_EQ(this, WebContents::FromRenderFrameHost(render_frame_host_impl));
DCHECK(render_frame_host_impl->GetParent());
// Inner WebContents aren't supported with prerendering. See
// https://crbug.com/40191159 for details.
CHECK_NE(RenderFrameHostImpl::LifecycleStateImpl::kPrerendering,
render_frame_host_impl->lifecycle_state());
RenderFrameHostManager* inner_render_manager =
inner_web_contents_impl->GetRenderManager();
RenderFrameHostImpl* inner_main_frame =
@@ -2970,66 +3033,6 @@ void WebContentsImpl::AttachInnerWebContents(
inner_main_frame->PropagateEmbeddingTokenToParentFrame();
}
std::unique_ptr<WebContents> WebContentsImpl::DetachFromOuterWebContents() {
OPTIONAL_TRACE_EVENT0("content",
"WebContentsImpl::DetachFromOuterWebContents");
auto* outer_web_contents = GetOuterWebContents();
DCHECK(outer_web_contents);
GetPrimaryMainFrame()
->GetParentOrOuterDocumentOrEmbedder()
->set_inner_tree_main_frame_tree_node_id(
FrameTreeNode::kFrameTreeNodeInvalidId);
RecursivelyUnregisterRenderWidgetHostViews();
// Each RenderViewHost has a RenderWidgetHost which can have a
// RenderWidgetHostView, and it needs to be re-created with the appropriate
// platform view. It is important to re-create all child views, not only the
// current one, since the view can be swapped due to a cross-origin
// navigation.
std::set<RenderViewHostImpl*> render_view_hosts;
primary_frame_tree_.ForEachRenderViewHost([&render_view_hosts](
RenderViewHostImpl* rvh) {
if (rvh->GetWidget() && rvh->GetWidget()->GetView()) {
DCHECK(rvh->GetWidget()->GetView()->IsRenderWidgetHostViewChildFrame());
render_view_hosts.insert(rvh);
}
});
for (auto* render_view_host : render_view_hosts) {
render_view_host->GetWidget()->GetView()->Destroy();
}
GetRenderManager()
->current_frame_host()
->browsing_context_state()
->DeleteOuterDelegateProxy(node_.OuterContentsFrameTreeNode()
->current_frame_host()
->GetSiteInstance()
->group());
view_ = CreateWebContentsView(
this, GetContentClient()->browser()->GetWebContentsViewDelegate(this),
&render_view_host_delegate_view_);
view_->CreateView(gfx::NativeView());
std::unique_ptr<WebContents> web_contents =
node_.DisconnectFromOuterWebContents();
DCHECK_EQ(web_contents.get(), this);
node_.SetFocusedFrameTree(&GetPrimaryFrameTree());
for (auto* render_view_host : render_view_hosts) {
CreateRenderWidgetHostViewForRenderManager(render_view_host);
}
RecursivelyRegisterRenderWidgetHostViews();
GetPrimaryMainFrame()->UpdateAXTreeData();
// Invoke on the *outer* web contents observers for symmetry.
outer_web_contents->observers_.NotifyObservers(
&WebContentsObserver::InnerWebContentsDetached, this);
return web_contents;
}
void WebContentsImpl::RecursivelyRegisterRenderWidgetHostViews() {
OPTIONAL_TRACE_EVENT0(
"content", "WebContentsImpl::RecursivelyRegisterRenderWidgetHostViews");
@@ -3238,6 +3241,10 @@ const blink::web_pref::WebPreferences WebContentsImpl::ComputeWebPreferences() {
prefs.spatial_navigation_enabled = false;
}
#if BUILDFLAG(IS_ANDROID)
prefs.long_press_link_select_text = long_press_link_select_text_;
#endif
prefs.stylus_handwriting_enabled = stylus_handwriting_enabled_;
prefs.disable_reading_from_canvas =
@@ -3939,7 +3946,8 @@ bool WebContentsImpl::PreHandleGestureEvent(
return delegate_ && delegate_->PreHandleGestureEvent(this, event);
}
RenderWidgetHostInputEventRouter* WebContentsImpl::GetInputEventRouter() {
input::RenderWidgetHostInputEventRouter*
WebContentsImpl::GetInputEventRouter() {
if (!IsBeingDestroyed()) {
if (GetOuterWebContents()) {
return GetOuterWebContents()->GetInputEventRouter();
@@ -3947,7 +3955,7 @@ RenderWidgetHostInputEventRouter* WebContentsImpl::GetInputEventRouter() {
if (!rwh_input_event_router_.get()) {
rwh_input_event_router_ =
std::make_unique<RenderWidgetHostInputEventRouter>(
std::make_unique<input::RenderWidgetHostInputEventRouter>(
GetHostFrameSinkManager(), this);
}
}
@@ -4630,6 +4638,8 @@ FrameTree* WebContentsImpl::CreateNewWindow(
if (!web_contents_impl) {
return nullptr;
}
web_contents_impl->is_popup_ =
params.disposition == WindowOpenDisposition::NEW_POPUP;
return &web_contents_impl->GetPrimaryFrameTree();
}
@@ -4713,6 +4723,8 @@ FrameTree* WebContentsImpl::CreateNewWindow(
}
auto* new_contents_impl = new_contents.get();
new_contents_impl->is_popup_ =
params.disposition == WindowOpenDisposition::NEW_POPUP;
// If the new frame has a name, make sure any SiteInstances that can find
// this named frame have proxies for it. Must be called after
@@ -6458,11 +6470,16 @@ bool WebContentsImpl::FocusLocationBarByDefault() {
void WebContentsImpl::DidStartNavigation(NavigationHandle* navigation_handle) {
TRACE_EVENT1("navigation", "WebContentsImpl::DidStartNavigation",
"navigation_handle", navigation_handle);
{
SCOPED_UMA_HISTOGRAM_TIMER("WebContentsObserver.DidStartNavigation");
observers_.NotifyObservers(&WebContentsObserver::DidStartNavigation,
navigation_handle);
}
base::ElapsedTimer duration;
observers_.NotifyObservers(&WebContentsObserver::DidStartNavigation,
navigation_handle);
base::TimeDelta elapsed = duration.Elapsed();
base::UmaHistogramTimes("WebContentsObserver.DidStartNavigation", elapsed);
base::UmaHistogramTimes(
base::StrCat(
{"WebContentsObserver.DidStartNavigation.",
navigation_handle->IsInMainFrame() ? "MainFrame" : "Subframe"}),
elapsed);
if (navigation_handle->IsInPrimaryMainFrame()) {
// When the browser is started with about:blank as the startup URL, focus
// the location bar (which will also select its contents) so people can
@@ -6738,7 +6755,8 @@ void WebContentsImpl::NotifyNavigationStateChangedFromController(
NotifyNavigationStateChanged(changed_flags);
}
TouchEmulator* WebContentsImpl::GetTouchEmulator(bool create_if_necessary) {
input::TouchEmulator* WebContentsImpl::GetTouchEmulator(
bool create_if_necessary) {
CHECK(rwh_input_event_router_);
if (!touch_emulator_ && create_if_necessary) {
@@ -6905,6 +6923,14 @@ void WebContentsImpl::DidNavigateAnyFramePostCommit(
}
}
void WebContentsImpl::DidUpdateNavigationHandleTiming(
NavigationHandle* navigation_handle) {
SCOPED_UMA_HISTOGRAM_TIMER(
"WebContentsObserver.DidUpdateNavigationHandleTiming");
observers_.NotifyObservers(
&WebContentsObserver::DidUpdateNavigationHandleTiming, navigation_handle);
}
bool WebContentsImpl::CanOverscrollContent() const {
OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::CanOverscrollContent");
// Disable overscroll when touch emulation is on. See crbug.com/369938.
@@ -6997,10 +7023,17 @@ void WebContentsImpl::DidLoadResourceFromMemoryCache(
StoragePartition* partition = source->GetProcess()->GetStoragePartition();
DCHECK(!blink::IsRequestDestinationFrame(request_destination));
// This method should only be called for resource loads (not navigations), so
// CHECK that here using `request_destination`. Note that
// `network::mojom::RequestDestination::kObject` and
// `network::mojom::RequestDestination::kEmbed` can correspond to navigations
// (see `blink::IsRequestDestinationFrame()`) but can also correspond to
// resource loads, so exclude those from the CHECK.
CHECK(request_destination != network::mojom::RequestDestination::kDocument);
CHECK(!network::IsRequestDestinationEmbeddedFrame(request_destination));
partition->GetNetworkContext()->NotifyExternalCacheHit(
url, http_method, source->GetNetworkIsolationKey(),
/*is_subframe_document_resource=*/false,
/*include_credentials=*/include_credentials);
}
@@ -7063,7 +7096,8 @@ void WebContentsImpl::ViewSource(RenderFrameHostImpl* frame) {
// Any new WebContents opened while this WebContents is in fullscreen can be
// used to confuse the user, so drop fullscreen.
base::ScopedClosureRunner fullscreen_block = ForSecurityDropFullscreen();
base::ScopedClosureRunner fullscreen_block =
ForSecurityDropFullscreen(/*display_id=*/display::kInvalidDisplayId);
// The new view source contents will be independent of this contents, so
// release the fullscreen block.
fullscreen_block.RunAndReset();
@@ -7324,7 +7358,8 @@ void WebContentsImpl::EnumerateDirectory(
// Any explicit focusing of another window while this WebContents is in
// fullscreen can be used to confuse the user, so drop fullscreen.
base::ScopedClosureRunner fullscreen_block = ForSecurityDropFullscreen();
base::ScopedClosureRunner fullscreen_block =
ForSecurityDropFullscreen(/*display_id=*/display::kInvalidDisplayId);
listener->SetFullscreenBlock(std::move(fullscreen_block));
if (delegate_) {
@@ -7627,10 +7662,7 @@ bool WebContentsImpl::UpdateTitleForEntryImpl(NavigationEntryImpl* entry,
return false; // Nothing changed, don't bother.
}
entry->SetTitle(final_title);
// The title for display may differ from the title just set; grab it.
final_title = entry->GetTitleForDisplay();
entry->SetTitle(std::move(final_title));
return true;
}
@@ -7930,7 +7962,8 @@ void WebContentsImpl::RunJavaScriptDialog(
// Running a dialog causes an exit to webpage-initiated fullscreen.
// http://crbug.com/728276
base::ScopedClosureRunner fullscreen_block = ForSecurityDropFullscreen();
base::ScopedClosureRunner fullscreen_block =
ForSecurityDropFullscreen(/*display_id=*/display::kInvalidDisplayId);
auto callback = base::BindOnce(
&WebContentsImpl::OnDialogClosed, weak_factory_.GetWeakPtr(),
@@ -8041,7 +8074,8 @@ void WebContentsImpl::RunBeforeUnloadConfirm(
// Running a dialog causes an exit to webpage-initiated fullscreen.
// http://crbug.com/728276
base::ScopedClosureRunner fullscreen_block = ForSecurityDropFullscreen();
base::ScopedClosureRunner fullscreen_block =
ForSecurityDropFullscreen(/*display_id=*/display::kInvalidDisplayId);
auto callback = base::BindOnce(
&WebContentsImpl::OnDialogClosed, weak_factory_.GetWeakPtr(),
@@ -8110,7 +8144,8 @@ void WebContentsImpl::RunFileChooser(
// Any explicit focusing of another window while this WebContents is in
// fullscreen can be used to confuse the user, so drop fullscreen.
base::ScopedClosureRunner fullscreen_block = ForSecurityDropFullscreen();
base::ScopedClosureRunner fullscreen_block =
ForSecurityDropFullscreen(/*display_id=*/display::kInvalidDisplayId);
listener->SetFullscreenBlock(std::move(fullscreen_block));
if (delegate_) {
@@ -9042,7 +9077,8 @@ void WebContentsImpl::DidCallFocus() {
OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::DidCallFocus");
// Any explicit focusing of another window while this WebContents is in
// fullscreen can be used to confuse the user, so drop fullscreen.
base::ScopedClosureRunner fullscreen_block = ForSecurityDropFullscreen();
base::ScopedClosureRunner fullscreen_block =
ForSecurityDropFullscreen(/*display_id=*/display::kInvalidDisplayId);
// The other contents is independent of this contents, so release the
// fullscreen block.
fullscreen_block.RunAndReset();
@@ -10286,6 +10322,15 @@ void WebContentsImpl::IsClipboardPasteAllowedByPolicy(
weak_factory_.GetWeakPtr(), std::move(callback)));
}
void WebContentsImpl::OnTextCopiedToClipboard(
RenderFrameHostImpl* render_frame_host,
const std::u16string& copied_text) {
OPTIONAL_TRACE_EVENT1("content", "WebContentsImpl::OnTextCopiedToClipboard",
"render_frame_host", render_frame_host);
observers_.NotifyObservers(&WebContentsObserver::OnTextCopiedToClipboard,
render_frame_host, copied_text);
}
void WebContentsImpl::IsClipboardPasteAllowedWrapperCallback(
IsClipboardPasteAllowedCallback callback,
std::optional<ClipboardPasteData> clipboard_paste_data) {
@@ -10326,6 +10371,11 @@ bool WebContentsImpl::IsTransientActivationRequiredForHtmlFullscreen() {
return true;
}
// Waive transient activation requirements if Automatic Fullscreen is granted.
if (IsAutomaticFullscreenGranted(host)) {
return false;
}
return GetContentClient()
->browser()
->IsTransientActivationRequiredForHtmlFullscreen(host);
@@ -10860,11 +10910,42 @@ gfx::mojom::DelegatedInkPointRenderer* WebContentsImpl::GetDelegatedInkRenderer(
return delegated_ink_point_renderer_.get();
}
void WebContentsImpl::StartPrefetch(
const GURL& prefetch_url,
bool use_prefetch_proxy,
const blink::mojom::Referrer& referrer,
const std::optional<url::Origin>& referring_origin,
base::WeakPtr<PreloadingAttempt> attempt) {
if (!base::FeatureList::IsEnabled(
features::kPrefetchBrowserInitiatedTriggers)) {
return;
}
PrefetchService* prefetch_service =
BrowserContextImpl::From(GetBrowserContext())->GetPrefetchService();
if (!prefetch_service) {
return;
}
PrefetchType prefetch_type(PreloadingTriggerType::kEmbedder,
use_prefetch_proxy);
auto container = std::make_unique<PrefetchContainer>(
*this, prefetch_url, prefetch_type, referrer, referring_origin,
/*no_vary_search_expected=*/std::nullopt, std::move(attempt));
// TODO(crbug.com/40946257): Update this list when prefetch container is
// eliminated from `PrefetchService`.
prefetch_containers_.push_back(container->GetWeakPtr());
prefetch_service->AddPrefetchContainer(std::move(container));
}
std::unique_ptr<PrerenderHandle> WebContentsImpl::StartPrerendering(
const GURL& prerendering_url,
PreloadingTriggerType trigger_type,
const std::string& embedder_histogram_suffix,
ui::PageTransition page_transition,
bool should_warm_up_compositor,
PreloadingHoldbackStatus holdback_status_override,
PreloadingAttempt* preloading_attempt,
base::RepeatingCallback<bool(const GURL&)> url_match_predicate,
@@ -10879,7 +10960,8 @@ std::unique_ptr<PrerenderHandle> WebContentsImpl::StartPrerendering(
content::ChildProcessHost::kInvalidUniqueID, GetWeakPtr(),
/*initiator_frame_token=*/std::nullopt,
/*initiator_frame_tree_node_id=*/RenderFrameHost::kNoFrameTreeNodeId,
ukm::kInvalidSourceId, page_transition, std::move(url_match_predicate),
ukm::kInvalidSourceId, page_transition, should_warm_up_compositor,
std::move(url_match_predicate),
std::move(prerender_navigation_handle_callback));
attributes.holdback_status_override = holdback_status_override;
@@ -11021,6 +11103,20 @@ WebContentsImpl::GetBackForwardTransitionAnimationManager() {
return GetView()->GetBackForwardTransitionAnimationManager();
}
#if BUILDFLAG(IS_ANDROID)
void WebContentsImpl::SetLongPressLinkSelectText(bool enabled) {
if (long_press_link_select_text_ == enabled) {
return;
}
long_press_link_select_text_ = enabled;
NotifyPreferencesChanged();
}
#endif
net::handles::NetworkHandle WebContentsImpl::GetTargetNetwork() {
return target_network_;
}
// static
void WebContentsImpl::UpdateAttributionSupportAllRenderers() {
for (WebContentsImpl* web_contents : GetAllWebContents()) {
@@ -19,7 +19,6 @@
#include "build/chromeos_buildflags.h"
#include "cc/base/features.h"
#include "components/attribution_reporting/features.h"
#include "components/ml/webnn/features.mojom-features.h"
#include "content/common/content_navigation_policy.h"
#include "content/common/content_switches_internal.h"
#include "content/common/features.h"
@@ -34,6 +33,7 @@
#include "media/base/media_switches.h"
#include "services/device/public/cpp/device_features.h"
#include "services/network/public/cpp/features.h"
#include "services/webnn/public/mojom/features.mojom-features.h"
#include "third_party/blink/public/common/buildflags.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/features_generated.h"
@@ -256,9 +256,6 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
#if BUILDFLAG(IS_CHROMEOS)
{wf::EnableLockedMode, raw_ref(blink::features::kLockedMode)},
#endif
{wf::EnableMachineLearningModelLoader,
raw_ref(features::kEnableMachineLearningModelLoaderWebPlatformApi),
kSetOnlyIfOverridden},
{wf::EnableMediaCastOverlayButton,
raw_ref(media::kMediaCastOverlayButton)},
{wf::EnableMediaEngagementBypassAutoplayPolicies,
@@ -305,9 +302,6 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
{wf::EnableWebIdentityDigitalCredentials,
raw_ref(features::kWebIdentityDigitalCredentials),
kSetOnlyIfOverridden},
{wf::EnableMachineLearningNeuralNetwork,
raw_ref(webnn::mojom::features::kWebMachineLearningNeuralNetwork),
kDefault},
{wf::EnableWebOTP, raw_ref(features::kWebOTP), kSetOnlyIfOverridden},
{wf::EnableWebOTPAssertionFeaturePolicy,
raw_ref(features::kWebOTPAssertionFeaturePolicy),
@@ -335,6 +329,8 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
raw_ref(features::kRemoveMobileViewportDoubleTap)},
{wf::EnableServiceWorkerStaticRouter,
raw_ref(features::kServiceWorkerStaticRouter)},
{wf::EnablePermissions, raw_ref(features::kWebPermissionsApi),
kSetOnlyIfOverridden},
};
for (const auto& mapping : blinkFeatureToBaseFeatureMapping) {
SetRuntimeFeatureFromChromiumFeature(
@@ -362,8 +358,6 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
{"AttributionReportingCrossAppWeb",
raw_ref(features::kPrivacySandboxAdsAPIsOverride),
kSetOnlyIfOverridden},
{"AttributionReportingCrossAppWeb",
raw_ref(features::kAttributionReportingCrossAppWebOverride)},
{"AndroidDownloadableFontsMatching",
raw_ref(features::kAndroidDownloadableFontsMatching)},
#if BUILDFLAG(IS_ANDROID)
@@ -384,7 +378,7 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
kSetOnlyIfOverridden},
{"FencedFramesLocalUnpartitionedDataAccess",
raw_ref(blink::features::kFencedFramesLocalUnpartitionedDataAccess)},
{"Fledge", raw_ref(blink::features::kFledge), kSetOnlyIfOverridden},
{"Fledge", raw_ref(blink::features::kFledge)},
{"Fledge", raw_ref(features::kPrivacySandboxAdsAPIsOverride),
kSetOnlyIfOverridden},
{"Fledge", raw_ref(features::kPrivacySandboxAdsAPIsM1Override),
@@ -394,6 +388,8 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
{"FontSrcLocalMatching", raw_ref(features::kFontSrcLocalMatching)},
{"LegacyWindowsDWriteFontFallback",
raw_ref(features::kLegacyWindowsDWriteFontFallback)},
{"MachineLearningNeuralNetwork",
raw_ref(webnn::mojom::features::kWebMachineLearningNeuralNetwork)},
{"OriginIsolationHeader", raw_ref(features::kOriginIsolationHeader)},
{"ReduceAcceptLanguage",
raw_ref(network::features::kReduceAcceptLanguage)},
@@ -449,7 +445,6 @@ void SetRuntimeFeaturesFromCommandLine(const base::CommandLine& command_line) {
using wrf = WebRuntimeFeatures;
const SwitchToFeatureMap switchToFeatureMapping[] = {
// Stable Features
{wrf::EnablePermissions, switches::kDisablePermissionsAPI, false},
{wrf::EnablePresentation, switches::kDisablePresentationAPI, false},
{wrf::EnableRemotePlayback, switches::kDisableRemotePlaybackAPI, false},
{wrf::EnableTimerThrottlingForBackgroundTabs,
@@ -478,6 +473,8 @@ void SetRuntimeFeaturesFromCommandLine(const base::CommandLine& command_line) {
blink::switches::kKeyboardFocusableScrollersEnabled, true},
{wrf::EnableKeyboardFocusableScrollers,
blink::switches::kKeyboardFocusableScrollersOptOut, false},
{wrf::EnableStandardizedBrowserZoom,
blink::switches::kDisableStandardizedBrowserZoom, false},
{wrf::EnableCSSCustomStateDeprecatedSyntax,
blink::switches::kCSSCustomStateDeprecatedSyntaxEnabled, true},
{wrf::EnableTextFragmentIdentifiers,
@@ -20,7 +20,7 @@
#include "build/build_config.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
#include "content/browser/ai/mock_ai_manager_impl.h"
#include "content/browser/ai/echo_ai_manager_impl.h"
#include "content/public/browser/anchor_element_preconnect_delegate.h"
#include "content/public/browser/authenticator_request_client_delegate.h"
#include "content/public/browser/browser_context.h"
@@ -125,6 +125,8 @@ bool ContentBrowserClient::IsShuttingDown() {
return false;
}
void ContentBrowserClient::ThreadPoolWillTerminate() {}
bool ContentBrowserClient::AllowGpuLaunchRetryOnIOThread() {
return true;
}
@@ -165,10 +167,11 @@ bool ContentBrowserClient::ShouldAllowProcessPerSiteForMultipleMainFrames(
return true;
}
bool ContentBrowserClient::ShouldUseSpareRenderProcessHost(
std::optional<ContentBrowserClient::SpareProcessRefusedByEmbedderReason>
ContentBrowserClient::ShouldUseSpareRenderProcessHost(
BrowserContext* browser_context,
const GURL& site_url) {
return true;
return std::nullopt;
}
bool ContentBrowserClient::DoesSiteRequireDedicatedProcess(
@@ -178,6 +181,14 @@ bool ContentBrowserClient::DoesSiteRequireDedicatedProcess(
return false;
}
bool ContentBrowserClient::ShouldAllowCrossProcessSandboxedFrameForPrecursor(
BrowserContext* browser_context,
const GURL& precursor,
const GURL& url) {
DCHECK(browser_context);
return true;
}
bool ContentBrowserClient::ShouldLockProcessToSite(
BrowserContext* browser_context,
const GURL& effective_url) {
@@ -674,6 +685,7 @@ bool ContentBrowserClient::ShouldDenyRequestOnCertificateError(
base::OnceClosure ContentBrowserClient::SelectClientCertificate(
BrowserContext* browser_context,
int process_id,
WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList client_certs,
@@ -958,7 +970,8 @@ std::wstring ContentBrowserClient::GetAppContainerSidForSandboxType(
L"924012148-129201922");
}
bool ContentBrowserClient::IsRendererAppContainerDisabled() {
bool ContentBrowserClient::IsAppContainerDisabled(
sandbox::mojom::Sandbox sandbox_type) {
return false;
}
@@ -973,6 +986,10 @@ bool ContentBrowserClient::IsRendererCodeIntegrityEnabled() {
return false;
}
bool ContentBrowserClient::IsPdfFontProxyEnabled() {
return false;
}
bool ContentBrowserClient::ShouldEnableAudioProcessHighPriority() {
// TODO(crbug.com/40242320): Delete this method when the
// kAudioProcessHighPriorityEnabled enterprise policy is deprecated.
@@ -1095,6 +1112,7 @@ ContentBrowserClient::WillCreateURLLoaderRequestInterceptors(
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id,
int64_t navigation_id,
bool force_no_https_upgrade,
scoped_refptr<base::SequencedTaskRunner> navigation_response_task_runner) {
return std::vector<std::unique_ptr<URLLoaderRequestInterceptor>>();
}
@@ -1526,17 +1544,6 @@ ContentBrowserClient::CreateIdentityRequestDialogController(
return std::make_unique<IdentityRequestDialogController>();
}
ContentBrowserClient::DigitalIdentityInterstitialAbortCallback
ContentBrowserClient::ShowDigitalIdentityInterstitialIfNeeded(
WebContents& web_contents,
const url::Origin& origin,
bool is_only_requesting_age,
DigitalIdentityInterstitialCallback callback) {
std::move(callback).Run(
DigitalIdentityProvider::RequestStatusForMetrics::kErrorOther);
return base::OnceClosure();
}
std::unique_ptr<DigitalIdentityProvider>
ContentBrowserClient::CreateDigitalIdentityProvider() {
return nullptr;
@@ -1743,9 +1750,9 @@ bool ContentBrowserClient::ShouldSuppressAXLoadComplete(RenderFrameHost* rfh) {
}
void ContentBrowserClient::BindAIManager(
RenderFrameHost* rfh,
BrowserContext* browser_context,
mojo::PendingReceiver<blink::mojom::AIManager> receiver) {
MockAIManagerImpl::Create(rfh, std::move(receiver));
EchoAIManagerImpl::Create(browser_context, std::move(receiver));
}
#if !BUILDFLAG(IS_ANDROID)
@@ -47,7 +47,8 @@ namespace app.runtime {
arc,
intent_url,
app_home_page,
focus_mode
focus_mode,
sparky
};
// An app can be launched with a specific action in mind, for example, to
@@ -95,7 +95,6 @@
orientationChanged,
parentChanged,
placeholderChanged,
portalActivated,
positionInSetChanged,
rangeValueChanged,
rangeValueMaxChanged,
@@ -310,7 +309,7 @@
pdfRoot,
pluginObject,
popUpButton,
portal,
portalDeprecated,
preDeprecated,
progressIndicator,
radioButton,
@@ -478,6 +477,7 @@
contents,
placeholder,
popoverAttribute,
prohibited,
relatedElement,
title,
value
@@ -488,6 +488,7 @@
attributeExplicitlyEmpty,
buttonLabel,
popoverAttribute,
prohibitedNameRepair,
relatedElement,
rubyAnnotation,
summary,
@@ -170,16 +170,23 @@ namespace declarativeNetRequest {
DOMString? regexSubstitution;
};
// TODO(crbug.com/40727004): Add documentation once feature is complete.
[nodoc] dictionary HeaderInfo {
dictionary HeaderInfo {
// The name of the header. This condition matches on the name
// only if both `values` and `excludedValues` are not specified.
DOMString header;
// If specified, this condition matches if the header's value
// contains at least one element in this list.
// If specified, this condition matches if the header's value matches at
// least one pattern in this list. This supports case-insensitive header
// value matching plus the following constructs:
//
// <b>'*'</b> : Matches any number of characters.
//
// <b>'?'</b> : Matches zero or one character(s).
//
// '*' and '?' can be escaped with a backslash, e.g. '\*' and '\?'
DOMString[]? values;
// If specified, this condition is not matched if the header
// exists but its value contains at least one element in this list.
// If specified, this condition is not matched if the header exists but its
// value contains at least one element in this list. This uses the same
// match pattern syntax as `values`.
DOMString[]? excludedValues;
};
@@ -355,15 +362,13 @@ namespace declarativeNetRequest {
// Rule matches if the request matches any response header condition in this
// list (if specified).
// TODO(crbug.com/40727004): Add documentation once feature is complete.
[nodoc] HeaderInfo[]? responseHeaders;
HeaderInfo[]? responseHeaders;
// Rule does not match if the request matches any response header
// condition in this list (if specified). If both `excludedResponseHeaders`
// and `responseHeaders` are specified, then the `excludedResponseHeaders`
// property takes precedence.
// TODO(crbug.com/40727004): Add documentation once feature is complete.
[nodoc] HeaderInfo[]? excludedResponseHeaders;
HeaderInfo[]? excludedResponseHeaders;
};
dictionary ModifyHeaderInfo {
@@ -636,8 +641,10 @@ namespace declarativeNetRequest {
// extension updates.</li>
// <li>Static rules specified as part of the extension package can not be
// removed using this function.</li>
// <li>$(ref:MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES) is the maximum number
// of combined dynamic and session rules an extension can add.</li>
// <li>$(ref:MAX_NUMBER_OF_DYNAMIC_RULES) is the maximum number
// of dynamic rules an extension can add. The number of
// <a href="#safe_rules">unsafe rules</a> must not exceed
// $(ref:MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES).</li>
// </ul>
// |callback|: Called once the update is complete or has failed. In case of
// an error, $(ref:runtime.lastError) will be set and no change will be made
@@ -667,8 +674,8 @@ namespace declarativeNetRequest {
// specified rules are added and removed, or an error is returned.</li>
// <li>These rules are not persisted across sessions and are backed in
// memory.</li>
// <li>$(ref:MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES) is the maximum number
// of combined dynamic and session rules an extension can add.</li>
// <li>$(ref:MAX_NUMBER_OF_SESSION_RULES) is the maximum number
// of session rules an extension can add.</li>
// </ul>
// |callback|: Called once the update is complete or has failed. In case of
// an error, $(ref:runtime.lastError) will be set and no change will be made
@@ -786,7 +793,7 @@ namespace declarativeNetRequest {
// The maximum number of combined dynamic and session scoped rules an
// extension can add.
[nodoc, value=5000] static long MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES();
[nodoc, value=5000, deprecated="There is no longer a combined limit. See $(ref:MAX_NUMBER_OF_DYNAMIC_RULES) and $(ref:MAX_NUMBER_OF_SESSION_RULES)."] static long MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES();
// The maximum number of dynamic rules that an extension can add.
[value=30000] static long MAX_NUMBER_OF_DYNAMIC_RULES();
@@ -24,6 +24,8 @@
// dynamic ID. This is an identifier that uniquely identifies the extension
// and is generated each session. The corresponding dynamic extension URL
// is available through $(ref:runtime.getURL).
// Dynamic resources can be loaded regardless of the value. However, if
// true, resources must be can only be loaded using the dynamic URL.
boolean? use_dynamic_url;
};
+21 -11
View File
@@ -290,6 +290,10 @@ void SetFlags(IsolateHolder::ScriptMode mode,
"--cppheap-optimize-sweep-for-mutator",
"--no-cppheap-optimize-sweep-for-mutator");
SetV8FlagsIfOverridden(features::kV8MinorMS, "--minor-ms", "--no-minor-ms");
if (base::FeatureList::IsEnabled(features::kV8ScavengerHigherCapacity)) {
SetV8FlagsFormatted("--scavenger-max-new-space-capacity-mb=%i",
features::kV8ScavengerMaxCapacity.Get());
}
SetV8FlagsIfOverridden(features::kV8Sparkplug, "--sparkplug",
"--no-sparkplug");
SetV8FlagsIfOverridden(features::kV8Turbofan, "--turbofan", "--no-turbofan");
@@ -404,6 +408,18 @@ void SetFlags(IsolateHolder::ScriptMode mode,
"--intel-jcc-erratum-mitigation",
"--no-intel-jcc-erratum-mitigation");
SetV8FlagsIfOverridden(features::kV8UpdateLimitAfterLoading,
"--update-allocation-limits-after-loading",
"--no-update-allocation-limits-after-loading");
SetV8FlagsIfOverridden(features::kV8UseLibmTrigFunctions,
"--use-libm-trig-functions",
"--no-use-libm-trig-functions");
SetV8FlagsIfOverridden(features::kV8UseOriginalMessageForStackTrace,
"--use-original-message-for-stack-trace",
"--no-use-original-message-for-stack-trace");
// JavaScript language features.
SetV8FlagsIfOverridden(features::kJavaScriptIteratorHelpers,
"--harmony-iterator-helpers",
@@ -411,9 +427,6 @@ void SetFlags(IsolateHolder::ScriptMode mode,
SetV8FlagsIfOverridden(features::kJavaScriptPromiseWithResolvers,
"--js-promise-withresolvers",
"--no-js-promise-withresolvers");
SetV8FlagsIfOverridden(features::kJavaScriptArrayFromAsync,
"--harmony-array-from-async",
"--no-harmony-array-from-async");
SetV8FlagsIfOverridden(features::kJavaScriptRegExpModifiers,
"--js-regexp-modifiers", "--no-js-regexp-modifiers");
SetV8FlagsIfOverridden(features::kJavaScriptImportAttributes,
@@ -424,19 +437,13 @@ void SetFlags(IsolateHolder::ScriptMode mode,
SetV8FlagsIfOverridden(features::kJavaScriptRegExpDuplicateNamedGroups,
"--js-regexp-duplicate-named-groups",
"--no-js-duplicate-named-groups");
SetV8FlagsIfOverridden(features::kJavaScriptPromiseTry, "--js-promise-try",
"--no-js-promise-try");
if (IsolateHolder::kStrictMode == mode) {
SetV8Flags("--use_strict");
}
SetV8FlagsIfOverridden(features::kV8UseLibmTrigFunctions,
"--use-libm-trig-functions",
"--no-use-libm-trig-functions");
SetV8FlagsIfOverridden(features::kV8UseOriginalMessageForStackTrace,
"--use-original-message-for-stack-trace",
"--no-use-original-message-for-stack-trace");
SetV8FlagsIfOverridden(features::kJavaScriptCompileHintsMagic,
"--compile-hints-magic", "--no-compile-hints-magic");
@@ -445,6 +452,9 @@ void SetFlags(IsolateHolder::ScriptMode mode,
SetV8FlagsIfOverridden(features::kWebAssemblyInlining,
"--experimental-wasm-inlining",
"--no-experimental-wasm-inlining");
SetV8FlagsIfOverridden(features::kWebAssemblyInliningCallIndirect,
"--wasm-inlining-call-indirect",
"--no-wasm-inlining-call-indirect");
SetV8FlagsIfOverridden(features::kWebAssemblyLiftoffCodeFlushing,
"--flush-liftoff-code", "--no-flush-liftoff-code");
SetV8FlagsIfOverridden(features::kWebAssemblyGenericWrapper,
@@ -27,6 +27,7 @@
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_functions.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/sequence_checker.h"
#include "base/strings/string_number_conversions.h"
@@ -73,7 +74,6 @@
#include "net/cookies/cookie_setting_override.h"
#include "net/dns/host_cache.h"
#include "net/dns/mapped_host_resolver.h"
#include "net/extras/shared_dictionary/shared_dictionary_isolation_key.h"
#include "net/extras/sqlite/cookie_crypto_delegate.h"
#include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
#include "net/first_party_sets/first_party_set_metadata.h"
@@ -89,6 +89,8 @@
#include "net/net_buildflags.h"
#include "net/proxy_resolution/configured_proxy_resolution_service.h"
#include "net/proxy_resolution/proxy_config.h"
#include "net/shared_dictionary/shared_dictionary_isolation_key.h"
#include "net/storage_access_api/status.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request.h"
@@ -96,7 +98,6 @@
#include "net/url_request/url_request_context_builder.h"
#include "services/network/brokered_client_socket_factory.h"
#include "services/network/cookie_manager.h"
#include "services/network/cors/cors_url_loader_factory.h"
#include "services/network/data_remover_util.h"
#include "services/network/disk_cache/mojo_backend_file_operations_factory.h"
#include "services/network/host_resolver.h"
@@ -109,11 +110,11 @@
#include "services/network/is_browser_initiated.h"
#include "services/network/net_log_exporter.h"
#include "services/network/network_service.h"
#include "services/network/network_service_memory_cache.h"
#include "services/network/network_service_network_delegate.h"
#include "services/network/network_service_proxy_delegate.h"
#include "services/network/oblivious_http_request_handler.h"
#include "services/network/prefetch_cache.h"
#include "services/network/prefetch_matching_url_loader_factory.h"
#include "services/network/prefetch_url_loader_client.h"
#include "services/network/proxy_config_service_mojo.h"
#include "services/network/proxy_lookup_request.h"
@@ -137,7 +138,6 @@
#include "services/network/session_cleanup_cookie_store.h"
#include "services/network/shared_dictionary/shared_dictionary_constants.h"
#include "services/network/shared_dictionary/shared_dictionary_manager.h"
#include "services/network/shared_dictionary/shared_dictionary_network_transaction_factory.h"
#include "services/network/shared_dictionary/shared_dictionary_storage.h"
#include "services/network/ssl_config_service_mojo.h"
#include "services/network/throttling/network_conditions.h"
@@ -195,7 +195,7 @@
#endif // BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(ENABLE_DEVICE_BOUND_SESSIONS)
#include "net/device_bound_sessions/device_bound_session_service.h"
#include "net/device_bound_sessions/session_service.h"
#endif // BUILDFLAG(ENABLE_DEVICE_BOUND_SESSIONS)
namespace network {
@@ -638,8 +638,12 @@ NetworkContext::NetworkContext(
cors_preflight_controller_(network_service),
http_auth_merged_preferences_(network_service),
ohttp_handler_(this),
prefetch_enabled_(
base::FeatureList::IsEnabled(features::kNetworkContextPrefetch)),
cors_non_wildcard_request_headers_support_(base::FeatureList::IsEnabled(
features::kCorsNonWildcardRequestHeadersSupport)) {
features::kCorsNonWildcardRequestHeadersSupport)),
prefetch_cache_(prefetch_enabled_ ? std::make_unique<PrefetchCache>()
: nullptr) {
#if BUILDFLAG(IS_WIN) && DCHECK_IS_ON()
if (params_->file_paths) {
DCHECK(params_->win_permissions_set)
@@ -737,9 +741,6 @@ NetworkContext::NetworkContext(
#endif
resource_scheduler_ = std::make_unique<ResourceScheduler>();
if (base::FeatureList::IsEnabled(features::kNetworkServiceMemoryCache))
memory_cache_ = std::make_unique<NetworkServiceMemoryCache>(this);
if (params_->http_auth_static_network_context_params) {
http_auth_merged_preferences_.SetAllowDefaultCredentials(
params_->http_auth_static_network_context_params
@@ -780,6 +781,10 @@ NetworkContext::NetworkContext(
base::MakeRefCounted<MojoBackendFileOperationsFactory>(
std::move(params_->http_cache_file_operations_factory));
}
if (prefetch_enabled_) {
InitializePrefetchURLLoaderFactory();
}
}
NetworkContext::NetworkContext(
@@ -808,7 +813,11 @@ NetworkContext::NetworkContext(
url_request_context)),
cors_preflight_controller_(network_service),
http_auth_merged_preferences_(network_service),
ohttp_handler_(this) {
ohttp_handler_(this),
prefetch_enabled_(
base::FeatureList::IsEnabled(features::kNetworkContextPrefetch)),
prefetch_cache_(prefetch_enabled_ ? std::make_unique<PrefetchCache>()
: nullptr) {
// May be nullptr in tests.
if (network_service_)
network_service_->RegisterNetworkContext(this);
@@ -820,6 +829,10 @@ NetworkContext::NetworkContext(
acam_preflight_spec_conformant_ = base::FeatureList::IsEnabled(
network::features::
kAccessControlAllowMethodsInCORSPreflightSpecConformant);
if (prefetch_enabled_) {
InitializePrefetchURLLoaderFactory();
}
}
NetworkContext::~NetworkContext() {
@@ -878,7 +891,7 @@ NetworkContext::~NetworkContext() {
// Clear `url_loader_factories_` before deleting the contents, as it can
// result in re-entrant calls to DestroyURLLoaderFactory().
std::set<std::unique_ptr<cors::CorsURLLoaderFactory>,
std::set<std::unique_ptr<PrefetchMatchingURLLoaderFactory>,
base::UniquePtrComparator>
url_loader_factories = std::move(url_loader_factories_);
}
@@ -914,9 +927,11 @@ void NetworkContext::CreateURLLoaderFactory(
mojo::PendingReceiver<mojom::URLLoaderFactory> receiver,
mojom::URLLoaderFactoryParamsPtr params,
scoped_refptr<ResourceSchedulerClient> resource_scheduler_client) {
url_loader_factories_.emplace(std::make_unique<cors::CorsURLLoaderFactory>(
this, std::move(params), std::move(resource_scheduler_client),
std::move(receiver), &cors_origin_access_list_));
url_loader_factories_.emplace(
std::make_unique<PrefetchMatchingURLLoaderFactory>(
this, std::move(params), std::move(resource_scheduler_client),
std::move(receiver), &cors_origin_access_list_,
prefetch_cache_.get()));
}
void NetworkContext::CreateURLLoaderFactoryForCertNetFetcher(
@@ -962,7 +977,7 @@ void NetworkContext::CreateURLLoaderFactory(
void NetworkContext::ResetURLLoaderFactories() {
// Move all factories to a temporary vector so ClearBindings() does not
// invalidate the iterator if the factory gets deleted.
std::vector<cors::CorsURLLoaderFactory*> factories;
std::vector<PrefetchMatchingURLLoaderFactory*> factories;
factories.reserve(url_loader_factories_.size());
for (const auto& factory : url_loader_factories_)
factories.push_back(factory.get());
@@ -1000,7 +1015,7 @@ void NetworkContext::OnRCMDisconnect(
const network::RestrictedCookieManager* rcm) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
auto it = restricted_cookie_managers_.find(rcm);
DCHECK(it != restricted_cookie_managers_.end());
CHECK(it != restricted_cookie_managers_.end(), base::NotFatalUntil::M130);
restricted_cookie_managers_.erase(it);
}
@@ -1112,7 +1127,7 @@ void NetworkContext::SetBlockTrustTokens(bool block) {
void NetworkContext::OnProxyLookupComplete(
ProxyLookupRequest* proxy_lookup_request) {
auto it = proxy_lookup_requests_.find(proxy_lookup_request);
DCHECK(it != proxy_lookup_requests_.end());
CHECK(it != proxy_lookup_requests_.end(), base::NotFatalUntil::M130);
proxy_lookup_requests_.erase(it);
}
@@ -1121,12 +1136,12 @@ void NetworkContext::DisableQuic() {
}
void NetworkContext::DestroyURLLoaderFactory(
cors::CorsURLLoaderFactory* url_loader_factory) {
PrefetchMatchingURLLoaderFactory* url_loader_factory) {
if (is_destructing_) {
return;
}
auto it = url_loader_factories_.find(url_loader_factory);
DCHECK(it != url_loader_factories_.end());
CHECK(it != url_loader_factories_.end(), base::NotFatalUntil::M130);
url_loader_factories_.erase(it);
}
@@ -1143,7 +1158,7 @@ void NetworkContext::LoaderCreated(uint32_t process_id) {
void NetworkContext::LoaderDestroyed(uint32_t process_id) {
auto it = loader_count_per_process_.find(process_id);
DCHECK(it != loader_count_per_process_.end());
CHECK(it != loader_count_per_process_.end(), base::NotFatalUntil::M130);
it->second -= 1;
if (it->second == 0)
loader_count_per_process_.erase(it);
@@ -1245,10 +1260,6 @@ void NetworkContext::ClearHttpCache(base::Time start_time,
url_request_context_, std::move(filter), start_time, end_time,
base::BindOnce(&NetworkContext::OnHttpCacheCleared,
base::Unretained(this), std::move(callback))));
NetworkServiceMemoryCache* memory_cache = GetMemoryCache();
if (memory_cache)
memory_cache->Clear();
}
void NetworkContext::ComputeHttpCacheSize(
@@ -1391,12 +1402,38 @@ void NetworkContext::QueueReport(
const GURL& url,
const std::optional<base::UnguessableToken>& reporting_source,
const net::NetworkAnonymizationKey& network_anonymization_key,
const std::optional<std::string>& user_agent,
base::Value::Dict body) {
QueueReportInternal(type, group, url, reporting_source,
network_anonymization_key, std::move(body),
net::ReportingTargetType::kDeveloper);
}
void NetworkContext::QueueEnterpriseReport(const std::string& type,
const std::string& group,
const GURL& url,
base::Value::Dict body) {
// Enterprise reports don't use a |reporting_source| or
// |network_anonymization_key|. Enterprise endpoints are profile-bound and not
// document-bound like web developer endpoints.
QueueReportInternal(type, group, url, /*reporting_source=*/std::nullopt,
net::NetworkAnonymizationKey(), std::move(body),
net::ReportingTargetType::kEnterprise);
}
void NetworkContext::QueueReportInternal(
const std::string& type,
const std::string& group,
const GURL& url,
const std::optional<base::UnguessableToken>& reporting_source,
const net::NetworkAnonymizationKey& network_anonymization_key,
base::Value::Dict body,
net::ReportingTargetType target_type) {
#if BUILDFLAG(ENABLE_REPORTING)
// If |reporting_source| is provided, it must not be empty.
DCHECK(!(reporting_source.has_value() && reporting_source->is_empty()));
if (require_network_anonymization_key_) {
// Enterprise reports have an empty |network_anonymization_key|.
if (target_type == net::ReportingTargetType::kDeveloper &&
require_network_anonymization_key_) {
DCHECK(!network_anonymization_key.IsEmpty());
}
@@ -1409,16 +1446,15 @@ void NetworkContext::QueueReport(
return;
}
std::string reported_user_agent = user_agent.value_or("");
if (reported_user_agent.empty() &&
request_context->http_user_agent_settings() != nullptr) {
std::string reported_user_agent = "";
if (request_context->http_user_agent_settings() != nullptr) {
reported_user_agent =
request_context->http_user_agent_settings()->GetUserAgent();
}
reporting_service->QueueReport(url, reporting_source,
network_anonymization_key, reported_user_agent,
group, type, std::move(body), 0 /* depth */);
reporting_service->QueueReport(
url, reporting_source, network_anonymization_key, reported_user_agent,
group, type, std::move(body), 0 /* depth */, target_type);
#endif // BUILDFLAG(ENABLE_REPORTING)
}
@@ -1597,8 +1633,7 @@ void NetworkContext::SetCTPolicy(mojom::CTPolicyPtr ct_policy) {
return;
require_ct_delegate_->UpdateCTPolicies(ct_policy->excluded_hosts,
ct_policy->excluded_spkis,
ct_policy->excluded_legacy_spkis);
ct_policy->excluded_spkis);
}
int NetworkContext::CheckCTRequirementsForSignedExchange(
@@ -1782,7 +1817,7 @@ void NetworkContext::CreateWebSocket(
const GURL& url,
const std::vector<std::string>& requested_protocols,
const net::SiteForCookies& site_for_cookies,
bool has_storage_access,
net::StorageAccessApiStatus storage_access_api_status,
const net::IsolationInfo& isolation_info,
std::vector<mojom::HttpHeaderPtr> additional_headers,
int32_t process_id,
@@ -1802,7 +1837,7 @@ void NetworkContext::CreateWebSocket(
DCHECK_GE(process_id, 0);
websocket_factory_->CreateWebSocket(
url, requested_protocols, site_for_cookies, has_storage_access,
url, requested_protocols, site_for_cookies, storage_access_api_status,
isolation_info, std::move(additional_headers), process_id, origin,
options,
static_cast<net::NetworkTrafficAnnotationTag>(traffic_annotation),
@@ -1917,14 +1952,12 @@ void NetworkContext::VerifyCertForSignedExchange(
void NetworkContext::NotifyExternalCacheHit(const GURL& url,
const std::string& http_method,
const net::NetworkIsolationKey& key,
bool is_subframe_document_resource,
bool include_credentials) {
net::HttpCache* cache =
url_request_context_->http_transaction_factory()->GetCache();
if (!cache)
return;
cache->OnExternalCacheHit(url, http_method, key,
is_subframe_document_resource, include_credentials);
cache->OnExternalCacheHit(url, http_method, key, include_credentials);
}
void NetworkContext::SetCorsOriginAccessListsForOrigin(
@@ -2312,10 +2345,6 @@ const net::HttpAuthPreferences* NetworkContext::GetHttpAuthPreferences() const {
return &http_auth_merged_preferences_;
}
NetworkServiceMemoryCache* NetworkContext::GetMemoryCache() {
return memory_cache_.get();
}
size_t NetworkContext::NumOpenWebTransports() const {
return base::ranges::count(web_transports_, false, &WebTransport::torn_down);
}
@@ -2722,25 +2751,17 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext(
builder.set_quic_context(std::move(quic_context));
if (params_->shared_dictionary_enabled) {
CHECK(GetSharedDictionaryManager());
builder.SetCreateHttpTransactionFactoryCallback(base::BindOnce(
[](base::WeakPtr<NetworkContext> context,
net::HttpNetworkSession* session)
-> std::unique_ptr<net::HttpTransactionFactory> {
CHECK(context);
return std::make_unique<SharedDictionaryNetworkTransactionFactory>(
*context->GetSharedDictionaryManager(),
std::make_unique<ThrottlingNetworkTransactionFactory>(session));
},
weak_factory_.GetWeakPtr()));
} else {
builder.SetCreateHttpTransactionFactoryCallback(
base::BindOnce([](net::HttpNetworkSession* session)
-> std::unique_ptr<net::HttpTransactionFactory> {
return std::make_unique<ThrottlingNetworkTransactionFactory>(session);
}));
builder.set_enable_shared_dictionary(true);
builder.set_enable_shared_zstd(
base::FeatureList::IsEnabled(network::features::kSharedZstd));
}
builder.SetCreateHttpTransactionFactoryCallback(
base::BindOnce([](net::HttpNetworkSession* session)
-> std::unique_ptr<net::HttpTransactionFactory> {
return std::make_unique<ThrottlingNetworkTransactionFactory>(session);
}));
builder.set_host_mapping_rules(
command_line->GetSwitchValueASCII(switches::kHostResolverRules));
@@ -2888,7 +2909,7 @@ void NetworkContext::OnHttpCacheCleared(ClearHttpCacheCallback callback,
void NetworkContext::OnHostResolverShutdown(HostResolver* resolver) {
auto found_resolver = host_resolvers_.find(resolver);
DCHECK(found_resolver != host_resolvers_.end());
CHECK(found_resolver != host_resolvers_.end(), base::NotFatalUntil::M130);
host_resolvers_.erase(found_resolver);
}
@@ -2925,7 +2946,7 @@ GURL NetworkContext::GetHSTSRedirect(const GURL& original_url) {
#if BUILDFLAG(IS_P2P_ENABLED)
void NetworkContext::DestroySocketManager(P2PSocketManager* socket_manager) {
auto iter = socket_managers_.find(socket_manager);
DCHECK(iter != socket_managers_.end());
CHECK(iter != socket_managers_.end(), base::NotFatalUntil::M130);
socket_managers_.erase(iter);
}
#endif // BUILDFLAG(IS_P2P_ENABLED)
@@ -2944,7 +2965,7 @@ void NetworkContext::OnVerifyCertForSignedExchangeComplete(
uint64_t cert_verify_id,
int result) {
auto iter = cert_verifier_requests_.find(cert_verify_id);
DCHECK(iter != cert_verifier_requests_.end());
CHECK(iter != cert_verifier_requests_.end(), base::NotFatalUntil::M130);
auto pending_cert_verify = std::move(iter->second);
cert_verifier_requests_.erase(iter);
@@ -3104,6 +3125,23 @@ void NetworkContext::GetSharedDictionaryOriginsBetween(
std::move(callback));
}
void NetworkContext::PreloadSharedDictionaryInfoForDocument(
const std::vector<GURL>& urls,
mojo::PendingReceiver<mojom::PreloadedSharedDictionaryInfoHandle>
preload_handle) {
if (shared_dictionary_manager_) {
shared_dictionary_manager_->PreloadSharedDictionaryInfoForDocument(
urls, std::move(preload_handle));
}
}
void NetworkContext::HasPreloadedSharedDictionaryInfoForTesting(
HasPreloadedSharedDictionaryInfoForTestingCallback callback) {
std::move(callback).Run(
shared_dictionary_manager_ &&
shared_dictionary_manager_->HasPreloadedSharedDictionaryInfo());
}
void NetworkContext::ResourceSchedulerClientVisibilityChanged(
const base::UnguessableToken& client_token,
bool visible) {
@@ -3174,20 +3212,10 @@ void NetworkContext::Prefetch(
uint32_t options,
const ResourceRequest& request,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
if (!base::FeatureList::IsEnabled(features::kNetworkContextPrefetch)) {
if (!prefetch_enabled_) {
return;
}
if (!prefetch_cache_) {
// Lazily initialized to avoid slowing down startup.
prefetch_cache_ = std::make_unique<PrefetchCache>();
}
if (!prefetch_url_loader_factory_remote_.is_bound() ||
!prefetch_url_loader_factory_remote_.is_connected()) {
InitializePrefetchURLLoaderFactory();
}
PrefetchURLLoaderClient* client = prefetch_cache_->Emplace(request);
if (!client) {
// This is normal if we already have a prefetch in progress for the {NIK,
@@ -3200,6 +3228,11 @@ void NetworkContext::Prefetch(
client->BindNewPipeAndPassRemote(), traffic_annotation);
}
void NetworkContext::GetBoundNetworkForTesting(
GetBoundNetworkForTestingCallback callback) {
std::move(callback).Run(url_request_context()->bound_network());
}
bool NetworkContext::IsNetworkForNonceAndUrlAllowed(
const base::UnguessableToken& nonce,
const GURL& url) const {
File diff suppressed because it is too large Load Diff
@@ -1141,7 +1141,7 @@ enum WebFeature {
kRTCIceServerURLs = 1657,
kOffscreenCanvasTransferToImageBitmap2D = 1658,
kOffscreenCanvasTransferToImageBitmapWebGL = 1659,
kOffscreenCanvasCommit2D = 1660,
kOBSOLETE_OffscreenCanvasCommit2D = 1660,
kOffscreenCanvasCommitWebGL = 1661,
kRTCConfigurationIceTransportPolicy = 1662,
kRTCConfigurationIceTransports = 1664,
@@ -2408,13 +2408,13 @@ enum WebFeature {
kRegisterProtocolHandlerCrossOriginSubframe = 3093,
kWebNfcNdefReaderScan = 3094,
kWebNfcNdefWriterWrite = 3095,
kHTMLPortalElement = 3096,
kV8HTMLPortalElement_Activate_Method = 3097,
kV8HTMLPortalElement_PostMessage_Method = 3098,
kV8Window_PortalHost_AttributeGetter = 3099,
kV8PortalHost_PostMessage_Method = 3100,
kV8PortalActivateEvent_Data_AttributeGetter = 3101,
kV8PortalActivateEvent_AdoptPredecessor_Method = 3102,
kOBSOLETE_HTMLPortalElement = 3096,
kOBSOLETE_V8HTMLPortalElement_Activate_Method = 3097,
kOBSOLETE_V8HTMLPortalElement_PostMessage_Method = 3098,
kOBSOLETE_V8Window_PortalHost_AttributeGetter = 3099,
kOBSOLETE_V8PortalHost_PostMessage_Method = 3100,
kOBSOLETE_V8PortalActivateEvent_Data_AttributeGetter = 3101,
kOBSOLETE_V8PortalActivateEvent_AdoptPredecessor_Method = 3102,
kLinkRelPrefetchForSignedExchanges = 3103,
kMessageEventSharedArrayBufferSameOrigin = 3104,
kMessageEventSharedArrayBufferSameAgentCluster = 3105,
@@ -3366,7 +3366,7 @@ enum WebFeature {
kV8Navigator_CreateAdRequest_Method = 4053,
kV8Navigator_FinalizeAd_Method = 4054,
kRegionCapture = 4055,
kAppHistory = 4056,
kNavigationAPI = 4056,
kFlexboxAlignSingleLineDifference = 4057,
kExternalProtocolBlockedBySandbox = 4058,
kOBSOLETE_WebAssemblyDynamicTiering = 4059,
@@ -3721,7 +3721,7 @@ enum WebFeature {
kViewTransition = 4383,
kElementTogglePopover = 4384,
kOBSOLETE_LayoutMediaInlineChildren = 4385,
kReduceAcceptLanguage = 4386,
kOBSOLETE_ReduceAcceptLanguage = 4386,
// The items above roughly this point are available in the M109 branch.
kOBSOLETE_UuidInPackageUrlNavigation = 4387,
@@ -3795,7 +3795,7 @@ enum WebFeature {
kServiceWorkerFetchHandlerModifiedAfterInitialization = 4453,
// The items above roughly this point are available in the M111 branch.
kOptionLabelInQuirksMode = 4454,
kOBSOLETE_OptionLabelInQuirksMode = 4454,
kParseFromStringIncludeShadows = 4455,
kWebAppManifestScopeExtensions = 4456,
kOBSOLETE_ServiceWorkerBypassFetchHandlerForMainResourceByOriginTrial = 4457,
@@ -3867,8 +3867,8 @@ enum WebFeature {
kHtmlClipboardApiUnsanitizedRead = 4522,
kHtmlClipboardApiUnsanitizedWrite = 4523,
kAsyncClipboardAPIUnsanitizedRead = 4524,
kWindowOpenFullscreenRequested = 4525,
kFullscreenAllowedByWindowOpen = 4526,
kOBSOLETE_WindowOpenFullscreenRequested = 4525,
kOBSOLETE_FullscreenAllowedByWindowOpen = 4526,
// The items above roughly this point are available in the M113 branch.
kAttributeValueContainsLtOrGt = 4527,
@@ -4030,7 +4030,6 @@ enum WebFeature {
kTextWrapPretty = 4674,
// The items above roughly this point are available in the M119 branch.
kOBSOLETE_V8PointerEvent_DeviceId_AttributeGetter = 4675,
kSourceMappingUrlMagicCommentAtSign = 4676,
kHTMLDetailsElementNameAttribute = 4677,
kHTMLDetailsElementNameAttributeClosesSelf = 4678,
@@ -4306,7 +4305,7 @@ enum WebFeature {
kStaticPropertyInAnimation = 4940,
kSimplifyLoadingTransparentPlaceholderImage = 4941,
kIdentityDigitalCredentialsSuccess = 4942,
kV8DeviceProperties_UniqueId_AttributeGetter = 4943,
kOBSOLETE_V8DeviceProperties_UniqueId_AttributeGetter = 4943,
// The items above roughly this point are available in the M125 branch.
kSharedStorageAPI_SelectURLOverallPageloadBudgetInsufficient = 4944,
@@ -4367,6 +4366,45 @@ enum WebFeature {
kV8InvalidatedNoUndetectableObjectsProtector = 4997,
kV8DocumentAllLegacyCall = 4998,
kV8DocumentAllLegacyConstruct = 4999,
kInsideListMarkerPositionQuirk = 5000,
kZstdContentEncodingForNavigation = 5001,
kZstdContentEncodingForMainFrameNavigation = 5002,
kZstdContentEncodingForSubFrameNavigation = 5003,
kZstdContentEncodingForSubresource = 5004,
kEventTimingOrphanPointerupWithClick = 5005,
kDisableReduceAcceptLanguage = 5006,
kSharedStorageAPI_CreateWorklet_CrossOriginScriptDefaultDataOrigin = 5007,
kDeprecatedAIModel = 5008,
kDeprecatedAICanCreateGenericSession = 5009,
kDeprecatedAICreateGenericSession = 5010,
kDeprecatedAIDefaultGenericSessionOptions = 5011,
kDeprecatedAITextSessionExecute = 5012,
kDeprecatedAITextSessionExecuteStreaming = 5013,
kARIAColIndexTextAttribute = 5014,
kARIARowIndexTextAttribute = 5015,
kV8PointerEvent_PersistentDeviceId_AttributeGetter = 5016,
kDelegatedInkExpectedImprovement = 5017,
kCSSSelectorNthChildOfSelector = 5018,
kDisableStandardizedBrowserZoom = 5019,
kV8FileSystemObserver_Constructor = 5020,
kV8FileSystemObserver_Observe_Method = 5021,
kV8FileSystemObserver_Disconnect_Method = 5022,
kV8ML_CreateContext_Method = 5023,
kV8MLContext_Compute_Method = 5024,
kV8MLContext_Dispatch_Method = 5025,
kCSSMixins = 5026,
kDurationFormat = 5027,
kSharedStorageAPI_AddModule_CrossOriginScript = 5028,
kCrossOriginOpenerPolicyNoopenerAllowPopups = 5029,
kCrossOriginOpenerPolicyNoopenerAllowPopupsReportOnly = 5030,
kV8ConsoleContext = 5031,
kButtonTypeAttrInvalid = 5032,
kButtonTypeAttrEmptyString = 5033,
kProtectedAudienceDirectFromSellerSignals = 5034,
kWebGPUSubgroupsFeatures = 5035,
kAudioContextOnError = 5036,
kNoVarySearchPrerender = 5037,
kFlexNewColumnWrapIntrinsicSize = 5043,
// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. Also don't add extra
@@ -358,6 +358,10 @@ struct WebPreferences {
// Don't accelerate small canvases to avoid crashes TODO(crbug.com/1004304)
bool disable_accelerated_small_canvases;
[EnableIf=is_android]
// Long press on links selects text instead of triggering context menu.
bool long_press_link_select_text;
// Disable the Web Authentication (WebAuthn) API.
// TODO(crbug.com/1284805): Remove once WebView supports WebAuthn.
[EnableIf=is_android]
@@ -418,6 +422,11 @@ struct WebPreferences {
// when to apply system color overrides to author specified styles.
bool in_forced_colors;
// Indicates if Forced Colors mode should be disabled for this page.
// This allows users opt out of forced colors on specific sites.
// Forced colors are disabled for sites in the `kPageColorsBlockList` pref.
bool is_forced_colors_disabled;
// The preferred color scheme set by the user's browser settings. The variable
// follows the browser's color mode setting unless a browser theme (custom or
// not) is defined, in which case the color scheme is set to the default
@@ -17,6 +17,7 @@
attribute DOMString? checked;
attribute long? colCount;
attribute unsigned long? colIndex;
[RuntimeEnabled=AriaRowColIndexText] attribute DOMString? colIndexText;
attribute unsigned long? colSpan;
attribute AccessibleNodeList? controls;
attribute DOMString? current;
@@ -49,6 +50,7 @@
attribute DOMString? roleDescription;
attribute long? rowCount;
attribute unsigned long? rowIndex;
[RuntimeEnabled=AriaRowColIndexText] attribute DOMString? rowIndexText;
attribute unsigned long? rowSpan;
attribute boolean? selected;
attribute long? setSize;
@@ -0,0 +1,13 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://drafts.csswg.org/cssom/#the-cssmarginrule-interface
[
Exposed=Window,
RuntimeEnabled=PageMarginBoxes
] interface CSSMarginRule : CSSRule {
readonly attribute DOMString name;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};
@@ -29,8 +29,7 @@
const unsigned short MEDIA_RULE = 4;
const unsigned short FONT_FACE_RULE = 5;
const unsigned short PAGE_RULE = 6;
// TODO(foolip): Implement CSSMarginRule.
// const unsigned short MARGIN_RULE = 9;
[RuntimeEnabled=PageMarginBoxes] const unsigned short MARGIN_RULE = 9;
const unsigned short NAMESPACE_RULE = 10;
readonly attribute unsigned short type;
attribute DOMString cssText;
@@ -14,15 +14,15 @@
[NewObject] CSSUnitValue em(double value);
[NewObject] CSSUnitValue rem(double value);
[NewObject] CSSUnitValue ex(double value);
[NewObject, RuntimeEnabled=CSSNumericFactoryCompleteness] CSSUnitValue rex(double value);
[NewObject] CSSUnitValue rex(double value);
[NewObject] CSSUnitValue ch(double value);
[NewObject, RuntimeEnabled=CSSNumericFactoryCompleteness] CSSUnitValue rch(double value);
[NewObject, RuntimeEnabled=CSSNumericFactoryCompleteness] CSSUnitValue ic(double value);
[NewObject, RuntimeEnabled=CSSNumericFactoryCompleteness] CSSUnitValue ric(double value);
[NewObject, RuntimeEnabled=CSSNumericFactoryCompleteness] CSSUnitValue lh(double value);
[NewObject, RuntimeEnabled=CSSNumericFactoryCompleteness] CSSUnitValue rlh(double value);
[NewObject, RuntimeEnabled=CSSCapFontUnits] CSSUnitValue cap(double value);
[NewObject, RuntimeEnabled=CSSCapFontUnits] CSSUnitValue rcap(double value);
[NewObject] CSSUnitValue rch(double value);
[NewObject] CSSUnitValue ic(double value);
[NewObject] CSSUnitValue ric(double value);
[NewObject] CSSUnitValue lh(double value);
[NewObject] CSSUnitValue rlh(double value);
[NewObject] CSSUnitValue cap(double value);
[NewObject] CSSUnitValue rcap(double value);
[NewObject] CSSUnitValue vw(double value);
[NewObject] CSSUnitValue vh(double value);
[NewObject] CSSUnitValue vi(double value);
@@ -84,7 +84,7 @@
[NewObject] CSSUnitValue dpi(double value);
[NewObject] CSSUnitValue dpcm(double value);
[NewObject] CSSUnitValue dppx(double value);
[NewObject, RuntimeEnabled=CSSNumericFactoryCompleteness] CSSUnitValue x(double value);
[NewObject] CSSUnitValue x(double value);
// <flex>
[NewObject] CSSUnitValue fr(double value);
@@ -14,6 +14,7 @@ interface mixin AriaAttributes {
[CEReactions, Reflect=aria_checked] attribute DOMString? ariaChecked;
[CEReactions, Reflect=aria_colcount] attribute DOMString? ariaColCount;
[CEReactions, Reflect=aria_colindex] attribute DOMString? ariaColIndex;
[RuntimeEnabled=AriaRowColIndexText, CEReactions, Reflect=aria_colindextext] attribute DOMString? ariaColIndexText;
[CEReactions, Reflect=aria_colspan] attribute DOMString? ariaColSpan;
[CEReactions, Reflect=aria_current] attribute DOMString? ariaCurrent;
[CEReactions, Reflect=aria_description] attribute DOMString? ariaDescription;
@@ -39,6 +40,7 @@ interface mixin AriaAttributes {
[CEReactions, Reflect=aria_roledescription] attribute DOMString? ariaRoleDescription;
[CEReactions, Reflect=aria_rowcount] attribute DOMString? ariaRowCount;
[CEReactions, Reflect=aria_rowindex] attribute DOMString? ariaRowIndex;
[RuntimeEnabled=AriaRowColIndexText, CEReactions, Reflect=aria_rowindextext] attribute DOMString? ariaRowIndexText;
[CEReactions, Reflect=aria_rowspan] attribute DOMString? ariaRowSpan;
[CEReactions, Reflect=aria_selected] attribute DOMString? ariaSelected;
[CEReactions, Reflect=aria_setsize] attribute DOMString? ariaSetSize;
@@ -141,6 +141,7 @@ dictionary CheckVisibilityOptions {
readonly attribute long clientLeft;
readonly attribute long clientWidth;
readonly attribute long clientHeight;
[RuntimeEnabled=StandardizedBrowserZoom] readonly attribute double currentCSSZoom;
// Used by both Anchor Positioning and Popover
[CEReactions,RuntimeEnabled=HTMLAnchorAttribute] attribute Element? anchorElement;
@@ -4,6 +4,6 @@
[RuntimeEnabled=HTMLInvokeTargetAttribute]
interface mixin InvokerElement {
[CEReactions,Reflect=invoketarget] attribute Element? invokeTargetElement;
[CEReactions,Reflect=invokeaction] attribute DOMString invokeAction;
[CEReactions,Reflect=commandfor] attribute Element? commandForElement;
[CEReactions,Reflect=command] attribute DOMString command;
};
@@ -11,8 +11,13 @@ interface mixin PartRootMixin {
// Retrieve the parts list for this PartRoot, always in tree order breaking
// ties for a Node using the order Parts were constructed.
sequence<Part> getParts();
// Retrieve getParts()[index].NodeToSortBy. This is experimental.
[PerWorldBindings] Node getPartNode(unsigned long index);
// Retrieve the Nodes corresponding to the NodeParts returned by getParts(),
// without building the Part objects.
[RuntimeEnabled=DOMPartsAPIMinimal] sequence<Node> getNodePartNodes();
// Retrieve the pairs of previous/next Nodes corresponding to the
// ChildNodeParts returned by getParts(), without building the Part objects.
// Nodes are paired, so for 3 ChildNodeParts, 6 Nodes will be returned.
[RuntimeEnabled=DOMPartsAPIMinimal] sequence<Node> getChildNodePartNodes();
// This clones the PartRoot, and also clones the Node tree itself, starting
// at the RootContainer. In the case of a DocumentPartRoot, the entire
// document tree is cloned. In the case of a ChildPartRoot, only the children
@@ -58,6 +58,8 @@
[MeasureAs=SelectionContainsNode] boolean containsNode(Node node, optional boolean allowPartialContainment = false);
[MeasureAs=SelectionDOMString] stringifier;
[RuntimeEnabled=SelectionAcrossShadowDOM] readonly attribute DOMString direction;
// Non-standard APIs
// https://github.com/w3c/selection-api/issues/34
@@ -5,13 +5,13 @@
[
RuntimeEnabled=HTMLInvokeTargetAttribute,
Exposed=Window
] interface InvokeEvent : Event {
constructor(DOMString type, optional InvokeEventInit eventInitDict = {});
] interface CommandEvent : Event {
constructor(DOMString type, optional CommandEventInit eventInitDict = {});
readonly attribute Element? invoker;
readonly attribute DOMString action;
readonly attribute DOMString command;
};
dictionary InvokeEventInit : EventInit {
dictionary CommandEventInit : EventInit {
Element? invoker = null;
DOMString action = "";
DOMString command = "";
};
@@ -77,6 +77,7 @@
"click",
"close",
"closing",
"command",
"complete",
"compositionend",
"compositionstart",
@@ -168,7 +169,6 @@
"inputreport",
"inputsourceschange",
"interest",
"invoke",
"install",
"interfacerequest",
"invalid",
@@ -244,7 +244,6 @@
"popstate",
"popoverhide",
"popovershow",
"portalactivate",
"prerenderingchange",
"prioritychange",
"progress",
@@ -20,7 +20,7 @@
[MeasureAs=PointerEventAttributeCount] readonly attribute long twist;
[MeasureAs=PointerEventAttributeCount] readonly attribute DOMString pointerType;
[MeasureAs=PointerEventAttributeCount] readonly attribute boolean isPrimary;
[MeasureAs=PointerEventAttributeCount, RuntimeEnabled=PointerEventDeviceId] readonly attribute DeviceProperties? deviceProperties;
[Measure, RuntimeEnabled=PointerEventDeviceId] readonly attribute long persistentDeviceId;
// https://w3c.github.io/pointerevents/extension.html#extensions-to-the-pointerevent-interface
[Measure] sequence<PointerEvent> getCoalescedEvents();
@@ -17,7 +17,7 @@ dictionary PointerEventInit : MouseEventInit {
long twist = 0;
DOMString pointerType = "";
boolean isPrimary = false;
DeviceProperties? deviceProperties = null;
long persistentDeviceId = 0;
// https://w3c.github.io/pointerevents/extension.html#extensions-to-the-pointerevent-interface
sequence<PointerEvent> coalescedEvents = [];
@@ -462,6 +462,21 @@ SkFontHinting RendererPreferencesToSkiaHinting(
}
#endif // !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_WIN)
void ForEachFrameWidgetControlledByView(
WebViewImpl& web_view,
base::FunctionRef<void(WebFrameWidgetImpl*)> callback) {
for (WebFrame* frame = web_view.MainFrame(); frame;
frame = frame->TraverseNext()) {
if (auto* frame_impl = DynamicTo<WebLocalFrameImpl>(frame)) {
if (frame_impl->GetFrame()->IsLocalRoot()) {
if (auto* widget = frame_impl->FrameWidgetImpl()) {
callback(widget);
}
}
}
}
}
} // namespace
// WebView ----------------------------------------------------------------
@@ -470,7 +485,6 @@ WebView* WebView::Create(
WebViewClient* client,
bool is_hidden,
blink::mojom::PrerenderParamPtr prerender_param,
bool is_inside_portal,
std::optional<blink::FencedFrame::DeprecatedFencedFrameMode>
fenced_frame_mode,
bool compositing_enabled,
@@ -487,18 +501,17 @@ WebView* WebView::Create(
client,
is_hidden ? mojom::blink::PageVisibilityState::kHidden
: mojom::blink::PageVisibilityState::kVisible,
std::move(prerender_param), is_inside_portal, fenced_frame_mode,
compositing_enabled, widgets_never_composited, To<WebViewImpl>(opener),
std::move(page_handle), agent_group_scheduler,
session_storage_namespace_id, std::move(page_base_background_color),
browsing_context_group_info, color_provider_colors);
std::move(prerender_param), fenced_frame_mode, compositing_enabled,
widgets_never_composited, To<WebViewImpl>(opener), std::move(page_handle),
agent_group_scheduler, session_storage_namespace_id,
std::move(page_base_background_color), browsing_context_group_info,
color_provider_colors);
}
WebViewImpl* WebViewImpl::Create(
WebViewClient* client,
mojom::blink::PageVisibilityState visibility,
blink::mojom::PrerenderParamPtr prerender_param,
bool is_inside_portal,
std::optional<blink::FencedFrame::DeprecatedFencedFrameMode>
fenced_frame_mode,
bool compositing_enabled,
@@ -511,8 +524,8 @@ WebViewImpl* WebViewImpl::Create(
const BrowsingContextGroupInfo& browsing_context_group_info,
const ColorProviderColorMaps* color_provider_colors) {
return new WebViewImpl(
client, visibility, std::move(prerender_param), is_inside_portal,
fenced_frame_mode, compositing_enabled, widgets_never_composited, opener,
client, visibility, std::move(prerender_param), fenced_frame_mode,
compositing_enabled, widgets_never_composited, opener,
std::move(page_handle), agent_group_scheduler,
session_storage_namespace_id, std::move(page_base_background_color),
browsing_context_group_info, color_provider_colors);
@@ -569,7 +582,6 @@ WebViewImpl::WebViewImpl(
WebViewClient* client,
mojom::blink::PageVisibilityState visibility,
blink::mojom::PrerenderParamPtr prerender_param,
bool is_inside_portal,
std::optional<blink::FencedFrame::DeprecatedFencedFrameMode>
fenced_frame_mode,
bool does_composite,
@@ -584,8 +596,10 @@ WebViewImpl::WebViewImpl(
: widgets_never_composited_(widgets_never_composited),
web_view_client_(client),
chrome_client_(MakeGarbageCollected<ChromeClientImpl>(this)),
minimum_zoom_level_(PageZoomFactorToZoomLevel(kMinimumPageZoomFactor)),
maximum_zoom_level_(PageZoomFactorToZoomLevel(kMaximumPageZoomFactor)),
minimum_zoom_level_(
blink::ZoomFactorToZoomLevel(kMinimumBrowserZoomFactor)),
maximum_zoom_level_(
blink::ZoomFactorToZoomLevel(kMaximumBrowserZoomFactor)),
does_composite_(does_composite),
fullscreen_controller_(std::make_unique<FullscreenController>(this)),
page_base_background_color_(
@@ -618,10 +632,10 @@ WebViewImpl::WebViewImpl(
page_->SetIsPrerendering(true);
page_->SetPrerenderMetricSuffix(
String(prerender_param->page_metric_suffix));
page_->SetShouldWarmUpCompositorOnPrerender(
prerender_param->should_warm_up_compositor);
}
// TODO(crbug.com/40287334): Remove the is_inside_portal parameter.
if (fenced_frame_mode && features::IsFencedFramesEnabled()) {
page_->SetIsMainFrameFencedFrameRoot();
page_->SetDeprecatedFencedFrameMode(*fenced_frame_mode);
@@ -1281,6 +1295,11 @@ void WebViewImpl::DidUpdateBrowserControls() {
visual_viewport.SetBrowserControlsAdjustment(
GetBrowserControls().UnreportedSizeAdjustment());
}
if (RuntimeEnabledFeatures::DynamicSafeAreaInsetsEnabled() &&
RuntimeEnabledFeatures::DynamicSafeAreaInsetsOnScrollEnabled()) {
GetPage()->UpdateSafeAreaInsetWithBrowserControls(GetBrowserControls());
}
}
BrowserControls& WebViewImpl::GetBrowserControls() {
@@ -1299,6 +1318,11 @@ void WebViewImpl::ResizeViewWhileAnchored(
if (old_viewport_shrink != GetBrowserControls().ShrinkViewport())
MainFrameImpl()->GetFrameView()->DynamicViewportUnitsChanged();
if (RuntimeEnabledFeatures::DynamicSafeAreaInsetsEnabled()) {
GetPage()->UpdateSafeAreaInsetWithBrowserControls(GetBrowserControls(),
/* force_update= */ true);
}
{
// Avoids unnecessary invalidations while various bits of state in
// TextAutosizer are updated.
@@ -1749,6 +1773,8 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
prefs.scroll_top_left_interop_enabled);
RuntimeEnabledFeatures::SetAcceleratedSmallCanvasesEnabled(
!prefs.disable_accelerated_small_canvases);
RuntimeEnabledFeatures::SetLongPressLinkSelectTextEnabled(
prefs.long_press_link_select_text);
#endif // BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA)
@@ -1795,6 +1821,7 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
settings->SetLazyLoadEnabled(prefs.lazy_load_enabled);
settings->SetInForcedColors(prefs.in_forced_colors);
settings->SetIsForcedColorsDisabled(prefs.is_forced_colors_disabled);
settings->SetPreferredRootScrollbarColorScheme(
prefs.preferred_root_scrollbar_color_scheme);
settings->SetPreferredColorScheme(prefs.preferred_color_scheme);
@@ -1889,14 +1916,17 @@ void WebViewImpl::SetPageFocus(bool enable) {
if (enable) {
LocalFrame* focused_frame = page_->GetFocusController().FocusedFrame();
if (focused_frame) {
// TODO(editing-dev): The use of UpdateStyleAndLayout needs to be audited.
// See http://crbug.com/590369 for more details.
focused_frame->GetDocument()->UpdateStyleAndLayout(
DocumentUpdateReason::kFocus);
Element* element = focused_frame->GetDocument()->FocusedElement();
if (element && focused_frame->Selection()
.ComputeVisibleSelectionInDOMTreeDeprecated()
.ComputeVisibleSelectionInDOMTree()
.IsNone()) {
// If the selection was cleared while the WebView was not
// focused, then the focus element shows with a focus ring but
// no caret and does respond to keyboard inputs.
focused_frame->GetDocument()->UpdateStyleAndLayoutTree();
if (element->IsTextControl()) {
element->UpdateSelectionOnFocus(SelectionBehaviorOnFocus::kRestore);
} else if (IsEditable(*element)) {
@@ -2187,7 +2217,7 @@ void WebViewImpl::ComputeScaleAndScrollForEditableElementRects(
2 * caret_bounds_in_content.height()
? minReadableCaretHeightForTextArea
: minReadableCaretHeight) *
MainFrameImpl()->GetFrame()->PageZoomFactor();
MainFrameImpl()->GetFrame()->LayoutZoomFactor();
new_scale = ClampPageScaleFactorToLimits(
MaximumLegiblePageScale() * min_readable_caret_height_for_node /
caret_bounds_in_content.height());
@@ -2274,31 +2304,17 @@ void WebViewImpl::AdvanceFocus(bool reverse) {
: mojom::blink::FocusType::kForward);
}
double WebViewImpl::ClampZoomLevel(double zoom_level) {
if (zoom_level < minimum_zoom_level_) {
return minimum_zoom_level_;
}
if (zoom_level > maximum_zoom_level_) {
return maximum_zoom_level_;
}
return zoom_level;
double WebViewImpl::ClampZoomLevel(double zoom_level) const {
return std::max(minimum_zoom_level_,
std::min(maximum_zoom_level_, zoom_level));
}
double WebViewImpl::SetMainFrameZoomLevel(double zoom_level) {
if (zoom_factor_for_device_scale_factor_) {
if (compositor_device_scale_factor_override_) {
page_->SetInspectorDeviceScaleFactorOverride(
zoom_factor_for_device_scale_factor_ /
compositor_device_scale_factor_override_);
} else {
page_->SetInspectorDeviceScaleFactorOverride(1.0f);
}
double WebViewImpl::ZoomLevelToZoomFactor(double zoom_level,
bool for_main_frame) const {
double zoom_factor = blink::ZoomLevelToZoomFactor(zoom_level);
if (for_main_frame && zoom_factor_override_) {
zoom_factor = zoom_factor_override_;
}
float zoom_factor =
zoom_factor_override_
? zoom_factor_override_
: static_cast<float>(PageZoomLevelToZoomFactor(zoom_level));
if (zoom_factor_for_device_scale_factor_) {
if (compositor_device_scale_factor_override_) {
zoom_factor *= compositor_device_scale_factor_override_;
@@ -2309,10 +2325,31 @@ double WebViewImpl::SetMainFrameZoomLevel(double zoom_level) {
return zoom_factor;
}
void WebViewImpl::RecomputeMainFrameZoomFactor() {
if (auto* main_frame = MainFrameImpl()) {
if (auto* widget = main_frame->FrameWidgetImpl()) {
widget->SetZoomLevel(widget->GetZoomLevel());
double WebViewImpl::ZoomFactorToZoomLevel(double zoom_factor) const {
if (zoom_factor_for_device_scale_factor_) {
if (compositor_device_scale_factor_override_) {
zoom_factor /= compositor_device_scale_factor_override_;
} else {
zoom_factor /= zoom_factor_for_device_scale_factor_;
}
}
return blink::ZoomFactorToZoomLevel(zoom_factor);
}
void WebViewImpl::UpdateWidgetZoomFactors() {
ForEachFrameWidgetControlledByView(*this, [](WebFrameWidgetImpl* widget) {
widget->SetZoomLevel(widget->GetZoomLevel());
});
}
void WebViewImpl::UpdateInspectorDeviceScaleFactorOverride() {
if (zoom_factor_for_device_scale_factor_) {
if (compositor_device_scale_factor_override_) {
page_->SetInspectorDeviceScaleFactorOverride(
zoom_factor_for_device_scale_factor_ /
compositor_device_scale_factor_override_);
} else {
page_->SetInspectorDeviceScaleFactorOverride(1.0f);
}
}
}
@@ -2366,10 +2403,12 @@ void WebViewImpl::SetPageScaleFactor(float scale_factor) {
void WebViewImpl::SetZoomFactorForDeviceScaleFactor(
float zoom_factor_for_device_scale_factor) {
DCHECK(does_composite_);
// We can't early-return here if these are already equal, because we may
// need to propagate the correct zoom factor to newly navigated frames.
zoom_factor_for_device_scale_factor_ = zoom_factor_for_device_scale_factor;
RecomputeMainFrameZoomFactor();
if (zoom_factor_for_device_scale_factor_ !=
zoom_factor_for_device_scale_factor) {
zoom_factor_for_device_scale_factor_ = zoom_factor_for_device_scale_factor;
UpdateWidgetZoomFactors();
UpdateInspectorDeviceScaleFactorOverride();
}
}
void WebViewImpl::SetPageLifecycleStateFromNewPageCommit(
@@ -3213,12 +3252,12 @@ void WebViewImpl::ConfigureAutoResizeMode() {
void WebViewImpl::SetCompositorDeviceScaleFactorOverride(
float device_scale_factor) {
if (compositor_device_scale_factor_override_ == device_scale_factor)
return;
compositor_device_scale_factor_override_ = device_scale_factor;
if (zoom_factor_for_device_scale_factor_) {
RecomputeMainFrameZoomFactor();
return;
if (compositor_device_scale_factor_override_ != device_scale_factor) {
compositor_device_scale_factor_override_ = device_scale_factor;
if (zoom_factor_for_device_scale_factor_) {
UpdateWidgetZoomFactors();
UpdateInspectorDeviceScaleFactorOverride();
}
}
}
@@ -3307,8 +3346,7 @@ void WebViewImpl::UpdateColorProviders(
bool color_providers_did_change =
page_->UpdateColorProviders(color_provider_colors);
if (color_providers_did_change) {
Page::PlatformColorsChanged();
Page::ColorSchemeChanged();
Page::ForcedColorsChanged();
}
}
@@ -3763,7 +3801,11 @@ void WebViewImpl::SetBackgroundColorOverrideForFullscreenController(
void WebViewImpl::SetZoomFactorOverride(float zoom_factor) {
zoom_factor_override_ = zoom_factor;
RecomputeMainFrameZoomFactor();
// This only affects the local main frame, so no need to propagate to all
// frame widgets.
if (web_widget_) {
web_widget_->SetZoomLevel(web_widget_->GetZoomLevel());
}
}
Element* WebViewImpl::FocusedElement() const {
@@ -1088,7 +1088,13 @@
{
name: "inForcedColors",
initial: false,
invalidate: ["ColorScheme"],
type: "bool",
},
{
name: "isForcedColorsDisabled",
initial: false,
invalidate: ["ForcedColors"],
type: "bool",
},
@@ -43,6 +43,11 @@ interface TextMetrics {
[RuntimeEnabled=ExtendedTextMetrics] readonly attribute double emHeightAscent;
[RuntimeEnabled=ExtendedTextMetrics] readonly attribute double emHeightDescent;
// For editing, to get the text offset at a point
[RuntimeEnabled=ExtendedTextMetrics] unsigned long caretPositionFromPoint(double x);
// For selection
[RuntimeEnabled=ExtendedTextMetrics, RaisesException] sequence<DOMRectReadOnly> getSelectionRects([EnforceRange] unsigned long start, [EnforceRange] unsigned long end);
// For bounding box
[RuntimeEnabled=ExtendedTextMetrics, RaisesException] DOMRectReadOnly getActualBoundingBox([EnforceRange] unsigned long start, [EnforceRange] unsigned long end);
};
@@ -1,11 +0,0 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
Exposed=Window,
RuntimeEnabled=PointerEventDeviceId
] interface DeviceProperties {
constructor(optional DevicePropertiesInit devicePropertiesInitDict = {});
[Measure] readonly attribute long uniqueId;
};
@@ -9,19 +9,19 @@
] interface Navigation : EventTarget {
readonly attribute NavigationHistoryEntry? currentEntry;
sequence<NavigationHistoryEntry> entries();
[RaisesException, MeasureAs=AppHistory] void updateCurrentEntry(NavigationUpdateCurrentEntryOptions options);
[RaisesException, MeasureAs=NavigationAPI] void updateCurrentEntry(NavigationUpdateCurrentEntryOptions options);
readonly attribute NavigationTransition? transition;
[RuntimeEnabled=NavigationActivation] readonly attribute NavigationActivation? activation;
readonly attribute boolean canGoBack;
readonly attribute boolean canGoForward;
[CallWith=ScriptState, MeasureAs=AppHistory] NavigationResult navigate(USVString url, optional NavigationNavigateOptions options = {});
[CallWith=ScriptState, MeasureAs=AppHistory] NavigationResult reload(optional NavigationReloadOptions options = {});
[CallWith=ScriptState, MeasureAs=NavigationAPI] NavigationResult navigate(USVString url, optional NavigationNavigateOptions options = {});
[CallWith=ScriptState, MeasureAs=NavigationAPI] NavigationResult reload(optional NavigationReloadOptions options = {});
[CallWith=ScriptState, MeasureAs=AppHistory] NavigationResult traverseTo(DOMString key, optional NavigationOptions options = {});
[CallWith=ScriptState, MeasureAs=AppHistory] NavigationResult back(optional NavigationOptions options = {});
[CallWith=ScriptState, MeasureAs=AppHistory] NavigationResult forward(optional NavigationOptions options = {});
[CallWith=ScriptState, MeasureAs=NavigationAPI] NavigationResult traverseTo(DOMString key, optional NavigationOptions options = {});
[CallWith=ScriptState, MeasureAs=NavigationAPI] NavigationResult back(optional NavigationOptions options = {});
[CallWith=ScriptState, MeasureAs=NavigationAPI] NavigationResult forward(optional NavigationOptions options = {});
attribute EventHandler onnavigate;
attribute EventHandler onnavigatesuccess;
@@ -10,7 +10,6 @@
#include "base/feature_list.h"
#include "base/time/time.h"
#include "components/attribution_reporting/features.h"
#include "services/network/public/cpp/attribution_reporting_runtime_features.h"
#include "services/network/public/cpp/features.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/features_generated.h"
@@ -18,7 +17,6 @@
#include "third_party/blink/public/common/origin_trials/trial_token.h"
#include "third_party/blink/public/common/origin_trials/trial_token_result.h"
#include "third_party/blink/public/common/origin_trials/trial_token_validator.h"
#include "third_party/blink/public/mojom/frame/frame.mojom-blink.h"
#include "third_party/blink/public/mojom/origin_trial_feature/origin_trial_feature.mojom-shared.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_security_origin.h"
@@ -28,7 +26,6 @@
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/attribution_src_loader.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
@@ -446,24 +443,6 @@ bool OriginTrialContext::InstallSettingFeature(
if (document.GetSettings())
document.GetSettings()->SetForceDarkModeEnabled(true);
return true;
case mojom::blink::OriginTrialFeature::kAttributionReportingCrossAppWeb:
static_assert(
network::AttributionReportingRuntimeFeature::kMaxValue ==
network::AttributionReportingRuntimeFeature::kCrossAppWeb,
"Any new attribution reporting runtime features with an associated "
"origin trial feature need to be able to update the browser when the "
"OT feature is installed. If your new runtime feature also has an OT "
"feature, please add a switch case for the new feature.");
// Tell the browser about this change, but return false so the feature can
// still be installed using the default method.
document.GetFrame()
->GetLocalFrameHostRemote()
.SetAttributionReportingRuntimeFeatures(
document.GetFrame()
->GetAttributionSrcLoader()
->GetRuntimeFeatures());
return false;
default:
return false;
}
@@ -515,9 +494,6 @@ void OriginTrialContext::AddForceEnabledTrials(
}
bool OriginTrialContext::CanEnableTrialFromName(const StringView& trial_name) {
if (trial_name == "PrivacySandboxAdsAPIs")
return base::FeatureList::IsEnabled(features::kPrivacySandboxAdsAPIs);
if (trial_name == "FledgeBiddingAndAuctionServer") {
return base::FeatureList::IsEnabled(features::kInterestGroupStorage) &&
base::FeatureList::IsEnabled(
@@ -548,13 +524,6 @@ bool OriginTrialContext::CanEnableTrialFromName(const StringView& trial_name) {
network::features::kCompressionDictionaryTransportBackend);
}
if (trial_name == "AttributionReportingCrossAppWeb") {
return base::FeatureList::IsEnabled(
attribution_reporting::features::kConversionMeasurement) &&
base::FeatureList::IsEnabled(
network::features::kAttributionReportingCrossAppWeb);
}
if (trial_name == "SoftNavigationHeuristics") {
return base::FeatureList::IsEnabled(features::kSoftNavigationDetection);
}
@@ -571,42 +540,6 @@ bool OriginTrialContext::CanEnableTrialFromName(const StringView& trial_name) {
return true;
}
Vector<mojom::blink::OriginTrialFeature>
OriginTrialContext::RestrictedFeaturesForTrial(const String& trial_name) {
if (trial_name == "PrivacySandboxAdsAPIs") {
Vector<mojom::blink::OriginTrialFeature> restricted;
if (!base::FeatureList::IsEnabled(features::kInterestGroupStorage)) {
restricted.push_back(mojom::blink::OriginTrialFeature::kFledge);
}
if (!base::FeatureList::IsEnabled(features::kBrowsingTopics)) {
restricted.push_back(mojom::blink::OriginTrialFeature::kTopicsAPI);
}
if (!base::FeatureList::IsEnabled(features::kBrowsingTopics) ||
!base::FeatureList::IsEnabled(features::kBrowsingTopicsDocumentAPI)) {
restricted.push_back(
mojom::blink::OriginTrialFeature::kTopicsDocumentAPI);
}
if (!base::FeatureList::IsEnabled(
attribution_reporting::features::kConversionMeasurement)) {
restricted.push_back(
mojom::blink::OriginTrialFeature::kAttributionReporting);
}
if (!base::FeatureList::IsEnabled(features::kFencedFrames)) {
restricted.push_back(mojom::blink::OriginTrialFeature::kFencedFrames);
}
if (!base::FeatureList::IsEnabled(features::kSharedStorageAPI)) {
restricted.push_back(mojom::blink::OriginTrialFeature::kSharedStorageAPI);
}
if (!base::FeatureList::IsEnabled(features::kFencedFramesAPIChanges)) {
restricted.push_back(
mojom::blink::OriginTrialFeature::kFencedFramesAPIChanges);
}
return restricted;
}
return {};
}
OriginTrialFeaturesEnabled OriginTrialContext::EnableTrialFromName(
const String& trial_name,
base::Time expiry_time) {
@@ -619,9 +552,6 @@ OriginTrialFeaturesEnabled OriginTrialContext::EnableTrialFromName(
return result;
}
Vector<mojom::blink::OriginTrialFeature> restricted =
RestrictedFeaturesForTrial(trial_name);
bool did_enable_feature = false;
for (mojom::blink::OriginTrialFeature feature :
origin_trials::FeaturesForTrial(trial_name.Utf8())) {
@@ -631,13 +561,6 @@ OriginTrialFeaturesEnabled OriginTrialContext::EnableTrialFromName(
continue;
}
if (restricted.Contains(feature)) {
DVLOG(1) << "EnableTrialFromName: feature " << static_cast<int>(feature)
<< " is restricted from being enabled via the trial: "
<< trial_name << ".";
continue;
}
did_enable_feature = true;
enabled_features_.insert(feature);
origin_trial_features.push_back(feature);
@@ -219,7 +219,7 @@ interface Internals {
[RaisesException] void setPageScaleFactor(float scaleFactor);
[RaisesException] void setPageScaleFactorLimits(float minScaleFactor, float maxScaleFactor);
[RaisesException] float pageZoomFactor();
[RaisesException] float layoutZoomFactor();
[RaisesException] void setIsCursorVisible(Document document, boolean isVisible);
void setMaxNumberOfFramesToTen(boolean enable);
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://drafts.csswg.org/css-view-transitions-2/#reveal-event
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#pagerevealevent
[
Exposed=Window,
RuntimeEnabled=PageRevealEvent
] interface PageRevealEvent : Event {
constructor(DOMString type, optional PageRevealEventInit eventInitDict = {});
[RuntimeEnabled=ViewTransitionOnNavigation] readonly attribute ViewTransition? viewTransition;
};
@@ -0,0 +1,9 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#pagerevealeventinit
dictionary PageRevealEventInit : EventInit {
ViewTransition? viewTransition = null;
};
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#pageswapevent
[
Exposed=Window,
RuntimeEnabled=PageSwapEvent
] interface PageSwapEvent : Event {
constructor(DOMString type, optional PageSwapEventInit eventInitDict = {});
[RuntimeEnabled=ViewTransitionOnNavigation] readonly attribute ViewTransition? viewTransition;
readonly attribute NavigationActivation? activation;
};
@@ -0,0 +1,10 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#pageswapeventinit
dictionary PageSwapEventInit : EventInit {
NavigationActivation? activation = null;
ViewTransition? viewTransition = null;
};
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(crbug.com/343126579): Add link to spec/explainer.
// https://github.com/explainers-by-googlers/prompt-api
enum AIModelAvailability {
"readily",
"after-download",
@@ -11,50 +12,29 @@ enum AIModelAvailability {
[
Exposed=Window,
RuntimeEnabled=ModelExecutionAPI
RuntimeEnabled=BuiltInAIAPI
]
interface AI {
[
Measure,
CallWith=ScriptState,
RaisesException
RaisesException,
RuntimeEnabled=AIPromptAPI
]
Promise<AIModelAvailability> canCreateTextSession();
[
Measure,
ImplementedAs=canCreateTextSession,
CallWith=ScriptState,
RaisesException
]
Promise<AIModelAvailability> canCreateGenericSession();
[
Measure,
CallWith=ScriptState,
RaisesException
RaisesException,
RuntimeEnabled=AIPromptAPI
]
Promise<AITextSession> createTextSession(
optional AITextSessionOptions options = {}
);
[
Measure,
ImplementedAs=createTextSession,
CallWith=ScriptState,
RaisesException
]
Promise<AITextSession> createGenericSession(
optional AITextSessionOptions options = {}
);
[
Measure,
CallWith=ScriptState,
RaisesException
]
Promise<AITextSessionOptions> defaultTextSessionOptions();
[
Measure,
ImplementedAs=defaultTextSessionOptions,
CallWith=ScriptState,
RaisesException
]
Promise<AITextSessionOptions> defaultGenericSessionOptions();
};
@@ -2,38 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(crbug.com/343126579): Add link to spec/explainer.
// https://github.com/explainers-by-googlers/prompt-api
[
Exposed=Window,
RuntimeEnabled=ModelExecutionAPI
RuntimeEnabled=AIPromptAPI
]
interface AITextSession {
[
Measure,
CallWith=ScriptState,
RaisesException
RaisesException,
RuntimeEnabled=AIPromptAPI
]
Promise<DOMString> prompt(DOMString input);
[
Measure,
ImplementedAs=prompt,
CallWith=ScriptState,
RaisesException
]
Promise<DOMString> execute(DOMString input);
[
Measure,
CallWith=ScriptState,
RaisesException
RaisesException,
RuntimeEnabled=AIPromptAPI
]
ReadableStream promptStreaming(DOMString input);
[
Measure,
ImplementedAs=promptStreaming,
CallWith=ScriptState,
RaisesException
]
Promise<DOMString> executeStreaming(DOMString input);
[
Measure,
CallWith=ScriptState,
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(crbug.com/343126579): Add link to spec/explainer.
// https://github.com/explainers-by-googlers/prompt-api
dictionary AITextSessionOptions {
[EnforceRange] unsigned long topK;
float temperature;
@@ -1,20 +0,0 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(crbug.com/343126579): Add link to spec/explainer.
[
ImplementedAs=DOMAI,
RuntimeEnabled=ModelExecutionAPI
] partial interface Window {
[
Replaceable
]
readonly attribute AI ai;
// TODO(crbug.com/341851444): Remove after confirming there is no usage.
[
Replaceable,
ImplementedAs=ai
]
readonly attribute AI model;
};
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(crbug.com/343126579): Add link to spec/explainer.
// https://github.com/explainers-by-googlers/prompt-api
[
Exposed=(Window,Worker),
ImplementedAs=DOMAI,
RuntimeEnabled=ModelExecutionAPI
] partial interface DedicatedWorkerGlobalScope {
RuntimeEnabled=BuiltInAIAPI
] partial interface mixin WindowOrWorkerGlobalScope {
[
Replaceable
]
@@ -11,8 +11,6 @@
// back-reference to the canvas
[ImplementedAs=offscreenCanvasForBinding] readonly attribute OffscreenCanvas canvas;
[RuntimeEnabled=OffscreenCanvasCommit] void commit();
// state
void save(); // push state on state stack
[NoAllocDirectCall, RaisesException] void restore(); // pop state stack if top state was pushed by save, and restore state
@@ -0,0 +1,38 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://w3c.github.io/webauthn/#dictdef-authenticationextensionsclientinputsjson
dictionary AuthenticationExtensionsLargeBlobInputsJSON {
DOMString support;
boolean read;
Base64URLString write;
};
dictionary AuthenticationExtensionsPRFInputsJSON {
AuthenticationExtensionsPRFValuesJSON eval;
record<USVString, AuthenticationExtensionsPRFValuesJSON> evalByCredential;
};
dictionary AuthenticationExtensionsPRFValuesJSON {
required Base64URLString first;
Base64URLString second;
};
dictionary AuthenticationExtensionsClientInputsJSON {
USVString appid;
USVString appidExclude;
boolean hmacCreateSecret;
USVString credentialProtectionPolicy;
boolean enforceCredentialProtectionPolicy = false;
boolean minPinLength;
boolean credProps = false;
[RuntimeEnabled=WebAuthenticationLargeBlobExtension] AuthenticationExtensionsLargeBlobInputsJSON largeBlob;
Base64URLString credBlob;
boolean getCredBlob;
[RuntimeEnabled=SecurePaymentConfirmation] AuthenticationExtensionsPaymentInputs payment;
[RuntimeEnabled=WebAuthenticationRemoteDesktopSupport] RemoteDesktopClientOverride remoteDesktopClientOverride;
[RuntimeEnabled=WebAuthenticationSupplementalPubKeys] AuthenticationExtensionsSupplementalPubKeysInputs supplementalPubKeys;
[RuntimeEnabled=WebAuthenticationPRF] AuthenticationExtensionsPRFInputsJSON prf;
};
@@ -5,10 +5,10 @@
// https://w3c.github.io/webauthn/#dictdef-authenticationresponsejson
dictionary AuthenticationResponseJSON {
Base64URLString id;
Base64URLString rawId;
AuthenticatorAssertionResponseJSON response;
DOMString? authenticatorAttachment;
AuthenticationExtensionsClientOutputsJSON clientExtensionResults;
DOMString type;
required Base64URLString id;
required Base64URLString rawId;
required AuthenticatorAssertionResponseJSON response;
DOMString authenticatorAttachment;
required AuthenticationExtensionsClientOutputsJSON clientExtensionResults;
required DOMString type;
};
@@ -5,8 +5,8 @@
// https://w3c.github.io/webauthn/#dictdef-authenticatorassertionresponsejson
dictionary AuthenticatorAssertionResponseJSON {
Base64URLString clientDataJSON;
Base64URLString authenticatorData;
Base64URLString signature;
Base64URLString? userHandle;
required Base64URLString clientDataJSON;
required Base64URLString authenticatorData;
required Base64URLString signature;
Base64URLString userHandle;
};
@@ -5,7 +5,10 @@
// https://w3c.github.io/webauthn/#dictdef-authenticatorattestationresponsejson
dictionary AuthenticatorAttestationResponseJSON {
Base64URLString clientDataJSON;
Base64URLString attestationObject;
sequence<DOMString> transports;
required Base64URLString clientDataJSON;
required Base64URLString authenticatorData;
required sequence<DOMString> transports;
Base64URLString publicKey;
required long long publicKeyAlgorithm;
required Base64URLString attestationObject;
};
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://w3c.github.io/pointerevents/#pointerevent-interface
dictionary DevicePropertiesInit {
long uniqueId = 0;
dictionary CredentialReportOptions {
PublicKeyCredentialReportOptions publicKey;
};
@@ -10,4 +10,5 @@ interface CredentialsContainer {
[CallWith=ScriptState, RaisesException, MeasureAs=CredentialManagerStore] Promise<Credential> store(Credential credential);
[CallWith=ScriptState, RaisesException, MeasureAs=CredentialManagerCreate] Promise<Credential?> create(optional CredentialCreationOptions options = {});
[CallWith=ScriptState, MeasureAs=CredentialManagerPreventSilentAccess] Promise<undefined> preventSilentAccess();
[CallWith=ScriptState, RaisesException, RuntimeEnabled=CredentialManagerReport] Promise<undefined> report(CredentialReportOptions options);
};
@@ -17,4 +17,5 @@
[CallWith=ScriptState] static Promise<boolean> isConditionalMediationAvailable();
[RuntimeEnabled=WebAuthenticationJSONSerialization, CallWith=ScriptState] PublicKeyCredentialJSON toJSON();
[RuntimeEnabled=WebAuthenticationJSONSerialization, CallWith=ScriptState, RaisesException] static PublicKeyCredentialCreationOptions parseCreationOptionsFromJSON(PublicKeyCredentialCreationOptionsJSON options);
[RuntimeEnabled=WebAuthenticationJSONSerialization, CallWith=ScriptState, RaisesException] static PublicKeyCredentialRequestOptions parseRequestOptionsFromJSON(PublicKeyCredentialRequestOptionsJSON options);
};
@@ -11,7 +11,7 @@ dictionary PublicKeyCredentialCreationOptions {
unsigned long timeout;
sequence<PublicKeyCredentialDescriptor> excludeCredentials = [];
AuthenticatorSelectionCriteria authenticatorSelection;
[RuntimeEnabled=WebAuthenticationHints] sequence<DOMString> hints = [];
sequence<DOMString> hints = [];
// https://w3c.github.io/webauthn/#enumdef-attestationconveyancepreference
DOMString attestation;
AuthenticationExtensionsClientInputs extensions;
@@ -10,46 +10,6 @@ dictionary PublicKeyCredentialUserEntityJSON {
required DOMString displayName;
};
dictionary PublicKeyCredentialDescriptorJSON {
required Base64URLString id;
required DOMString type;
sequence<DOMString> transports;
};
dictionary AuthenticationExtensionsLargeBlobInputsJSON {
DOMString support;
boolean read;
Base64URLString write;
};
dictionary AuthenticationExtensionsPRFInputsJSON {
AuthenticationExtensionsPRFValuesJSON eval;
record<USVString, AuthenticationExtensionsPRFValuesJSON> evalByCredential;
};
dictionary AuthenticationExtensionsPRFValuesJSON {
required Base64URLString first;
Base64URLString second;
};
dictionary AuthenticationExtensionsClientInputsJSON {
USVString appid;
USVString appidExclude;
boolean hmacCreateSecret;
boolean uvm;
USVString credentialProtectionPolicy;
boolean enforceCredentialProtectionPolicy = false;
boolean minPinLength;
boolean credProps = false;
[RuntimeEnabled=WebAuthenticationLargeBlobExtension] AuthenticationExtensionsLargeBlobInputsJSON largeBlob;
Base64URLString credBlob;
boolean getCredBlob;
[RuntimeEnabled=SecurePaymentConfirmation] AuthenticationExtensionsPaymentInputs payment;
[RuntimeEnabled=WebAuthenticationRemoteDesktopSupport] RemoteDesktopClientOverride remoteDesktopClientOverride;
[RuntimeEnabled=WebAuthenticationSupplementalPubKeys] AuthenticationExtensionsSupplementalPubKeysInputs supplementalPubKeys;
[RuntimeEnabled=WebAuthenticationPRF] AuthenticationExtensionsPRFInputsJSON prf;
};
dictionary PublicKeyCredentialCreationOptionsJSON {
required PublicKeyCredentialRpEntity rp;
required PublicKeyCredentialUserEntityJSON user;
@@ -0,0 +1,11 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://w3c.github.io/webauthn/#dictdef-publickeycredentialdescriptorjson
dictionary PublicKeyCredentialDescriptorJSON {
required Base64URLString id;
required DOMString type;
sequence<DOMString> transports;
};
@@ -5,4 +5,6 @@
// https://w3c.github.io/webauthn/#typedefdef-publickeycredentialjson
typedef DOMString Base64URLString;
typedef (RegistrationResponseJSON or AuthenticationResponseJSON) PublicKeyCredentialJSON;
// This is either RegistrationResponseJSON or AuthenticationResponseJSON.
typedef object PublicKeyCredentialJSON;
@@ -0,0 +1,8 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
dictionary PublicKeyCredentialReportOptions {
USVString rpId;
BufferSource unknownCredentialId;
};
@@ -11,6 +11,6 @@ dictionary PublicKeyCredentialRequestOptions {
sequence<PublicKeyCredentialDescriptor> allowCredentials = [];
// A DOMString expressing a UserVerificationRequirement.
DOMString userVerification;
[RuntimeEnabled=WebAuthenticationHints] sequence<DOMString> hints = [];
sequence<DOMString> hints = [];
AuthenticationExtensionsClientInputs extensions;
};
@@ -0,0 +1,15 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://w3c.github.io/webauthn/#dictdef-publickeycredentialrequestoptionsjson
dictionary PublicKeyCredentialRequestOptionsJSON {
required Base64URLString challenge;
unsigned long timeout;
DOMString rpId;
sequence<PublicKeyCredentialDescriptorJSON> allowCredentials = [];
DOMString userVerification = "preferred";
sequence<DOMString> hints = [];
AuthenticationExtensionsClientInputsJSON extensions;
};
@@ -5,10 +5,10 @@
// https://w3c.github.io/webauthn/#dictdef-registrationresponsejson
dictionary RegistrationResponseJSON {
Base64URLString id;
Base64URLString rawId;
AuthenticatorAttestationResponseJSON response;
DOMString? authenticatorAttachment;
AuthenticationExtensionsClientOutputsJSON clientExtensionResults;
DOMString type;
required Base64URLString id;
required Base64URLString rawId;
required AuthenticatorAttestationResponseJSON response;
DOMString authenticatorAttachment;
required AuthenticationExtensionsClientOutputsJSON clientExtensionResults;
required DOMString type;
};
@@ -10,5 +10,5 @@
[CallWith=ScriptState, RaisesException] void updateInkTrailStartPoint(PointerEvent evt, InkTrailStyle style);
readonly attribute Element? presentationArea;
readonly attribute unsigned long expectedImprovement;
[DeprecateAs=DelegatedInkExpectedImprovement] readonly attribute unsigned long expectedImprovement;
};
@@ -8,4 +8,5 @@ dictionary DocumentPictureInPictureOptions {
[EnforceRange] unsigned long long width = 0;
[EnforceRange] unsigned long long height = 0;
boolean disallowReturnToOpener = false;
[RuntimeEnabled=DocumentPictureInPicturePreferInitialPlacement] boolean preferInitialWindowPlacement = false;
};
@@ -12,14 +12,18 @@
] interface FileSystemObserver {
[
CallWith=ScriptState,
RaisesException
RaisesException,
Measure
] constructor(FileSystemObserverCallback callback);
[
CallWith=ScriptState,
RaisesException
CallWith=ScriptState,
RaisesException,
Measure
] Promise<undefined> observe(FileSystemHandle handle,
optional FileSystemObserverObserveOptions options = {});
void unobserve(FileSystemHandle handle);
void disconnect();
[
RuntimeEnabled=FileSystemObserverUnobserve
] void unobserve(FileSystemHandle handle);
[Measure] void disconnect();
};
@@ -2,16 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This will be a shared interface by two APIs:
// - The Model Loader API,
// https://github.com/webmachinelearning/model-loader/blob/main/explainer.md
// - The WebNN API,
// https://github.com/webmachinelearning/webnn/blob/main/explainer.md
// https://www.w3.org/TR/webnn/#api-ml
[
RuntimeEnabled=MachineLearningCommon,
RuntimeEnabled=MachineLearningNeuralNetwork,
Exposed=(Window, DedicatedWorker)
] interface ML {
[CallWith=ScriptState, RaisesException]
Promise<MLContext> createContext(optional MLContextOptions options = {});
[
CallWith=ScriptState,
RaisesException,
Measure
] Promise<MLContext> createContext(optional MLContextOptions options = {});
};
@@ -19,17 +19,63 @@ dictionary MLComputeResult {
MLNamedArrayBufferViews outputs;
};
dictionary MLContextLostInfo {
DOMString message;
};
dictionary MLSupportLimits {
sequence<DOMString> dataTypes;
};
dictionary MLArgMinMaxSupportLimits {
MLSupportLimits input;
MLSupportLimits output;
};
dictionary MLConcatSupportLimits {
MLSupportLimits inputs;
};
dictionary MLGatherSupportLimits {
MLSupportLimits input;
MLSupportLimits indices;
};
dictionary MLWhereSupportLimits {
MLSupportLimits condition;
MLSupportLimits trueValue;
MLSupportLimits falseValue;
};
dictionary MLOpSupportLimits {
MLSupportLimits input;
MLSupportLimits constant;
MLSupportLimits output;
MLArgMinMaxSupportLimits argMin;
MLArgMinMaxSupportLimits argMax;
MLConcatSupportLimits concat;
MLGatherSupportLimits gather;
MLWhereSupportLimits where;
};
typedef record<DOMString, MLBuffer> MLNamedBuffers;
[
RuntimeEnabled=MachineLearningCommon,
RuntimeEnabled=MachineLearningNeuralNetwork,
SecureContext,
Exposed=(Window, DedicatedWorker)
] interface MLContext {
[
RuntimeEnabled=MachineLearningNeuralNetwork,
CallWith=ScriptState
] readonly attribute Promise<MLContextLostInfo> lost;
[
RuntimeEnabled=MachineLearningNeuralNetwork,
CallWith=ScriptState,
RaisesException
RaisesException,
Measure
] Promise<MLComputeResult> compute(
MLGraph graph, MLNamedArrayBufferViews inputs, MLNamedArrayBufferViews outputs);
@@ -75,7 +121,12 @@ typedef record<DOMString, MLBuffer> MLNamedBuffers;
[
RuntimeEnabled=MachineLearningNeuralNetwork,
CallWith=ScriptState,
RaisesException
RaisesException,
Measure
] void dispatch(
MLGraph graph, MLNamedBuffers inputs, MLNamedBuffers outputs);
[
RuntimeEnabled=MachineLearningNeuralNetwork,
CallWith=ScriptState
] MLOpSupportLimits opSupportLimits();
};
@@ -1,24 +0,0 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// We expect `MLModel` serves as an umbrella interface and the Model Loader API
// will be the first one using it. It will also be a good counterpart of the
// `MLGraph` used in the WebNN API.
//
// Explainer of Model Loader API:
// https://github.com/webmachinelearning/model-loader/blob/main/explainer.md
// Spec of the WebNN API:
// https://webmachinelearning.github.io/webnn/
[
SecureContext,
RuntimeEnabled=MachineLearningModelLoader
] interface MLModel {
[CallWith=ScriptState, RaisesException] Promise<record<DOMString, MLTensor>>
compute(record<DOMString, MLTensor> inputs);
[CallWith=ScriptState] sequence<MLTensorInfo> inputs();
[CallWith=ScriptState] sequence<MLTensorInfo> outputs();
};
@@ -1,15 +0,0 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/webmachinelearning/model-loader/blob/main/explainer.md
[
RuntimeEnabled=MachineLearningModelLoader,
Exposed=Window
] interface MLModelLoader {
[CallWith=ScriptState, RaisesException] constructor(MLContext context);
[CallWith=ScriptState, RaisesException] Promise<MLModel>
load(ArrayBuffer buffer);
};
@@ -1,10 +0,0 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/webmachinelearning/model-loader/blob/main/explainer.md
dictionary MLTensor {
required ArrayBufferView data;
required sequence<unsigned long> dimensions;
};
@@ -1,27 +0,0 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/webmachinelearning/model-loader/blob/main/explainer.md
enum MLDataType {
"unknown",
"int64",
"uint64",
"float64",
"int32",
"uint32",
"float32",
"int16",
"uint16",
"float16",
"int8",
"uint8",
"bool",
};
dictionary MLTensorInfo {
required DOMString name;
required MLDataType type;
required sequence<unsigned long> dimensions;
};
@@ -2,17 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This will be a shared interface by two APIs:
// - The Model Loader API,
// https://github.com/webmachinelearning/model-loader/blob/main/explainer.md
// - The WebNN API,
// https://github.com/webmachinelearning/webnn/blob/main/explainer.md
// https://www.w3.org/TR/webnn/#api-ml
[
Exposed=Window,
SecureContext,
ImplementedAs=NavigatorML,
RuntimeEnabled=MachineLearningCommon
RuntimeEnabled=MachineLearningNeuralNetwork
] partial interface Navigator {
[SameObject] readonly attribute ML ml;
};

Some files were not shown because too many files have changed in this diff Show More