0

Add a feature that just records metrics for History Clusters module without rendering

Bug: 1418730,b/265301309
Change-Id: Ida408efe2f218d06a8b4ecda7658434ea05de523
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292453
Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Sophie Chang <sophiechang@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1110692}
This commit is contained in:
Sophie Chang
2023-02-28 00:53:09 +00:00
committed by Chromium LUCI CQ
parent 2ca6dec6a9
commit 28c78e455f
5 changed files with 33 additions and 8 deletions
chrome/browser
components/search

@ -1050,7 +1050,9 @@ void PopulateChromeWebUIFrameBinders(
NewTabPageUI>(map);
}
if (base::FeatureList::IsEnabled(ntp_features::kNtpHistoryClustersModule)) {
if (base::FeatureList::IsEnabled(ntp_features::kNtpHistoryClustersModule) ||
base::FeatureList::IsEnabled(
ntp_features::kNtpHistoryClustersModuleLoad)) {
RegisterWebUIControllerInterfaceBinder<
ntp::history_clusters::mojom::PageHandler, NewTabPageUI>(map);
}

@ -17,6 +17,7 @@ import {driveDescriptor as driveV2Descriptor} from './drive_v2/module.js';
import {dummyV2Descriptor, dummyV2Descriptor02, dummyV2Descriptor03, dummyV2Descriptor04, dummyV2Descriptor05, dummyV2Descriptor06, dummyV2Descriptor07, dummyV2Descriptor08, dummyV2Descriptor09, dummyV2Descriptor10, dummyV2Descriptor11, dummyV2Descriptor12} from './dummy_v2/module.js';
// </if>
import {feedDescriptor, feedV2Descriptor} from './feed/module.js';
import {HistoryClustersProxyImpl} from './history_clusters/history_clusters_proxy.js';
import {historyClustersDescriptor} from './history_clusters/module.js';
import {ModuleDescriptor} from './module_descriptor.js';
import {ModuleRegistry} from './module_registry.js';
@ -66,5 +67,12 @@ export async function counterfactualLoad() {
modules.map(module => module.descriptor.id));
}
}
// Instantiate history clusters module if |historyClustersModuleEnabled| is
// false to counterfactually log metrics about the coverage of the history
// clusters module without rendering it.
if (!loadTimeData.getBoolean('historyClustersModuleEnabled') &&
loadTimeData.getBoolean('historyClustersModuleLoadEnabled')) {
HistoryClustersProxyImpl.getInstance().handler.getCluster();
}
}
counterfactualLoad();

@ -101,6 +101,13 @@ namespace {
constexpr char kPrevNavigationTimePrefName[] = "NewTabPage.PrevNavigationTime";
bool HasCredentials(Profile* profile) {
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile);
return
/* Can be null if Chrome signin is disabled. */ identity_manager &&
identity_manager->GetAccountsInCookieJar().signed_in_accounts.size() > 0;
}
void AddRawStringOrDefault(content::WebUIDataSource* source,
const char key[],
const std::string str,
@ -207,6 +214,13 @@ content::WebUIDataSource* CreateAndAddNewTabPageUiHtmlSource(Profile* profile) {
ntp_features::kNtpModulesLoad));
source->AddInteger("modulesLoadTimeout",
ntp_features::GetModulesLoadTimeout().InMilliseconds());
source->AddBoolean(
"historyClustersModuleEnabled",
base::FeatureList::IsEnabled(ntp_features::kNtpHistoryClustersModule));
source->AddBoolean("historyClustersModuleLoadEnabled",
base::FeatureList::IsEnabled(
ntp_features::kNtpHistoryClustersModuleLoad) &&
HasCredentials(profile));
static constexpr webui::LocalizedString kStrings[] = {
{"doneButton", IDS_DONE},
@ -531,13 +545,6 @@ content::WebUIDataSource* CreateAndAddNewTabPageUiHtmlSource(Profile* profile) {
return source;
}
bool HasCredentials(Profile* profile) {
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile);
return
/* Can be null if Chrome signin is disabled. */ identity_manager &&
identity_manager->GetAccountsInCookieJar().signed_in_accounts.size() > 0;
}
} // namespace
NewTabPageUI::NewTabPageUI(content::WebUI* web_ui)

@ -248,6 +248,13 @@ BASE_FEATURE(kNtpHistoryClustersModuleCategories,
"NtpHistoryClustersModuleCategories",
base::FEATURE_DISABLED_BY_DEFAULT);
// If enabled, the history clusters module will be loaded but not shown. This is
// useful to determine if a user would have seen modules in order to
// counterfactually log or trigger.
BASE_FEATURE(kNtpHistoryClustersModuleLoad,
"NtpHistoryClustersModuleLoad",
base::FEATURE_DISABLED_BY_DEFAULT);
const base::FeatureParam<double>
kNtpElementLuminosityChangeForLightBackgroundParam{
&kNtpComprehensiveTheming,

@ -67,6 +67,7 @@ BASE_DECLARE_FEATURE(kNtpHistoryClustersModule);
BASE_DECLARE_FEATURE(kNtpHistoryClustersModuleBeginTimeDuration);
BASE_DECLARE_FEATURE(kNtpHistoryClustersModuleMinimumImagesRequired);
BASE_DECLARE_FEATURE(kNtpHistoryClustersModuleCategories);
BASE_DECLARE_FEATURE(kNtpHistoryClustersModuleLoad);
// Parameter for controlling the luminosity difference for NTP elements on light
// backgrounds.