privacy-hub: Remove HaTS code
Happiness tracking surveys have wrapped up. Remove the outdated HaTS
client code to reduce dead code.
Bug: 380421104
Change-Id: Ic84d79fe8a309e2ffb4e6035dc7a68353602ea64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6038050
Auto-Submit: Christoph Schlosser <[email protected]>
Commit-Queue: Kyle Horimoto <[email protected]>
Reviewed-by: Kyle Horimoto <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1388485}
diff --git a/chrome/browser/ash/BUILD.gn b/chrome/browser/ash/BUILD.gn
index e9e4dcc..ca91e1f 100644
--- a/chrome/browser/ash/BUILD.gn
+++ b/chrome/browser/ash/BUILD.gn
@@ -330,7 +330,6 @@
"//chrome/browser/ash/policy/status_collector:browser_tests",
"//chrome/browser/ash/preferences:browser_tests",
"//chrome/browser/ash/printing/print_management:browser_tests",
- "//chrome/browser/ash/privacy_hub:browser_tests",
"//chrome/browser/ash/remote_apps:browser_tests",
"//chrome/browser/ash/scalable_iph:browser_tests",
"//chrome/browser/ash/smb_client:browser_tests",
diff --git a/chrome/browser/ash/hats/hats_config.cc b/chrome/browser/ash/hats/hats_config.cc
index 91ab87dd..84b13a49 100644
--- a/chrome/browser/ash/hats/hats_config.cc
+++ b/chrome/browser/ash/hats/hats_config.cc
@@ -232,16 +232,6 @@
prefs::kHatsPeripheralsCycleEndTs, // cycle_end_timestamp_pref_name
};
-// Privacy Hub post launch experience survey -- shown 40 seconds after the user
-// leaves the Privacy controls page after staying there for 5 seconds.
-const HatsConfig kPrivacyHubPostLaunchSurvey = {
- ::features::kHappinessTrackingPrivacyHubPostLaunch, // feature
- base::Days(1), // new_device_threshold
- prefs::kHatsPrivacyHubPostLaunchIsSelected, // is_selected_pref_name
- prefs::
- kHatsPrivacyHubPostLaunchCycleEndTs, // cycle_end_timestamp_pref_name
-};
-
// OS Settings Survey -- shown [5-30] seconds after a user removes focus from
// Settings or closes the Settings app, if user has used Search, it will add it
// as a Product Specific Data (PSD).
diff --git a/chrome/browser/ash/hats/hats_config.h b/chrome/browser/ash/hats/hats_config.h
index fda016b..b661ffc 100644
--- a/chrome/browser/ash/hats/hats_config.h
+++ b/chrome/browser/ash/hats/hats_config.h
@@ -86,7 +86,6 @@
extern const HatsConfig kHatsBluetoothRevampSurvey;
extern const HatsConfig kHatsBatteryLifeSurvey;
extern const HatsConfig kHatsPeripheralsSurvey;
-extern const HatsConfig kPrivacyHubPostLaunchSurvey;
extern const HatsConfig kHatsOsSettingsSearchSurvey;
extern const HatsConfig kHatsBorealisGamesSurvey;
extern const HatsConfig kHatsLauncherAppsFindingSurvey;
diff --git a/chrome/browser/ash/preferences/preferences.cc b/chrome/browser/ash/preferences/preferences.cc
index 8d6a07d..0ea6ab9 100644
--- a/chrome/browser/ash/preferences/preferences.cc
+++ b/chrome/browser/ash/preferences/preferences.cc
@@ -512,11 +512,6 @@
registry->RegisterBooleanPref(::prefs::kHatsPeripheralsIsSelected, false);
- registry->RegisterBooleanPref(::prefs::kHatsPrivacyHubPostLaunchIsSelected,
- false);
-
- registry->RegisterInt64Pref(::prefs::kHatsPrivacyHubPostLaunchCycleEndTs, 0);
-
// Personalization HaTS survey prefs for avatar, screensaver, and wallpaper
// features.
registry->RegisterInt64Pref(
diff --git a/chrome/browser/ash/privacy_hub/BUILD.gn b/chrome/browser/ash/privacy_hub/BUILD.gn
index 61a0e4e..3c81d53 100644
--- a/chrome/browser/ash/privacy_hub/BUILD.gn
+++ b/chrome/browser/ash/privacy_hub/BUILD.gn
@@ -8,15 +8,12 @@
static_library("privacy_hub") {
sources = [
- "privacy_hub_hats_trigger.cc",
- "privacy_hub_hats_trigger.h",
"privacy_hub_util.cc",
"privacy_hub_util.h",
]
deps = [
"//ash/webui/settings/public/constants:mojom",
- "//chrome/browser/ash/hats",
"//chrome/browser/profiles",
"//chromeos/ash/components/camera_presence_notifier",
"//components/session_manager/core",
@@ -28,18 +25,3 @@
"//chrome/browser:browser_public_dependencies",
]
}
-
-source_set("browser_tests") {
- testonly = true
-
- defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
-
- sources = [ "privacy_hub_hats_trigger_browsertest.cc" ]
-
- deps = [
- ":privacy_hub",
- "//base",
- "//chrome/browser/ash/hats",
- "//chrome/test:test_support",
- ]
-}
diff --git a/chrome/browser/ash/privacy_hub/DEPS b/chrome/browser/ash/privacy_hub/DEPS
index 6dbd228..207b15f 100644
--- a/chrome/browser/ash/privacy_hub/DEPS
+++ b/chrome/browser/ash/privacy_hub/DEPS
@@ -14,7 +14,6 @@
# Files residing in certain directories (e.g., //chrome/browser) are listed
# individually. Other dependencies within //chrome are listed on a per-
# directory basis. See //tools/chromeos/gen_deps.sh for details.
- "+chrome/browser/ash/hats",
"+chrome/browser/notifications",
"+chrome/browser/profiles",
"+chrome/browser/ui/ash",
diff --git a/chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger.cc b/chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger.cc
deleted file mode 100644
index f5227b88..0000000
--- a/chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger.cc
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger.h"
-
-#include "chrome/browser/ash/hats/hats_config.h"
-#include "chrome/browser/ash/hats/hats_notification_controller.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "components/session_manager/core/session_manager.h"
-
-namespace ash {
-namespace {
-const HatsConfig& kHatsConfig = kPrivacyHubPostLaunchSurvey;
-constexpr base::TimeDelta kShowSurveyDelay = base::Seconds(40);
-}
-
-PrivacyHubHatsTrigger& PrivacyHubHatsTrigger::Get() {
- static base::NoDestructor<PrivacyHubHatsTrigger> instance;
- return *instance;
-}
-
-void PrivacyHubHatsTrigger::ShowSurveyAfterDelayElapsed() {
- // The user has already seen a survey or we're about to show them one.
- if (hats_controller_ || show_notification_timer_.IsRunning()) {
- return;
- }
-
- show_notification_timer_.Start(
- FROM_HERE, kShowSurveyDelay,
- base::BindOnce(&PrivacyHubHatsTrigger::ShowSurveyIfSelected,
- base::Unretained(this)));
-}
-
-PrivacyHubHatsTrigger::PrivacyHubHatsTrigger() = default;
-PrivacyHubHatsTrigger::~PrivacyHubHatsTrigger() = default;
-
-void PrivacyHubHatsTrigger::ShowSurveyIfSelected() {
- // We only show the survey if the current session is still active.
- if (session_manager::SessionManager::Get()->IsUserSessionBlocked()) {
- return;
- }
-
- Profile* profile = GetProfile();
- if (!profile) {
- // This can happen in tests when there is no `ProfileManager` instance.
- return;
- }
-
- if (HatsNotificationController::ShouldShowSurveyToProfile(profile,
- kHatsConfig)) {
- hats_controller_ =
- base::MakeRefCounted<HatsNotificationController>(profile, kHatsConfig);
- }
-}
-
-void PrivacyHubHatsTrigger::SetNoProfileForTesting(const bool no_profile) {
- no_profile_for_testing_ = no_profile;
-}
-
-const HatsNotificationController*
-PrivacyHubHatsTrigger::GetHatsNotificationControllerForTesting() const {
- return hats_controller_.get();
-}
-
-base::OneShotTimer& PrivacyHubHatsTrigger::GetTimerForTesting() {
- return show_notification_timer_;
-}
-
-Profile* PrivacyHubHatsTrigger::GetProfile() const {
- if (no_profile_for_testing_) {
- return nullptr;
- }
-
- return ProfileManager::GetActiveUserProfile();
-}
-
-} // namespace ash
diff --git a/chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger.h b/chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger.h
deleted file mode 100644
index 294fefe2..0000000
--- a/chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_ASH_PRIVACY_HUB_PRIVACY_HUB_HATS_TRIGGER_H_
-#define CHROME_BROWSER_ASH_PRIVACY_HUB_PRIVACY_HUB_HATS_TRIGGER_H_
-
-#include "base/memory/scoped_refptr.h"
-#include "base/no_destructor.h"
-#include "base/timer/timer.h"
-
-class Profile;
-
-namespace ash {
-namespace settings {
-class PrivacyHubHandlerHatsTest;
-}
-
-class HatsNotificationController;
-
-// Implementation for the Privacy Hub Hats surveys.
-// This is a simple abstraction on top of the standard mechanisms to show a
-// survey within the PrivacyHub specific limits.
-class PrivacyHubHatsTrigger {
- public:
- static PrivacyHubHatsTrigger& Get();
-
- PrivacyHubHatsTrigger(const PrivacyHubHatsTrigger&) = delete;
- PrivacyHubHatsTrigger& operator=(const PrivacyHubHatsTrigger&) = delete;
-
- // Start the delay to show the survey to the user if they are selected. If the
- // user has already seen a survey or this is called while the delay hasn't
- // elapsed yet nothing will happen.
- void ShowSurveyAfterDelayElapsed();
-
- private:
- friend class base::NoDestructor<PrivacyHubHatsTrigger>;
- friend class PrivacyHubHatsTriggerTest;
- friend class settings::PrivacyHubHandlerHatsTest;
-
- PrivacyHubHatsTrigger();
- ~PrivacyHubHatsTrigger();
-
- const HatsNotificationController* GetHatsNotificationControllerForTesting()
- const;
- base::OneShotTimer& GetTimerForTesting();
- void SetNoProfileForTesting(bool no_profile);
- Profile* GetProfile() const;
-
- // Show the survey to the current primary user if they are selected. If they
- // aren't or any of the surveys preconditions aren't met this does nothing.
- void ShowSurveyIfSelected();
-
- base::OneShotTimer show_notification_timer_;
- scoped_refptr<HatsNotificationController> hats_controller_;
- bool no_profile_for_testing_ = false;
-};
-
-} // namespace ash
-
-#endif // CHROME_BROWSER_ASH_PRIVACY_HUB_PRIVACY_HUB_HATS_TRIGGER_H_
diff --git a/chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger_browsertest.cc b/chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger_browsertest.cc
deleted file mode 100644
index 1a9b0e4..0000000
--- a/chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger_browsertest.cc
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger.h"
-
-#include "ash/constants/ash_switches.h"
-#include "chrome/browser/ash/hats/hats_config.h"
-#include "chrome/browser/ash/hats/hats_notification_controller.h"
-#include "chrome/browser/notifications/notification_display_service_tester.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/common/chrome_features.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "components/session_manager/core/session_manager.h"
-#include "components/session_manager/session_manager_types.h"
-#include "content/public/test/browser_test.h"
-
-namespace ash {
-
-class PrivacyHubHatsTriggerTest : public InProcessBrowserTest {
- public:
- PrivacyHubHatsTriggerTest() {
- scoped_feature_list_.InitAndEnableFeature(
- kPrivacyHubPostLaunchSurvey.feature);
- }
- ~PrivacyHubHatsTriggerTest() override = default;
-
- // InProcessBrowserTest:
- void SetUpOnMainThread() override {
- InProcessBrowserTest::SetUpOnMainThread();
-
- display_service_ = std::make_unique<NotificationDisplayServiceTester>(
- browser()->profile());
- }
-
- void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
- InProcessBrowserTest::SetUpDefaultCommandLine(command_line);
-
- command_line->AppendSwitchASCII(
- ash::switches::kForceHappinessTrackingSystem,
- ::features::kHappinessTrackingPrivacyHubPostLaunch.name);
- }
-
- bool IsHatsNotificationActive() const {
- return display_service_
- ->GetNotification(HatsNotificationController::kNotificationId)
- .has_value();
- }
-
- const HatsNotificationController* GetHatsNotificationController() const {
- return privacy_hub_trigger_.GetHatsNotificationControllerForTesting();
- }
-
- base::OneShotTimer& GetTimer() {
- return privacy_hub_trigger_.GetTimerForTesting();
- }
-
- void SetNoProfileForTesting() {
- privacy_hub_trigger_.SetNoProfileForTesting(true);
- }
-
- void ExpectTimerIsRunningThenTrigger() {
- EXPECT_TRUE(GetTimer().IsRunning());
- EXPECT_FALSE(IsHatsNotificationActive());
- EXPECT_FALSE(GetHatsNotificationController());
-
- GetTimer().FireNow();
- }
-
- void RunThenTriggerTimer(base::TimeDelta delay) {
- base::SequencedTaskRunner::GetCurrentDefault()->PostDelayedTask(
- FROM_HERE,
- base::BindOnce(
- &PrivacyHubHatsTriggerTest::ExpectTimerIsRunningThenTrigger,
- base::Unretained(this)),
- delay);
- }
-
- base::test::ScopedFeatureList scoped_feature_list_;
- PrivacyHubHatsTrigger privacy_hub_trigger_;
-
- std::unique_ptr<NotificationDisplayServiceTester> display_service_;
-};
-
-IN_PROC_BROWSER_TEST_F(PrivacyHubHatsTriggerTest, ShowSurveySuccess) {
- EXPECT_FALSE(IsHatsNotificationActive());
-
- base::RunLoop loop;
- display_service_->SetNotificationAddedClosure(loop.QuitClosure());
- privacy_hub_trigger_.ShowSurveyAfterDelayElapsed();
-
- RunThenTriggerTimer(base::Seconds(2));
-
- loop.Run();
-
- EXPECT_TRUE(GetHatsNotificationController());
- EXPECT_TRUE(IsHatsNotificationActive());
-}
-
-IN_PROC_BROWSER_TEST_F(PrivacyHubHatsTriggerTest, ShowSurveyOnlyOnce) {
- EXPECT_FALSE(IsHatsNotificationActive());
-
- // Show survey once
- base::RunLoop loop;
- display_service_->SetNotificationAddedClosure(loop.QuitClosure());
- privacy_hub_trigger_.ShowSurveyAfterDelayElapsed();
-
- RunThenTriggerTimer(base::Seconds(2));
-
- loop.Run();
-
- const HatsNotificationController* hats_notification_controller =
- GetHatsNotificationController();
- EXPECT_NE(hats_notification_controller, nullptr);
- EXPECT_TRUE(IsHatsNotificationActive());
-
- // Trigger survey again but the controller shouldn't be a new instance.
- privacy_hub_trigger_.ShowSurveyAfterDelayElapsed();
-
- EXPECT_EQ(hats_notification_controller, GetHatsNotificationController());
-}
-
-IN_PROC_BROWSER_TEST_F(PrivacyHubHatsTriggerTest, NoActiveProfile) {
- SetNoProfileForTesting();
- EXPECT_FALSE(IsHatsNotificationActive());
-
- privacy_hub_trigger_.ShowSurveyAfterDelayElapsed();
-
- EXPECT_FALSE(GetHatsNotificationController());
-}
-
-IN_PROC_BROWSER_TEST_F(PrivacyHubHatsTriggerTest, NoSurveyIfSessionNotActive) {
- session_manager::SessionManager::Get()->SetSessionState(
- session_manager::SessionState::LOCKED);
- EXPECT_FALSE(IsHatsNotificationActive());
-
- privacy_hub_trigger_.ShowSurveyAfterDelayElapsed();
-
- EXPECT_FALSE(GetHatsNotificationController());
-}
-
-} // namespace ash
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 5435f8bf..98f7106 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -1167,6 +1167,14 @@
"profile.content_settings.quiet_permission_ui_promo.should_show."
"notifications";
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+// Deprecated 11/2024
+inline constexpr char kHatsPrivacyHubPostLaunchIsSelected[] =
+ "hats_privacy_hub_postlaunch_is_selected";
+inline constexpr char kHatsPrivacyHubPostLaunchCycleEndTs[] =
+ "hats_privacy_hub_postlaunch_end_timestamp";
+#endif
+
// Register local state used only for migration (clearing or moving to a new
// key).
void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
@@ -1655,6 +1663,11 @@
true);
registry->RegisterBooleanPref(kQuietNotificationPermissionShouldShowPromo,
true);
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ // Deprecated 11/2024
+ registry->RegisterBooleanPref(kHatsPrivacyHubPostLaunchIsSelected, false);
+ registry->RegisterInt64Pref(kHatsPrivacyHubPostLaunchCycleEndTs, 0);
+#endif
}
void ClearSyncRequestedPrefAndMaybeMigrate(PrefService* profile_prefs) {
@@ -3018,6 +3031,12 @@
profile_prefs->ClearPref(kQuietNotificationPermissionPromoWasShown);
profile_prefs->ClearPref(kQuietNotificationPermissionShouldShowPromo);
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ // Added 11/2024
+ profile_prefs->ClearPref(kHatsPrivacyHubPostLaunchIsSelected);
+ profile_prefs->ClearPref(kHatsPrivacyHubPostLaunchCycleEndTs);
+#endif
+
// Please don't delete the following line. It is used by PRESUBMIT.py.
// END_MIGRATE_OBSOLETE_PROFILE_PREFS
diff --git a/chrome/browser/resources/ash/settings/os_privacy_page/os_privacy_page.ts b/chrome/browser/resources/ash/settings/os_privacy_page/os_privacy_page.ts
index 70c355e..d686dc6 100644
--- a/chrome/browser/resources/ash/settings/os_privacy_page/os_privacy_page.ts
+++ b/chrome/browser/resources/ash/settings/os_privacy_page/os_privacy_page.ts
@@ -209,14 +209,6 @@
readOnly: true,
},
- isHatsSurveyEnabled_: {
- type: Boolean,
- value: function() {
- return loadTimeData.getBoolean('isPrivacyHubHatsEnabled');
- },
- readOnly: true,
- },
-
isAccountManagerEnabled_: {
type: Boolean,
value() {
diff --git a/chrome/browser/resources/ash/settings/os_privacy_page/privacy_hub_browser_proxy.ts b/chrome/browser/resources/ash/settings/os_privacy_page/privacy_hub_browser_proxy.ts
index c8e75608..9222ab3 100644
--- a/chrome/browser/resources/ash/settings/os_privacy_page/privacy_hub_browser_proxy.ts
+++ b/chrome/browser/resources/ash/settings/os_privacy_page/privacy_hub_browser_proxy.ts
@@ -12,8 +12,6 @@
getCurrentTimeZoneName(): Promise<string>;
getCurrentSunriseTime(): Promise<string>;
getCurrentSunsetTime(): Promise<string>;
- sendLeftOsPrivacyPage(): void;
- sendOpenedOsPrivacyPage(): void;
}
let instance: PrivacyHubBrowserProxy|null = null;
@@ -47,14 +45,6 @@
return sendWithPromise('getCurrentSunsetTime');
}
- sendLeftOsPrivacyPage(): void {
- chrome.send('leftOsPrivacyPage');
- }
-
- sendOpenedOsPrivacyPage(): void {
- chrome.send('osPrivacyPageWasOpened');
- }
-
static getInstance(): PrivacyHubBrowserProxy {
return instance || (instance = new PrivacyHubBrowserProxyImpl());
}
diff --git a/chrome/browser/resources/ash/settings/os_privacy_page/privacy_hub_subpage.ts b/chrome/browser/resources/ash/settings/os_privacy_page/privacy_hub_subpage.ts
index 33bd7ba..bf52acf 100644
--- a/chrome/browser/resources/ash/settings/os_privacy_page/privacy_hub_subpage.ts
+++ b/chrome/browser/resources/ash/settings/os_privacy_page/privacy_hub_subpage.ts
@@ -80,14 +80,6 @@
value: true,
},
- isHatsSurveyEnabled_: {
- type: Boolean,
- readOnly: true,
- value: function() {
- return loadTimeData.getBoolean('isPrivacyHubHatsEnabled');
- },
- },
-
isMicListEmpty_: {
type: Boolean,
value: true,
@@ -175,7 +167,6 @@
private cameraRowSubtext_: string;
private isCameraListEmpty_: boolean;
private isMicListEmpty_: boolean;
- private isHatsSurveyEnabled_: boolean;
private microphoneRowSubtext_: string;
private microphoneHardwareToggleActive_: boolean;
private shouldDisableMicrophoneToggle_: boolean;
@@ -221,14 +212,8 @@
override currentRouteChanged(route: Route): void {
// Does not apply to this page.
if (route !== routes.PRIVACY_HUB) {
- if (this.isHatsSurveyEnabled_) {
- this.browserProxy_.sendLeftOsPrivacyPage();
- }
return;
}
- if (this.isHatsSurveyEnabled_) {
- this.browserProxy_.sendOpenedOsPrivacyPage();
- }
this.attemptDeepLink();
}
diff --git a/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler.cc b/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler.cc
index c328850..f68fce5 100644
--- a/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler.cc
+++ b/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler.cc
@@ -10,7 +10,6 @@
#include "base/i18n/time_formatting.h"
#include "base/logging.h"
#include "base/synchronization/condition_variable.h"
-#include "chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger.h"
#include "chrome/browser/ash/privacy_hub/privacy_hub_util.h"
#include "chrome/browser/ash/system/timezone_util.h"
#include "chrome/common/chrome_features.h"
@@ -23,7 +22,6 @@
CrasAudioHandler::Get()->IsInputMutedBySecurityCurtain()) {}
PrivacyHubHandler::~PrivacyHubHandler() {
- TriggerHatsIfPageWasOpened();
privacy_hub_util::SetFrontend(nullptr);
}
@@ -62,18 +60,6 @@
"getCurrentSunsetTime",
base::BindRepeating(&PrivacyHubHandler::HandleGetCurrentSunSetTime,
base::Unretained(this)));
-
- if (base::FeatureList::IsEnabled(
- ::features::kHappinessTrackingPrivacyHubPostLaunch)) {
- web_ui()->RegisterMessageCallback(
- "osPrivacyPageWasOpened",
- base::BindRepeating(&PrivacyHubHandler::HandlePrivacyPageOpened,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "leftOsPrivacyPage",
- base::BindRepeating(&PrivacyHubHandler::HandlePrivacyPageClosed,
- base::Unretained(this)));
- }
}
void PrivacyHubHandler::NotifyJS(const std::string& event_name,
@@ -103,33 +89,6 @@
NotifyJS("microphone-muted-by-security-curtain-changed", base::Value(muted));
}
-void PrivacyHubHandler::SetPrivacyPageOpenedTimeStampForTesting(
- base::TimeTicks time_stamp) {
- privacy_page_opened_timestamp_ = time_stamp;
-}
-
-void PrivacyHubHandler::HandlePrivacyPageOpened(const base::Value::List& args) {
- DCHECK(args.empty());
- DCHECK(base::FeatureList::IsEnabled(
- ::features::kHappinessTrackingPrivacyHubPostLaunch));
-
- // TODO(b/290646585): Replace with a CHECK().
- AllowJavascript();
-
- privacy_page_opened_timestamp_ = base::TimeTicks::Now();
-}
-
-void PrivacyHubHandler::HandlePrivacyPageClosed(const base::Value::List& args) {
- DCHECK(args.empty());
- DCHECK(base::FeatureList::IsEnabled(
- ::features::kHappinessTrackingPrivacyHubPostLaunch));
-
- // TODO(b/290646585): Replace with a CHECK().
- AllowJavascript();
-
- TriggerHatsIfPageWasOpened();
-}
-
void PrivacyHubHandler::HandleInitialMicrophoneSwitchState(
const base::Value::List& args) {
const auto callback_id = ValidateArgs(args);
@@ -193,13 +152,4 @@
return args[0];
}
-void PrivacyHubHandler::TriggerHatsIfPageWasOpened() {
- if (const base::TimeTicks now = base::TimeTicks::Now();
- (now - privacy_page_opened_timestamp_.value_or(now)) >=
- base::Seconds(5)) {
- privacy_page_opened_timestamp_.reset();
- PrivacyHubHatsTrigger::Get().ShowSurveyAfterDelayElapsed();
- }
-}
-
} // namespace ash::settings
diff --git a/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler.h b/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler.h
index 804e2cb5..bccba37e 100644
--- a/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler.h
+++ b/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler.h
@@ -9,7 +9,6 @@
#include <string>
#include "ash/public/cpp/privacy_hub_delegate.h"
-#include "base/time/time.h"
#include "base/values.h"
#include "chromeos/ash/components/audio/cras_audio_handler.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -34,18 +33,12 @@
// CrasAudioHandler::AudioObserver
void OnInputMutedBySecurityCurtainChanged(bool muted) override;
- void SetPrivacyPageOpenedTimeStampForTesting(base::TimeTicks time_stamp);
-
protected:
// content::WebUIMessageHandler
void RegisterMessages() override;
void NotifyJS(const std::string& event_name, const base::Value& value);
- void HandlePrivacyPageOpened(const base::Value::List& args);
-
- void HandlePrivacyPageClosed(const base::Value::List& args);
-
void HandleInitialMicrophoneSwitchState(const base::Value::List& args);
void HandleInitialMicrophoneMutedBySecurityCurtainState(
const base::Value::List& args);
@@ -60,11 +53,8 @@
// return the callback_id
const base::ValueView ValidateArgs(const base::Value::List& args);
- void TriggerHatsIfPageWasOpened();
-
bool mic_muted_by_security_curtain_ = false;
- std::optional<base::TimeTicks> privacy_page_opened_timestamp_;
base::WeakPtrFactory<PrivacyHubHandler> weak_factory_{this};
};
diff --git a/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler_unittest.cc b/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler_unittest.cc
index b953a83..3d231ed 100644
--- a/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler_unittest.cc
+++ b/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_hub_handler_unittest.cc
@@ -9,7 +9,6 @@
#include "base/ranges/algorithm.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
-#include "chrome/browser/ash/privacy_hub/privacy_hub_hats_trigger.h"
#include "chrome/browser/ash/privacy_hub/privacy_hub_util.h"
#include "chrome/common/chrome_features.h"
#include "chromeos/ash/components/audio/cras_audio_handler.h"
@@ -25,8 +24,6 @@
using PrivacyHubHandler::HandleInitialCameraLedFallbackState;
using PrivacyHubHandler::HandleInitialMicrophoneSwitchState;
- using PrivacyHubHandler::HandlePrivacyPageClosed;
- using PrivacyHubHandler::HandlePrivacyPageOpened;
};
using cps = cros::mojom::CameraPrivacySwitchState;
@@ -143,21 +140,6 @@
scoped_camera_led_fallback_;
};
-class PrivacyHubHandlerHatsTest : public PrivacyHubHandlerTest {
- public:
- PrivacyHubHandlerHatsTest() {
- feature_list_.InitAndEnableFeature(
- ::features::kHappinessTrackingPrivacyHubPostLaunch);
- }
-
- bool IsTimerStarted() {
- return PrivacyHubHatsTrigger::Get().GetTimerForTesting().IsRunning();
- }
-
- private:
- base::test::ScopedFeatureList feature_list_;
-};
-
class PrivacyHubHandlerCameraSwitchTest
: public PrivacyHubHandlerTest,
public testing::WithParamInterface<bool> {
@@ -225,49 +207,6 @@
testing::Values(true, false),
testing::PrintToStringParamName());
-TEST_F(PrivacyHubHandlerHatsTest, OnlyTriggerHatsIfPageWasVisitedLongEnough) {
- const base::Value::List args;
-
- EXPECT_FALSE(IsTimerStarted());
-
- // We trigger the HaTS survey on the leave event but the user hasn't visited
- // the page yet.
- privacy_hub_handler_.HandlePrivacyPageClosed(args);
- EXPECT_FALSE(IsTimerStarted());
-
- // User goes to the page.
- privacy_hub_handler_.HandlePrivacyPageOpened(args);
- EXPECT_FALSE(IsTimerStarted());
-
- // Simulate the user stays on the page for 5 seconds.
- privacy_hub_handler_.SetPrivacyPageOpenedTimeStampForTesting(
- base::TimeTicks::Now() - base::Seconds(5));
- EXPECT_FALSE(IsTimerStarted());
-
- // And leaves it again, now the survey should be triggered.
- privacy_hub_handler_.HandlePrivacyPageClosed(args);
- EXPECT_TRUE(IsTimerStarted());
-}
-
-TEST_F(PrivacyHubHandlerHatsTest, DontTriggerHatsIfUserLeftEarly) {
- const base::Value::List args;
-
- EXPECT_FALSE(IsTimerStarted());
-
- // We trigger the HaTS survey on the leave event but the user hasn't visited
- // the page yet.
- privacy_hub_handler_.HandlePrivacyPageClosed(args);
- EXPECT_FALSE(IsTimerStarted());
-
- // User goes to the page.
- privacy_hub_handler_.HandlePrivacyPageOpened(args);
- EXPECT_FALSE(IsTimerStarted());
-
- // And leaves it again immediately, now the survey shouldn't be triggered.
- privacy_hub_handler_.HandlePrivacyPageClosed(args);
- EXPECT_FALSE(IsTimerStarted());
-}
-
TEST_F(PrivacyHubHandlerTest, MicrophoneMutedBySecurityCurtainChanged) {
privacy_hub_handler_.OnInputMutedBySecurityCurtainChanged(true);
@@ -302,33 +241,6 @@
".*Did not expect arguments.*");
}
-TEST_F(PrivacyHubHandlerDeathTest, HandlePrivacyPageOpened) {
- base::Value::List args;
- args.Append(this_test_name_);
-
- EXPECT_DEATH(privacy_hub_handler_.HandlePrivacyPageOpened(args), ".*empty.*");
-}
-
-TEST_F(PrivacyHubHandlerDeathTest, HandlePrivacyPageClosed) {
- base::Value::List args;
- args.Append(this_test_name_);
-
- EXPECT_DEATH(privacy_hub_handler_.HandlePrivacyPageClosed(args), ".*empty.*");
-}
-
-TEST_F(PrivacyHubHandlerDeathTest, OnlyTriggerHatsIfFeatureIsEnabled) {
- const base::Value::List args;
- base::test::ScopedFeatureList feature_list;
- feature_list.InitAndDisableFeature(
- ::features::kHappinessTrackingPrivacyHubPostLaunch);
-
- // User goes to the page.
- EXPECT_DEATH(privacy_hub_handler_.HandlePrivacyPageOpened(args),
- "base::FeatureList::IsEnabled");
- EXPECT_DEATH(privacy_hub_handler_.HandlePrivacyPageClosed(args),
- "base::FeatureList::IsEnabled");
-}
-
#endif
} // namespace ash::settings
diff --git a/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_section.cc b/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_section.cc
index 010423ff..ce08d86f2 100644
--- a/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_section.cc
+++ b/chrome/browser/ui/webui/ash/settings/pages/privacy/privacy_section.cc
@@ -631,10 +631,6 @@
html_source->AddBoolean("isAuthPanelEnabled",
ash::features::IsUseAuthPanelInSessionEnabled());
- html_source->AddBoolean(
- "isPrivacyHubHatsEnabled",
- base::FeatureList::IsEnabled(
- ::features::kHappinessTrackingPrivacyHubPostLaunch));
html_source->AddBoolean("showPrivacyHubLocationControl",
ash::features::IsCrosPrivacyHubLocationEnabled());
html_source->AddBoolean("showSpeakOnMuteDetectionPage",