dark_light_mode: Remove the dark light mode educational nudge
As what has been discussed in the bug, remove the educations nudge since the dark / light mode has been launched for over 5 milestones. Bug: b/254736195 Change-Id: I3669b2eaff4f9bff5c5a631e1c2f063c1082aa47 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4375504 Commit-Queue: Connie Xu <conniekxu@chromium.org> Reviewed-by: Gabriel Charette <gab@chromium.org> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org> Reviewed-by: Sean Kau <skau@chromium.org> Cr-Commit-Position: refs/heads/main@{#1123266}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e190ef48a4
commit
4d14f65cb8
@ -1075,10 +1075,6 @@ component("ash") {
|
||||
"style/color_util.h",
|
||||
"style/dark_light_mode_controller_impl.cc",
|
||||
"style/dark_light_mode_controller_impl.h",
|
||||
"style/dark_light_mode_nudge.cc",
|
||||
"style/dark_light_mode_nudge.h",
|
||||
"style/dark_light_mode_nudge_controller.cc",
|
||||
"style/dark_light_mode_nudge_controller.h",
|
||||
"style/default_color_constants.h",
|
||||
"style/default_colors.cc",
|
||||
"style/default_colors.h",
|
||||
@ -3100,7 +3096,6 @@ test("ash_unittests") {
|
||||
"style/color_palette_controller_unittest.cc",
|
||||
"style/color_util_unittest.cc",
|
||||
"style/dark_light_mode_controller_unittests.cc",
|
||||
"style/dark_light_mode_nudge_controller_unittests.cc",
|
||||
"style/system_components_unittests.cc",
|
||||
"system/accessibility/accessibility_detailed_view_unittest.cc",
|
||||
"system/accessibility/accessibility_feature_pod_controller_unittest.cc",
|
||||
|
@ -760,15 +760,6 @@ const char kDynamicColorColorScheme[] = "ash.dynamic_color.color_scheme";
|
||||
// color palette. It is an ARGB 32-bit unsigned integer stored as a uint64.
|
||||
const char kDynamicColorSeedColor[] = "ash.dynamic_color.seed_color";
|
||||
|
||||
// An integer pref storing the number of times that dark/light mode educational
|
||||
// can still be shown. It will be initialized to the maximum number of times
|
||||
// that the nudge can be shown. And will be set to 0 if the user toggled the
|
||||
// entry points of dark/light mode ("Dark theme" inside quick settings or
|
||||
// personalization hub), which means the user already knows how to change the
|
||||
// color mode of the system.
|
||||
const char kDarkLightModeNudgeLeftToShowCount[] =
|
||||
"ash.dark_light_mode.educational_nudge";
|
||||
|
||||
// An integer pref storing the type of automatic scheduling of turning on and
|
||||
// off the dark mode feature similar to `kNightLightScheduleType`, but
|
||||
// custom scheduling (2) is the same as sunset to sunrise scheduling (1)
|
||||
|
@ -367,8 +367,6 @@ extern const char kMessageCenterLockScreenModeHideSensitive[];
|
||||
|
||||
COMPONENT_EXPORT(ASH_CONSTANTS) extern const char kAmbientColorEnabled[];
|
||||
COMPONENT_EXPORT(ASH_CONSTANTS) extern const char kDarkModeEnabled[];
|
||||
COMPONENT_EXPORT(ASH_CONSTANTS)
|
||||
extern const char kDarkLightModeNudgeLeftToShowCount[];
|
||||
COMPONENT_EXPORT(ASH_CONSTANTS) extern const char kDarkModeScheduleType[];
|
||||
COMPONENT_EXPORT(ASH_CONSTANTS) extern const char kNightLightEnabled[];
|
||||
COMPONENT_EXPORT(ASH_CONSTANTS) extern const char kNightLightTemperature[];
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "ash/session/session_controller_impl.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/style/color_util.h"
|
||||
#include "ash/style/dark_light_mode_nudge_controller.h"
|
||||
#include "ash/wallpaper/wallpaper_controller_impl.h"
|
||||
#include "components/account_id/account_id.h"
|
||||
#include "components/prefs/pref_change_registrar.h"
|
||||
@ -70,8 +69,7 @@ DarkLightModeControllerImpl::DarkLightModeControllerImpl()
|
||||
: ScheduledFeature(prefs::kDarkModeEnabled,
|
||||
prefs::kDarkModeScheduleType,
|
||||
std::string(),
|
||||
std::string()),
|
||||
nudge_controller_(std::make_unique<DarkLightModeNudgeController>()) {
|
||||
std::string()) {
|
||||
DCHECK(!g_instance);
|
||||
g_instance = this;
|
||||
|
||||
@ -118,8 +116,6 @@ void DarkLightModeControllerImpl::RegisterProfilePrefs(
|
||||
|
||||
registry->RegisterBooleanPref(prefs::kDarkModeEnabled,
|
||||
kDefaultDarkModeEnabled);
|
||||
registry->RegisterIntegerPref(prefs::kDarkLightModeNudgeLeftToShowCount,
|
||||
kDarkLightModeNudgeMaxShownCount);
|
||||
}
|
||||
|
||||
void DarkLightModeControllerImpl::SetAutoScheduleEnabled(bool enabled) {
|
||||
@ -140,11 +136,6 @@ void DarkLightModeControllerImpl::ToggleColorMode() {
|
||||
!IsDarkModeEnabled());
|
||||
active_user_pref_service_->CommitPendingWrite();
|
||||
NotifyColorModeChanges();
|
||||
SystemNudgeController::RecordNudgeAction(NudgeCatalogName::kDarkLightMode);
|
||||
|
||||
// Updates showing logic of educational nudge on toggling the entry points of
|
||||
// dark/light mode.
|
||||
nudge_controller_->ToggledByUser();
|
||||
}
|
||||
|
||||
void DarkLightModeControllerImpl::AddObserver(ColorModeObserver* observer) {
|
||||
@ -271,14 +262,6 @@ void DarkLightModeControllerImpl::OnSessionStateChanged(
|
||||
}
|
||||
|
||||
RefreshColorsOnColorMode(IsDarkModeEnabled());
|
||||
|
||||
if (state == session_manager::SessionState::ACTIVE) {
|
||||
nudge_controller_->MaybeShowNudge();
|
||||
}
|
||||
}
|
||||
|
||||
void DarkLightModeControllerImpl::SetShowNudgeForTesting(bool value) {
|
||||
nudge_controller_->set_show_nudge_for_testing(value); // IN-TEST
|
||||
}
|
||||
|
||||
void DarkLightModeControllerImpl::RefreshFeatureState() {}
|
||||
|
@ -21,12 +21,10 @@ class PrefService;
|
||||
namespace ash {
|
||||
|
||||
class ColorModeObserver;
|
||||
class DarkLightModeNudgeController;
|
||||
|
||||
// Controls the behavior of dark/light mode. Turns on the dark mode at sunset
|
||||
// and off at sunrise if auto schedule is set (custom start and end for
|
||||
// scheduling is not supported). And determine whether to show the educational
|
||||
// nudge for users on login.
|
||||
// scheduling is not supported).
|
||||
class ASH_EXPORT DarkLightModeControllerImpl
|
||||
: public DarkLightModeController,
|
||||
public LoginDataDispatcher::Observer,
|
||||
@ -72,8 +70,6 @@ class ASH_EXPORT DarkLightModeControllerImpl
|
||||
void OnActiveUserPrefServiceChanged(PrefService* prefs) override;
|
||||
void OnSessionStateChanged(session_manager::SessionState state) override;
|
||||
|
||||
void SetShowNudgeForTesting(bool value);
|
||||
|
||||
protected:
|
||||
// ScheduledFeature:
|
||||
void RefreshFeatureState() override;
|
||||
@ -94,8 +90,6 @@ class ASH_EXPORT DarkLightModeControllerImpl
|
||||
base::ScopedClosureRunner GetNotifyOnDarkModeChangeClosure();
|
||||
void NotifyIfDarkModeChanged(bool old_is_dark_mode_enabled);
|
||||
|
||||
std::unique_ptr<DarkLightModeNudgeController> nudge_controller_;
|
||||
|
||||
// The default color is DARK when the DarkLightMode feature is disabled. But
|
||||
// we can also override it to LIGHT through ScopedLightModeAsDefault. This is
|
||||
// done to help keeping some of the UI elements as LIGHT by default before
|
||||
|
@ -1,61 +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.
|
||||
|
||||
#include "ash/style/dark_light_mode_nudge.h"
|
||||
|
||||
#include "ash/constants/notifier_catalogs.h"
|
||||
#include "ash/resources/vector_icons/vector_icons.h"
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/style/ash_color_provider.h"
|
||||
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/views/controls/label.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
namespace {
|
||||
|
||||
// The size of the dark light mode icon.
|
||||
constexpr int kIconSize = 20;
|
||||
|
||||
// The minimum width of the label.
|
||||
constexpr int kMinLabelWidth = 200;
|
||||
|
||||
// The spacing between the icon and label in the nudge view.
|
||||
constexpr int kIconLabelSpacing = 16;
|
||||
|
||||
// The padding which separates the nudge's border with its inner contents.
|
||||
constexpr int kNudgePadding = 16;
|
||||
|
||||
constexpr char kDarkLightModeNudgeName[] = "DarkLightModeEducationalNudge";
|
||||
|
||||
} // namespace
|
||||
|
||||
DarkLightModeNudge::DarkLightModeNudge()
|
||||
: SystemNudge(kDarkLightModeNudgeName,
|
||||
NudgeCatalogName::kDarkLightMode,
|
||||
kIconSize,
|
||||
kIconLabelSpacing,
|
||||
kNudgePadding) {}
|
||||
|
||||
DarkLightModeNudge::~DarkLightModeNudge() = default;
|
||||
|
||||
std::unique_ptr<SystemNudgeLabel> DarkLightModeNudge::CreateLabelView() const {
|
||||
return std::make_unique<SystemNudgeLabel>(GetAccessibilityText(),
|
||||
kMinLabelWidth);
|
||||
}
|
||||
|
||||
const gfx::VectorIcon& DarkLightModeNudge::GetIcon() const {
|
||||
return kUnifiedMenuDarkModeIcon;
|
||||
}
|
||||
|
||||
std::u16string DarkLightModeNudge::GetAccessibilityText() const {
|
||||
return l10n_util::GetStringUTF16(
|
||||
TabletMode::Get()->InTabletMode()
|
||||
? IDS_ASH_DARK_LIGHT_MODE_EDUCATIONAL_NUDGE_IN_TABLET_MODE
|
||||
: IDS_ASH_DARK_LIGHT_MODE_EDUCATIONAL_NUDGE_IN_CLAMSHELL_MODE);
|
||||
}
|
||||
|
||||
} // namespace ash
|
@ -1,29 +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.
|
||||
|
||||
#ifndef ASH_STYLE_DARK_LIGHT_MODE_NUDGE_H_
|
||||
#define ASH_STYLE_DARK_LIGHT_MODE_NUDGE_H_
|
||||
|
||||
#include "ash/system/tray/system_nudge.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
// Implements an educational nudge for dark light mode.
|
||||
class DarkLightModeNudge : public SystemNudge {
|
||||
public:
|
||||
DarkLightModeNudge();
|
||||
DarkLightModeNudge(const DarkLightModeNudge&) = delete;
|
||||
DarkLightModeNudge& operator=(const DarkLightModeNudge&) = delete;
|
||||
~DarkLightModeNudge() override;
|
||||
|
||||
protected:
|
||||
// SystemNudge:
|
||||
std::unique_ptr<SystemNudgeLabel> CreateLabelView() const override;
|
||||
const gfx::VectorIcon& GetIcon() const override;
|
||||
std::u16string GetAccessibilityText() const override;
|
||||
};
|
||||
|
||||
} // namespace ash
|
||||
|
||||
#endif // ASH_STYLE_DARK_LIGHT_MODE_NUDGE_H_
|
@ -1,100 +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.
|
||||
|
||||
#include "ash/style/dark_light_mode_nudge_controller.h"
|
||||
|
||||
#include "ash/constants/ash_pref_names.h"
|
||||
#include "ash/constants/ash_switches.h"
|
||||
#include "ash/session/session_controller_impl.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/style/dark_light_mode_controller_impl.h"
|
||||
#include "ash/style/dark_light_mode_nudge.h"
|
||||
#include "base/command_line.h"
|
||||
#include "chromeos/constants/chromeos_features.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/prefs/scoped_user_pref_update.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
namespace {
|
||||
|
||||
PrefService* GetActiveUserPrefService() {
|
||||
return DarkLightModeControllerImpl::Get()->active_user_pref_service();
|
||||
}
|
||||
|
||||
void SetRemainingShownCount(int count) {
|
||||
PrefService* prefs = GetActiveUserPrefService();
|
||||
if (prefs)
|
||||
prefs->SetInteger(prefs::kDarkLightModeNudgeLeftToShowCount, count);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
DarkLightModeNudgeController::DarkLightModeNudgeController() = default;
|
||||
|
||||
DarkLightModeNudgeController::~DarkLightModeNudgeController() = default;
|
||||
|
||||
// static
|
||||
int DarkLightModeNudgeController::GetRemainingShownCount() {
|
||||
const PrefService* prefs = GetActiveUserPrefService();
|
||||
return prefs ? prefs->GetInteger(prefs::kDarkLightModeNudgeLeftToShowCount)
|
||||
: 0;
|
||||
}
|
||||
|
||||
void DarkLightModeNudgeController::MaybeShowNudge() {
|
||||
if (!ShouldShowNudge())
|
||||
return;
|
||||
|
||||
const int shown_count = GetRemainingShownCount();
|
||||
ShowNudge();
|
||||
SetRemainingShownCount(shown_count - 1);
|
||||
}
|
||||
|
||||
void DarkLightModeNudgeController::ToggledByUser() {
|
||||
SetRemainingShownCount(0);
|
||||
}
|
||||
|
||||
std::unique_ptr<SystemNudge> DarkLightModeNudgeController::CreateSystemNudge() {
|
||||
return std::make_unique<DarkLightModeNudge>();
|
||||
}
|
||||
|
||||
bool DarkLightModeNudgeController::ShouldShowNudge() const {
|
||||
if (!chromeos::features::IsDarkLightModeEnabled())
|
||||
return false;
|
||||
|
||||
// Do not show the nudge if it is set to be hidden in the tests.
|
||||
if (hide_nudge_for_testing_)
|
||||
return false;
|
||||
|
||||
// Do not show if the command line flag to hide nudges is set.
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshNoNudges))
|
||||
return false;
|
||||
|
||||
auto* session_controller = Shell::Get()->session_controller();
|
||||
if (!session_controller->IsActiveUserSessionStarted())
|
||||
return false;
|
||||
|
||||
absl::optional<user_manager::UserType> user_type =
|
||||
session_controller->GetUserType();
|
||||
// Must have a `user_type` because of the active user session check above.
|
||||
DCHECK(user_type);
|
||||
switch (*user_type) {
|
||||
case user_manager::USER_TYPE_REGULAR:
|
||||
case user_manager::USER_TYPE_CHILD:
|
||||
// We only allow regular and child accounts to see the nudge.
|
||||
break;
|
||||
case user_manager::USER_TYPE_GUEST:
|
||||
case user_manager::USER_TYPE_PUBLIC_ACCOUNT:
|
||||
case user_manager::USER_TYPE_KIOSK_APP:
|
||||
case user_manager::USER_TYPE_ARC_KIOSK_APP:
|
||||
case user_manager::USER_TYPE_WEB_KIOSK_APP:
|
||||
case user_manager::USER_TYPE_ACTIVE_DIRECTORY:
|
||||
case user_manager::NUM_USER_TYPES:
|
||||
return false;
|
||||
}
|
||||
|
||||
return GetRemainingShownCount() > 0;
|
||||
}
|
||||
|
||||
} // namespace ash
|
@ -1,56 +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.
|
||||
|
||||
#ifndef ASH_STYLE_DARK_LIGHT_MODE_NUDGE_CONTROLLER_H_
|
||||
#define ASH_STYLE_DARK_LIGHT_MODE_NUDGE_CONTROLLER_H_
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/system/tray/system_nudge_controller.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
class SystemNudge;
|
||||
|
||||
// Controls the showing and hiding of the dark/light mode educational nudge.
|
||||
// SystemNudgeController will control the animation, time duration etc of the
|
||||
// nudge.
|
||||
class ASH_EXPORT DarkLightModeNudgeController : public SystemNudgeController {
|
||||
public:
|
||||
DarkLightModeNudgeController();
|
||||
DarkLightModeNudgeController(const DarkLightModeNudgeController&) = delete;
|
||||
DarkLightModeNudgeController& operator=(const DarkLightModeNudgeController&) =
|
||||
delete;
|
||||
~DarkLightModeNudgeController() override;
|
||||
|
||||
// Gets the remaining number of times that the educational nudge can be shown.
|
||||
static int GetRemainingShownCount();
|
||||
|
||||
// If possible, this will show the nudge that educates the user how to switch
|
||||
// between the dark and light mode.
|
||||
void MaybeShowNudge();
|
||||
|
||||
// Called when the feature's state is toggled manually by the user.
|
||||
void ToggledByUser();
|
||||
|
||||
void set_show_nudge_for_testing(bool value) {
|
||||
hide_nudge_for_testing_ = !value;
|
||||
}
|
||||
|
||||
protected:
|
||||
// SystemNudgeController:
|
||||
std::unique_ptr<SystemNudge> CreateSystemNudge() override;
|
||||
|
||||
private:
|
||||
// Returns true if the educational nudge should be shown.
|
||||
bool ShouldShowNudge() const;
|
||||
|
||||
// Used to indicate whether to hide the nudge in tests. Will be initialized to
|
||||
// hide for ash tests through `set_show_nudge_for_testing` above. See
|
||||
// AshTestHelper::SetUp for more details.
|
||||
bool hide_nudge_for_testing_ = false;
|
||||
};
|
||||
|
||||
} // namespace ash
|
||||
|
||||
#endif // ASH_STYLE_DARK_LIGHT_MODE_NUDGE_CONTROLLER_H_
|
@ -1,112 +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.
|
||||
|
||||
#include "ash/style/dark_light_mode_nudge_controller.h"
|
||||
|
||||
#include "ash/constants/ash_constants.h"
|
||||
#include "ash/constants/ash_switches.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/style/dark_light_mode_controller_impl.h"
|
||||
#include "ash/system/dark_mode/dark_mode_feature_pod_controller.h"
|
||||
#include "ash/system/unified/unified_system_tray.h"
|
||||
#include "ash/system/unified/unified_system_tray_bubble.h"
|
||||
#include "ash/test/ash_test_base.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "chromeos/constants/chromeos_features.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
namespace {
|
||||
|
||||
const char kUser[] = "user@gmail.com";
|
||||
const AccountId account_id = AccountId::FromUserEmailGaiaId(kUser, kUser);
|
||||
|
||||
} // namespace
|
||||
|
||||
class DarkLightModeNudgeControllerTest : public NoSessionAshTestBase {
|
||||
public:
|
||||
DarkLightModeNudgeControllerTest() {
|
||||
scoped_feature_list_.InitAndEnableFeature(
|
||||
chromeos::features::kDarkLightMode);
|
||||
}
|
||||
DarkLightModeNudgeControllerTest(const DarkLightModeNudgeControllerTest&) =
|
||||
delete;
|
||||
DarkLightModeNudgeControllerTest& operator=(
|
||||
const DarkLightModeNudgeControllerTest&) = delete;
|
||||
~DarkLightModeNudgeControllerTest() override = default;
|
||||
|
||||
// NoSessionAshTestBase:
|
||||
void SetUp() override {
|
||||
NoSessionAshTestBase::SetUp();
|
||||
Shell::Get()->dark_light_mode_controller()->SetShowNudgeForTesting(true);
|
||||
}
|
||||
|
||||
private:
|
||||
base::test::ScopedFeatureList scoped_feature_list_;
|
||||
};
|
||||
|
||||
TEST_F(DarkLightModeNudgeControllerTest, NoNudgeInGuestSession) {
|
||||
SimulateGuestLogin();
|
||||
EXPECT_EQ(kDarkLightModeNudgeMaxShownCount,
|
||||
DarkLightModeNudgeController::GetRemainingShownCount());
|
||||
}
|
||||
|
||||
TEST_F(DarkLightModeNudgeControllerTest, NoNudgeWhenSkippedByCommandLineFlag) {
|
||||
// Unit tests run with a scoped command line, so directly set the flag.
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kAshNoNudges);
|
||||
SimulateUserLogin(account_id);
|
||||
EXPECT_EQ(kDarkLightModeNudgeMaxShownCount,
|
||||
DarkLightModeNudgeController::GetRemainingShownCount());
|
||||
}
|
||||
|
||||
TEST_F(DarkLightModeNudgeControllerTest, NoNudgeInLockScreen) {
|
||||
SimulateUserLogin(account_id);
|
||||
EXPECT_EQ(kDarkLightModeNudgeMaxShownCount - 1,
|
||||
DarkLightModeNudgeController::GetRemainingShownCount());
|
||||
|
||||
// Switch to lock screen should not show the nudge again.
|
||||
GetSessionControllerClient()->LockScreen();
|
||||
EXPECT_EQ(kDarkLightModeNudgeMaxShownCount - 1,
|
||||
DarkLightModeNudgeController::GetRemainingShownCount());
|
||||
}
|
||||
|
||||
TEST_F(DarkLightModeNudgeControllerTest, NudgeShownCount) {
|
||||
// Login `kDarkLightModeNudgeMaxShownCount` times and verity the remaining
|
||||
// nudge shown count.
|
||||
for (int i = kDarkLightModeNudgeMaxShownCount; i > 0; i--) {
|
||||
SimulateUserLogin(account_id);
|
||||
EXPECT_EQ(i - 1, DarkLightModeNudgeController::GetRemainingShownCount());
|
||||
ClearLogin();
|
||||
}
|
||||
// The remaining nudge shown count should be 0 after
|
||||
// `kDarkLightModeNudgeMaxShownCount` times login, which means the nudge will
|
||||
// not be shown again in next time login.
|
||||
EXPECT_EQ(0, DarkLightModeNudgeController::GetRemainingShownCount());
|
||||
}
|
||||
|
||||
// Flaky. https://crbug.com/1325224
|
||||
TEST_F(DarkLightModeNudgeControllerTest,
|
||||
DISABLED_NoNudgeAfterColorModeToggled) {
|
||||
SimulateUserLogin(account_id);
|
||||
UnifiedSystemTray* system_tray = GetPrimaryUnifiedSystemTray();
|
||||
system_tray->ShowBubble();
|
||||
std::unique_ptr<DarkModeFeaturePodController>
|
||||
dark_mode_feature_pod_controller =
|
||||
std::make_unique<DarkModeFeaturePodController>(
|
||||
system_tray->bubble()->unified_system_tray_controller());
|
||||
|
||||
EXPECT_EQ(kDarkLightModeNudgeMaxShownCount - 1,
|
||||
DarkLightModeNudgeController::GetRemainingShownCount());
|
||||
EXPECT_GT(DarkLightModeNudgeController::GetRemainingShownCount(), 0);
|
||||
// Toggle the "Dark theme" feature pod button inside quick settings.
|
||||
dark_mode_feature_pod_controller->CreateButton();
|
||||
dark_mode_feature_pod_controller->OnIconPressed();
|
||||
// The remaining nudge shown count should be 0 after toggling the "Dark theme"
|
||||
// feature pod button to switch color mode. Even though the nudge hasn't been
|
||||
// shown `kDarkLightModeNudgeMaxShownCount` yet.
|
||||
EXPECT_EQ(0, DarkLightModeNudgeController::GetRemainingShownCount());
|
||||
}
|
||||
|
||||
} // namespace ash
|
@ -319,15 +319,6 @@ void AshTestHelper::SetUp(InitParams init_params) {
|
||||
Shell::CreateInstance(std::move(shell_init_params));
|
||||
Shell* shell = Shell::Get();
|
||||
|
||||
// The dark/light mode educational nudge is expected to be shown when session
|
||||
// state changed to ACTIVE. This means it might be shown above the shelf in
|
||||
// all the tests with an active user session. This setting here make it will
|
||||
// not be shown by default in tests. As keep it shown will change the
|
||||
// operations needed in many of the tests, e.g, when productive launcher is
|
||||
// shown as well, we need one more click outside of the launcher to dismiss
|
||||
// the nudge first before dismissing the launcher.
|
||||
shell->dark_light_mode_controller()->SetShowNudgeForTesting(false);
|
||||
|
||||
chromeos::MultitaskMenuNudgeController::SetSuppressNudgeForTesting(true);
|
||||
|
||||
// Set up a test wallpaper controller client before signing in any users. At
|
||||
|
@ -120,10 +120,6 @@ void ThemeSelectionScreen::OnUserAction(const base::Value::List& args) {
|
||||
Profile* profile = ProfileManager::GetActiveUserProfile();
|
||||
const std::string& action_id = args[0].GetString();
|
||||
|
||||
// Set the nudge shown count to 0 once the user goes through the Dark / Light
|
||||
// setup to avoiding triggering Dark / Light nudge after OOBE.
|
||||
profile->GetPrefs()->SetInteger(prefs::kDarkLightModeNudgeLeftToShowCount, 0);
|
||||
|
||||
if (action_id == kUserActionSelect) {
|
||||
const SelectedTheme selected_theme =
|
||||
static_cast<SelectedTheme>(args[1].GetInt());
|
||||
|
@ -124,12 +124,7 @@ class ThemeSelectionScreenTest
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(ThemeSelectionScreenTest, ProceedWithDefaultTheme) {
|
||||
ShowThemeSelectionScreen();
|
||||
Profile* profile = ProfileManager::GetActiveUserProfile();
|
||||
test::OobeJS().ClickOnPath(kNextButtonPath);
|
||||
// Verify that remaining nudge shown count is 0 after proceeding with the
|
||||
// default theme.
|
||||
EXPECT_EQ(0, profile->GetPrefs()->GetInteger(
|
||||
prefs::kDarkLightModeNudgeLeftToShowCount));
|
||||
WaitForScreenExit();
|
||||
|
||||
EXPECT_THAT(
|
||||
@ -170,10 +165,6 @@ IN_PROC_BROWSER_TEST_P(ThemeSelectionScreenTest, SelectTheme) {
|
||||
test::OobeJS().ClickOnPath(kNextButtonPath);
|
||||
EXPECT_THAT(histogram_tester_.GetAllSamples(kSelectedThemeHistogram),
|
||||
ElementsAre(base::Bucket(static_cast<int>(theme), 1)));
|
||||
|
||||
// Verify that remaining nudge shown count is 0 after user selects the theme.
|
||||
EXPECT_EQ(0, profile->GetPrefs()->GetInteger(
|
||||
prefs::kDarkLightModeNudgeLeftToShowCount));
|
||||
WaitForScreenExit();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ash/constants/ash_constants.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "build/branding_buildflags.h"
|
||||
@ -827,6 +828,12 @@ const char kGlanceablesSignoutScreenshotDuration[] =
|
||||
const char kEasyUnlockLocalStateUserPrefs[] = "easy_unlock.user_prefs";
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
// Deprecated 03/2023
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
const char kDarkLightModeNudgeLeftToShowCount[] =
|
||||
"ash.dark_light_mode.educational_nudge";
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
// Register local state used only for migration (clearing or moving to a new
|
||||
// key).
|
||||
void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
|
||||
@ -1120,6 +1127,12 @@ void RegisterProfilePrefsForMigration(
|
||||
// Deprecated 03/2023.
|
||||
registry->RegisterTimePref(
|
||||
kGoogleSearchDomainMixingMetricsEmitterLastMetricsTime, base::Time());
|
||||
|
||||
// Deprecated 03/2023.
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
registry->RegisterIntegerPref(kDarkLightModeNudgeLeftToShowCount,
|
||||
ash::kDarkLightModeNudgeMaxShownCount);
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@ -2175,6 +2188,11 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
|
||||
profile_prefs->ClearPref(
|
||||
kGoogleSearchDomainMixingMetricsEmitterLastMetricsTime);
|
||||
|
||||
// Added 03/2023.
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
profile_prefs->ClearPref(kDarkLightModeNudgeLeftToShowCount);
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
|
||||
// Please don't delete the following line. It is used by PRESUBMIT.py.
|
||||
// END_MIGRATE_OBSOLETE_PROFILE_PREFS
|
||||
|
||||
|
Reference in New Issue
Block a user